Details
-
Feature Request
-
Resolution: Obsolete
-
Major
-
None
-
None
-
Documentation (Ref Guide, User Guide, etc.), Interactive Demo/Tutorial, Compatibility/Configuration
-
0
-
0%
Description
The ScriptService.java interface allows .bsh authors to return MBean interfaces for their .bsh script in an array of classes.
Unfortunately, this requires coding an external Java interface class, which sort of precludes its usefulness.
I think what might be better, instead is to proactively expose all the defined methods in the script namespace as MBean operations and attributes:
http://www.beanshell.org/javadoc/bsh/Interpreter.html#getNameSpace()
http://www.beanshell.org/javadoc/bsh/NameSpace.html#getVariableNames()
http://www.beanshell.org/javadoc/bsh/NameSpace.html#getMethods()
This violates any safety of encapsulation but if you're coding a .bsh why would you care? *
- okay, if you do, maybe there should be some way to turn it off?
Example script:
String name = "joe";
void invoke() {
System.out.println("invoke " + name);
}
------
would expose an "invoke" operation and "name" as an read/write attribute.
In some ways, this would make creating MBeans very quick and easy to do. It would also lower the barrier to most people, who think that making an MBean is a lot of repetitive work or requires tools such as xdoclet to be efficient.
Something else that comes to mind is doing something like:
<server>
<mbean name="example:service=Test">
<depends> ...
<code language="bsh">
String name = "joe";
void invoke() {
System.out.println("invoke " + name);
}
</code>
</mbean>
The "language" tag sort of enables the potential for other scripts, such as Groovy or JScript.