Jelly Folks,
Looks like theres alot of activity on the list with the "Big Move".
I've made considerable progress on the BCEL taglibrary and the use of
BSF to create enterpreted methods.
For example:
<bcel:class name="org.mrd.test.Test3" extends="java.lang.Object">
<bcel:method name="testMethod" returns="int" test1="int" test2="int"
language="javascript">
test1+test2;
</bcel:method>
</bcel:class>
<new var="testExample3" className="org.mrd.test.Test3"/>
Returns: ${testExample3.testMethod(1,2)}
It uses the BCEL libraries to generate a BSF framework in the generated
class that can eval the content of the method. It also generates a "BSF
ObjectRegistery" specific to that class that defines the arguments of
the generated method: The resulting code of the generated method is
comparable to:
public class Test3{
protected BSFManager manager = null;
protected ObjectRegistry registry = null;
public Test()throws BSFException{
manager = new BSFManager();
manager.declareBean("this",this, this.getClass());
registry = manager.getObjectRegistry();
}
//evalutes script
public int testMethod(int test1, int test2) throws BSFException{
//local method registry
ObjectRegistry local = new ObjectRegistry(registry);
manager.setObjectRegistry(local);
manager.declareBean("test1", new Integer(test1),int.class);
manager.declareBean("test2", new Integer(test2),int.class);
BSFEngine engine = manager.loadScriptingEngine("javascript");
Object o = engine.eval(
"my_generated_method",0, 0, "test1+test2;");
manager.setObjectRegistry(registry);
return o;
}
}
I am rather buisy lately, but I'd like to see this possibly start to get
into other developers hands as well.
If this taglibrary were added to the commons-jelly taglibraries, would
it be possible for me to gain commit rights to its branch? Otherwise, in
donating it, I'd also loose my current control over its development
direction, which is something I'd like to stay in-touch with. I have a
couple more Ideas I'd like to integrate into it
1.) BSF script precompiling in class generation as an optimization of
runtime method calling.
2.) access to local bean properties from script (this.getN/setN,n,
super.), specifically access to "this" instance of the class somehow
from within the script in an intuitive way (ie: "this" and "super" seem
to be researved words in Rhino/BSF.
thanks,
Mark
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]