jakarta-bsf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject BSF and defining primitive types.
Date Thu, 30 Jan 2003 00:50:07 GMT
I'm currently working on a taglibrary for Jelly that does two things

1.) Allows one to "Build" new Classes using BCEL. This supports creation 
of new "properties" with getters and/or setters. I handle this entirely 
with the BCEL library.

2.) Support for creating new "methods" that use BSF as a mechanism to 
exec scripts defining the actions/behaviors of those new methods. (See 
my privious thread in the Jelly list).

http://www.mail-archive.com/commons-user@jakarta.apache.org/msg01591.html

and on the BCEL list:

http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg15546.html


My questions concern issue to do with "primitives" and appropriate 
behavior in BSF..

I'm generating methods that look something like this (simplified):

public Object myMethod(int foo, java.lang.Double bar )
throws com.ibm.bsf.BSFException{

         manager.declareBean("foo", new Integer(foo), Integer.class);
         manager.declareBean("bar", bar, bar.getClass());

         BSFEngine engine = manager.loadScriptingEngine("javascript");

         return engine.eval("my_class.my_generated_method",0, 0, 
"foo+bar;");

}

from jelly script that looks something like:

<bcel:class name="Foo">
	<bcel:property name="hello" type="java.lang.String"/>
	<bcel:method>
		<bcel:arg name="foo" type="int"/>
		<bcel:arg name="bar" type="java.lang.Double/>
		<bcel:body engine="bsf" language="javascript">
			foo + bar;
		</bcel:body>
	</bcel:method>
</bcel:class>

My question concerns appropriate issues with registering primitives, 
you'll notice I'm using:

manager.declareBean("foo", new Integer(foo), Integer.class);

my concern is that this wrapping should still allow:

"foo+bar"

to function properly

I'm wondering if my approach is best concerning the design of 
BSFEngine/Manager and it behavior with such objects? I notice no clearly 
defined methods for registering primitives.

Should I define it the "Integer.class" as its defined class or 
"int.class" as its defined class? I'm assuming Integer.class, but it 
unclear to me if BSF has any "unwrapping" going on internally.

-thanks,
Mark Diggory






Mime
View raw message