Paul Landes | 3 Jan 2010 06:19

Re: Running Scripted Command in separate namespaces?

Beanshell isn't supported by the original author any longer and there  
isn't any "official" maintainer any more.  I do believe there is a  
repository that has various patches people have applied over time  
though.

That said, I think the latest (2.04b) does what you need.  When  
scripted methods are defined in the global namespace, yes, you're  
correct.  However, you can also define nested scripted methods:

bsh.XThis foo() {
   print(this.namespace);
   bsh.XThis bar()
     print(this.namespace);
   }
   return this;
}
foo().bar();

Or you can run the scripted method in the namespace of your choosing,  
in this case the caller's namespace:

Object eval( String expression ) {
     return this.interpreter.eval( expression, this.caller.namespace );
}

This example is actually the implementation of the "eval()" command.

On Dec 30, 2009, at 2:36 PM, keith preston wrote:

> I've noticed that all scriptedCommands are executed in the Global
(Continue reading)


Gmane