org.apache.bsf.engines.netrexx
public class NetRexxEngine extends BSFEngineImpl
The NetRexx code must be written script-style, without a "class" or "properties" section preceeding the executable code. The NetRexxEngine will generate a prefix for this code:
class $$CLASSNAME$$;
method BSFNetRexxEngineEntry(bsf=org.apache.bsf.BSFManager) public static;
$$CLASSNAME$$ will be replaced by a generated classname of the form
BSFNetRexx*, and the bsf parameter can be used to retrieve application
objects registered with the Bean Scripting Framework.
If you use the placeholder string $$CLASSNAME$$ elsewhere in your script -- including within text strings -- BSFNetRexxEngine will replace it with the generated name of the class before the NetRexx code is compiled.
If you need to use full NetRexx functionality, we recommend that your NetRexx script define and invoke a "minor class", with or without the "dependent" keyword as suits your needs. You'll have to use $$CLASSNAME$$ in naming the minor class, since the name of the main class is synthesized; for example, to create the minor class "bar" you'd write "class $$CLASSNAME$$.Bar".
Since NetRexx has to be _compiled_ to a Java classfile, invoking it involves a fair amount of computation to load and execute the compiler. We are currently making an attempt to manage that by caching the class after it has been loaded, but the indexing is fairly primitive; we hash against the script string to find the class for it.
Minor-class .class files are now being deleted after the major class loads. This coould potentially cause problems.
Constructor Summary | |
---|---|
NetRexxEngine()
Constructor. |
Method Summary | |
---|---|
Object | call(Object object, String method, Object[] args)
Return an object from an extension. |
void | declareBean(BSFDeclaredBean bean) |
Object | eval(String source, int lineNo, int columnNo, Object script)
Override impl of execute. |
void | exec(String source, int lineNo, int columnNo, Object script)
Override impl of execute. |
Object | execEvalShared(String source, int lineNo, int columnNo, Object oscript, boolean returnsObject)
This is shared code for the exec() and eval() operations. |
void | initialize(BSFManager mgr, String lang, Vector declaredBeans) |
void | undeclareBean(BSFDeclaredBean bean) |
Parameters: Object object from which to call our static method method The name of the method to call. args an array of arguments to be passed to the extension, which may be either Vectors of Nodes, or Strings.
Note that NetRexx compilation imposes serious overhead -- 11 seconds for the first compile, about 3 thereafter -- but in exchange you get Java-like speeds once the classes have been created (minus the cache lookup cost).
Nobody knows whether javac is threadsafe. I'm going to serialize access to the compilers to protect it.