|
|||||||||
| Home >> All >> org >> apache >> bsf >> engines >> [ netrexx overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.bsf.engines.netrexx
Class NetRexxEngine

java.lang.Objectorg.apache.bsf.util.BSFEngineImpl
org.apache.bsf.engines.netrexx.NetRexxEngine
- All Implemented Interfaces:
- org.apache.bsf.BSFEngine, java.util.EventListener, java.beans.PropertyChangeListener
- public class NetRexxEngine
- extends org.apache.bsf.util.BSFEngineImpl
This is the interface to NetRexx from the Bean Scripting Framework.
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".
Hazards:
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.
| Nested Class Summary | |
private class |
NetRexxEngine.GeneratedFile
|
| Field Summary | |
private boolean |
bsfHandleCreated
|
(package private) static java.util.Hashtable |
codeToClass
|
(package private) org.apache.bsf.util.BSFFunctions |
mgrfuncs
|
(package private) java.lang.String |
minorPrefix
|
(package private) static java.lang.String |
placeholder
|
(package private) static java.lang.String |
serializeCompilation
|
private static int |
uniqueFileOffset
Create a scratchfile, open it for writing, return its name. |
| Fields inherited from class org.apache.bsf.util.BSFEngineImpl |
classLoader, classPath, dbgmgr, declaredBeans, lang, mgr, tempDir |
| Constructor Summary | |
NetRexxEngine()
Constructor. |
|
| Method Summary | |
java.lang.Object |
call(java.lang.Object object,
java.lang.String method,
java.lang.Object[] args)
Return an object from an extension. |
(package private) java.lang.Object |
callStatic(java.lang.Class rexxclass,
java.lang.String method,
java.lang.Object[] args)
Invoke a static method. |
void |
declareBean(org.apache.bsf.BSFDeclaredBean bean)
Declare a bean after the engine has been started. |
java.lang.Object |
eval(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object script)
Override impl of execute. |
void |
exec(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object script)
Override impl of execute. |
java.lang.Object |
execEvalShared(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object oscript,
boolean returnsObject)
This is shared code for the exec() and eval() operations. |
void |
initialize(org.apache.bsf.BSFManager mgr,
java.lang.String lang,
java.util.Vector declaredBeans)
initialize the engine; called right after construction by the manager. |
private NetRexxEngine.GeneratedFile |
openUniqueFile(java.lang.String directory,
java.lang.String prefix,
java.lang.String suffix)
|
void |
undeclareBean(org.apache.bsf.BSFDeclaredBean bean)
Undeclare a previously declared bean. |
| Methods inherited from class org.apache.bsf.util.BSFEngineImpl |
apply, compileApply, compileExpr, compileScript, disconnectedDebuggerNotify, getSpecificDebuggingInterface, placeBreakpointAtLine, placeBreakpointAtOffset, propertyChange, removeBreakpoint, setEntryExit, terminate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
mgrfuncs
org.apache.bsf.util.BSFFunctions mgrfuncs
bsfHandleCreated
private boolean bsfHandleCreated
codeToClass
static java.util.Hashtable codeToClass
serializeCompilation
static java.lang.String serializeCompilation
placeholder
static java.lang.String placeholder
minorPrefix
java.lang.String minorPrefix
uniqueFileOffset
private static int uniqueFileOffset
- Create a scratchfile, open it for writing, return its name.
Relies on the filesystem to provide us with uniqueness testing.
NOTE THAT uniqueFileOffset continues to count; we don't want to
risk reusing a classname we have previously loaded in this session
even if the classfile has been deleted.
I've made the offset static, due to concerns about reuse/reentrancy
of the NetRexx engine.
| Constructor Detail |
NetRexxEngine
public NetRexxEngine()
- Constructor.
| Method Detail |
call
public java.lang.Object call(java.lang.Object object, java.lang.String method, java.lang.Object[] args) throws org.apache.bsf.BSFException
- Return an object from an extension.
callStatic
java.lang.Object callStatic(java.lang.Class rexxclass, java.lang.String method, java.lang.Object[] args) throws org.apache.bsf.BSFException
- Invoke a static method.
declareBean
public void declareBean(org.apache.bsf.BSFDeclaredBean bean) throws org.apache.bsf.BSFException
- Description copied from interface:
org.apache.bsf.BSFEngine - Declare a bean after the engine has been started. Declared beans
are beans that are named and which the engine must make available
to the scripts it runs in the most first class way possible.
eval
public java.lang.Object eval(java.lang.String source, int lineNo, int columnNo, java.lang.Object script) throws org.apache.bsf.BSFException
- Override impl of execute. In NetRexx, methods which do not wish
to return a value should be invoked via exec, which will cause them
to be generated without the "returns" clause.
Those which wish to return a value should call eval instead.
which will add "returns java.lang.Object" to the header.
Note: It would be nice to have the "real" return type avaialable, so
we could do something more type-safe than Object, and so we could
return primitive types without having to enclose them in their
object wrappers. BSF does not currently support that concept.
exec
public void exec(java.lang.String source, int lineNo, int columnNo, java.lang.Object script) throws org.apache.bsf.BSFException
- Override impl of execute. In NetRexx, methods which do not wish
to return a value should be invoked via exec, which will cause them
to be generated without the "returns" clause.
Those which wish to return a value should call eval instead.
which will add "returns java.lang.Object" to the header.
execEvalShared
public java.lang.Object execEvalShared(java.lang.String source, int lineNo, int columnNo, java.lang.Object oscript, boolean returnsObject) throws org.apache.bsf.BSFException
- This is shared code for the exec() and eval() operations. It will
evaluate a string containing a NetRexx method body -- which may be
as simple as a single return statement.
It should store the "bsf" handle where the
script can get to it, for callback purposes.
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.
initialize
public void initialize(org.apache.bsf.BSFManager mgr, java.lang.String lang, java.util.Vector declaredBeans) throws org.apache.bsf.BSFException
- Description copied from class:
org.apache.bsf.util.BSFEngineImpl - initialize the engine; called right after construction by
the manager. Declared beans are simply kept in a vector and
that's it. Subclasses must do whatever they want with it.
openUniqueFile
private NetRexxEngine.GeneratedFile openUniqueFile(java.lang.String directory, java.lang.String prefix, java.lang.String suffix)
undeclareBean
public void undeclareBean(org.apache.bsf.BSFDeclaredBean bean) throws org.apache.bsf.BSFException
- Description copied from interface:
org.apache.bsf.BSFEngine - Undeclare a previously declared bean.
|
|||||||||
| Home >> All >> org >> apache >> bsf >> engines >> [ netrexx overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC