Hi Di Li, Di Li wrote: > I want to use Jython and JRuby with BSF. And I need to set up dynamic > variables for scripts? For example, in BeanShell, we can do it using > "interpreter.set(String, Object)", which is the same as in Jython. And in > JRuby, we can use "DynamicVariable.set(String, IRubyOjbect)". > > Is there any way to do the same thing in BSF? > hmm, not being acquainted with the Jython and JRuby implementations myself, maybe some comments that might help you:
* Java programs may register "beans" which are stored in the BSFRegistry using a String as an index; the BSF engines usually supply a funtion/method to look up such beans, if you supply the index name (for Jython you will find BSF samples; if you can come up with small samples for JRuby, please consider to make them available, such that we can add them to the BSF samples) o You can look up the source of these BSF engines for Jython (part of the BSF distribution <org/apache/bsf/engines/jython>) and JRuby (should be available via their homepage) * Usually Java implemented languages have means "on board" that allow setting/retrieving variable values the way you are seeking. o Should you want to add missing functionality, then you would probably want to make it available via the respective BSF engines (at least you need to retrieve the interpreter instance you will be using via BSF). HTH (and good luck!), ---rony