public class RexxEngine
extends org.apache.bsf.util.BSFEngineImpl
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2001-2016 Rony G. Flatscher Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------
Modifier and Type | Field and Description |
---|---|
protected boolean |
bJNITerminated
Will be set to true, if terminate() used JNI to successfully terminate the Rexx interpreter
instance.
|
protected boolean |
bTerminated
If terminate() was invoked, then this instance must not be used anymore.
|
static java.lang.String |
version
Version string indicating version of this class (majorVersion*100+minorVersion
concatenated with a dot and the sorted date of last change.
|
Constructor and Description |
---|
RexxEngine() |
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
apply(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object oscript,
java.util.Vector vArgNames,
java.util.Vector vArgs)
Applies (evaluates) a piece of Rexx code
(can be a whole program as well)
with Java-supplied arguments and returns the result.
|
java.lang.Object |
call(java.lang.Object object,
java.lang.String name,
java.lang.Object[] args)
Calls (executes) a Rexx program which code has been supplied before via an invocation of
"apply()",
"exec()" or "eval()" with the Java-supplied arguments and returns
the result.
|
java.lang.Object |
call(RexxProxy proxy,
java.lang.reflect.Method methodObject,
java.lang.Object[] args)
Allows forwarding a messages to a RexxProxy using the method name of the supplied
methodObject object with the supplied arguments , if any. |
java.lang.Object |
call(RexxProxy proxy,
java.lang.Object javaObject,
java.lang.String methodName,
java.lang.String methodDescriptor,
java.lang.Object[] args)
Allows forwarding a messages to a RexxProxy using the supplied
methodName
the supplied arguments , if any. |
void |
declareBean(org.apache.bsf.BSFDeclaredBean bean)
Method implemented in order to avoid an exeption to be thrown by the
default implementation.
|
java.lang.Object |
eval(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object oscript)
Evaluates (executes) a piece of Rexx code
(can be a whole program as well)
without any Java-supplied arguments and returns the result.
|
java.lang.String |
get_rii_ID()
Getter method.
|
java.lang.Object |
getGlobalEnvironment()
Get the ooRexx
.environment directory. |
long |
getInterpreterVersion()
(Copied from the ooRexx
rexxpg.pdf documentation) "Returns
the version of the interpreter. |
long |
getLanguageLevel()
(Copied from the ooRexx
rexxpg.pdf documentation) "Returns the language level of
the interpreter. |
java.lang.Object |
getLocalEnvironment()
Get the ooRexx
.local directory. |
java.lang.Object |
getNil()
Get the ooRexx
.nil object. |
RexxConfiguration |
getRexxConfiguration()
Getter method.
|
RexxAndJava |
getRexxInterface()
Returns the
RexxAndJava instance that is used for interfacing with Rexx. |
void |
halt()
Halt (raise the
HALT condition) all Rexx threads of this engine's peer
Rexx interperter instance (using the new ooRExx 4.0 APIs). |
int |
halt(java.lang.String tid)
Allow halting an individual Rexx thread (raising the
HALT condition) having
the given thread ID. |
void |
initialize(org.apache.bsf.BSFManager mgr,
java.lang.String lang,
java.util.Vector declaredBeans)
Initializes the Rexx engine and causes the external
functions 'BSF' and 'BSFPollEvents' to be registered with the
Rexx interpreter.
|
boolean |
isTerminated()
Getter method for field
bTerminated . |
java.lang.Object |
lookupBean(java.lang.String beanName)
Allow lookup of BSFRegistry entries.
|
java.lang.String |
procEnvironment(int t,
java.lang.String n,
java.lang.String v) |
java.lang.String |
registerBean(java.lang.Object object)
This method registers an object with the given beanName
that gets created automatically in the BSF registry, if not registered yet.
|
java.lang.String |
registerBean(java.lang.String beanName,
java.lang.Object object)
This method registers an object with the given beanName with
the BSF registry, if not registered yet.
|
protected void |
set_rii_ID(java.lang.String rii_ID)
Setter method.
|
void |
terminate()
Waits until all Rexx threads of this engine's Rexx interpreter instance peer have terminated
(using the new ooRExx 4.0 APIs); this method must be called from the same thread
that created the Rexx interpreter instance (i.e.
|
void |
undeclareBean(org.apache.bsf.BSFDeclaredBean bean)
Method implemented in order to avoid an exeption to be thrown by the
default implementation.
|
boolean |
unregisterBean(java.lang.String beanName)
This method allows for unregistering Beans, taking into account reference counters.
|
public static final java.lang.String version
protected boolean bTerminated
protected boolean bJNITerminated
public boolean isTerminated()
bTerminated
.true
, if Rexx engine got successfully terminated, false
public java.lang.String get_rii_ID()
protected void set_rii_ID(java.lang.String rii_ID)
public RexxConfiguration getRexxConfiguration()
public RexxAndJava getRexxInterface()
RexxAndJava
instance that is used for interfacing with Rexx.public void initialize(org.apache.bsf.BSFManager mgr, java.lang.String lang, java.util.Vector declaredBeans) throws org.apache.bsf.BSFException
initialize
in interface org.apache.bsf.BSFEngine
initialize
in class org.apache.bsf.util.BSFEngineImpl
mgr
- The BSFManager that's hosting this engine.lang
- Language string which this engine is handling.declaredBeans
- Vector of BSFDeclaredObject containing beans
that should be declared into the language runtime at init
time as best as possible.org.apache.bsf.BSFException
- if anything goes wrong while init'ing a
BSFException is thrown. The reason indicates the problem.public java.lang.Object getLocalEnvironment()
.local
directory.RexxProxy
allowing access to the ooRexx .local
directorypublic java.lang.Object getGlobalEnvironment()
.environment
directory.RexxProxy
allowing access to the ooRexx .environment
directorypublic java.lang.Object getNil()
.nil
object.RexxProxy
representint the ooRexx .nil
sentinel objectpublic long getInterpreterVersion()
rexxpg.pdf
documentation) "Returns
the version of the interpreter. The returned version is
encoded in the 3 least significant bytes of the returned value,
using 1 byte each for the interpreter version, release, and revision
values. For example, on a 32-bit platform, this value would be
0x00040000
for version 4.0.0."public long getLanguageLevel()
rexxpg.pdf
documentation) "Returns the language level of
the interpreter. The returned language level is encoded in the 2 least
significant bytes of the returned value, using 1 byte each for the
interpreter version, release, and revision values. For example, on a 32-bit
platform, this value would be 0x00000603
for language level 6.03."public java.lang.Object eval(java.lang.String source, int lineNo, int columnNo, java.lang.Object oscript) throws org.apache.bsf.BSFException
source
- if set to RexxAndJava.EVENT_TEXT
,
then oscript
is put into the event queue
to be polled by Rexx. If this text starts with the
string "/*2*/"
it is
put into the alarm (highest dispatch) level vector, if it starts with the
string "/*0*/"
it is
put into the batch (lowest dispatch) level vector,
else it is put into the normal level vector.lineNo
- not used.columnNo
- not used.oscript
- the String version of this object [using toString()]
represents the Rexx code to be executed.
Its statements are delimited with a ';' or a
CR (carriage-return) and/or LF (line-feed).null
.org.apache.bsf.BSFException
- if anything goes wrong while eval'ing a
BSFException is thrown. The reason indicates the problem.public java.lang.Object call(java.lang.Object object, java.lang.String name, java.lang.Object[] args) throws org.apache.bsf.BSFException
[Hint: This follows after learning how Xalan is employing BSF: it first calls "exec()" and then "call()", hence "call()" does not receive the source to be executed.]
As of 2009-05-17 using the new ooRexx 4.0 APIs the following fundamental change has
been implemented: if the argument Note: if the RexxProxy's object
is an instance of RexxProxy
,
then a callback on the RexxProxy object is carried out, using method as the
ooRexx message name, supplying arguments, if any. Otherwise, the original behaviour takes place.
userDataID
field is not set (i.e. null
),
then no slot argument will be supplied as the last argument to the Rexx method.
object
- if an instance of RexxProxy, then a callback is carried outname
- if given, name of the message to send to the ooRexx objectargs
- arguments to be passed to Rexx, if anynull
.org.apache.bsf.BSFException
- if anything goes wrong while eval'ing a
BSFException is thrown. The reason indicates the problem.public java.lang.Object call(RexxProxy proxy, java.lang.reflect.Method methodObject, java.lang.Object[] args) throws org.apache.bsf.BSFException
methodObject
object with the supplied arguments
, if any. This
method will be mostlikely invoked employing a Proxy
object.
As of 2009-05-17 using the new ooRexx 4.0 APIs the following fundamental change has
been implemented: if the argument object
is an instance of RexxProxy
,
then a callback on the RexxProxy object is carried out, using method as the
ooRexx message name, supplying arguments, if any. Otherwise, the original behaviour takes place.
proxy
- a RexxProxy to which the callback is to be carried outmethodObject
- the java.lang.reflect.Method object that is supposed to be invoked originallyargs
- arguments to be passed to Rexx, if anynull
.org.apache.bsf.BSFException
public java.lang.Object call(RexxProxy proxy, java.lang.Object javaObject, java.lang.String methodName, java.lang.String methodDescriptor, java.lang.Object[] args) throws org.apache.bsf.BSFException
methodName
the supplied arguments
, if any. This method will be mostlikely invoked
employing a RexxProxy object in the context of a dynamically created (proxy) Java class
(e.g. an abstract class, where the abstract methods will forward their invocation to the
RexxProxy object).proxy
- a RexxProxy to which the callback is to be carried outjavaObject
- object that invoked this callbackmethodName
- this name is used as the message to be sent to the Rexx objectmethodDescriptor
- the Java internal representation of the method's arguments and
return type, if anyargs
- arguments to be passed to Rexx, if anynull
.org.apache.bsf.BSFException
public java.lang.Object apply(java.lang.String source, int lineNo, int columnNo, java.lang.Object oscript, java.util.Vector vArgNames, java.util.Vector vArgs) throws org.apache.bsf.BSFException
apply
in interface org.apache.bsf.BSFEngine
apply
in class org.apache.bsf.util.BSFEngineImpl
source
- name of source containing the script (e.g. fully qualified file name) or nulllineNo
- not used.columnNo
- not used.oscript
- the String version of this object [using toString()]
represents the Rexx code to be executed.
Its statements are delimited with a ';' or a
an LF (line-feed, "0x0a"), preceeded by an
optional CR (carriage-return, "0x0d").vArgNames
- not used.vArgs
- arguments to be passed to Rexx.null
.org.apache.bsf.BSFException
- if anything goes wrong while doin' it.public void declareBean(org.apache.bsf.BSFDeclaredBean bean) throws org.apache.bsf.BSFException
declareBean
in interface org.apache.bsf.BSFEngine
declareBean
in class org.apache.bsf.util.BSFEngineImpl
bean
- the bean to be declared for the already started language.org.apache.bsf.BSFException
- if the engine cannot do this operationpublic void undeclareBean(org.apache.bsf.BSFDeclaredBean bean) throws org.apache.bsf.BSFException
undeclareBean
in interface org.apache.bsf.BSFEngine
undeclareBean
in class org.apache.bsf.util.BSFEngineImpl
bean
- the bean to be declared for the already started language.org.apache.bsf.BSFException
- if the engine cannot do this operationpublic void terminate()
boolean isTerminated()
to test whether the Rexx interpreter instance of
this RexxEngine
got terminated.
To halt all Rexx threads of this engine's Rexx interpreter instance peer use
halt()
.terminate
in interface org.apache.bsf.BSFEngine
terminate
in class org.apache.bsf.util.BSFEngineImpl
public void halt() throws RexxException
HALT
condition) all Rexx threads of this engine's peer
Rexx interperter instance (using the new ooRExx 4.0 APIs).RexxException
public int halt(java.lang.String tid)
HALT
condition) having
the given thread ID.tid
- a string with the target thread ID, or
the string "0"
(raises the HALT
condition
in all ooRexx threads)RexxSetHalt(...)
: 0 (o.k.),
1
(tid not found), or 2
(failure), or
3
(Rexx interpreter instance was not yet created)
public java.lang.String registerBean(java.lang.Object object) throws RexxException
object
- to be registeredRexxException
public java.lang.String registerBean(java.lang.String beanName, java.lang.Object object) throws RexxException
beanName
- name of the object to be registeredobject
- to be registeredRexxException
public boolean unregisterBean(java.lang.String beanName) throws RexxException
beanName
- name of the Bean to be unregisteredtrue
, if the Bean exists, false
else.RexxException
public java.lang.Object lookupBean(java.lang.String beanName) throws RexxException
beanName
- string denoting the index into the BSFRegistrybeanName
, if not found in BSF registry returns null
RexxException
public java.lang.String procEnvironment(int t, java.lang.String n, java.lang.String v) throws RexxException
RexxException