> In the JDK 6's script supporting API, I can bind beans into a specific > ScriptContext, then evaluate the script code insed that context. By doing > this, I can bind different bean objects for different scripts using the same > name. Can I do the similar thing using BSF? > Yes, this should be possible with the ObjectRegistry, something like:
* create an ObjectRegistry object, register the beans that you want to share among different scripts with it, o while creating an ObjectRegistry you could also supply an existing ObjectRegistry possessing the registered objects to the constructor. That passed ObjectRegistry object will serve as a "parent" which is looked up, if the new ObjectRegistry does not have the sought entry, serving as a fall-back registry. * set the BSFManager's ObjectRegistry using setObjectRegistry(). Also, you could get the ObjectRegistry object from a BSFManager with getObjectRegistry() and supply it to a different instance of BSFManager, in the case that scripts created entries there which should be referred to in other scripts. Just try it out. HTH, ---rony