20080913, rgf

org.rexxla.bsf.engines.rexx
Class RexxEngine

java.lang.Object
  extended byorg.apache.bsf.util.BSFEngineImpl
      extended byorg.rexxla.bsf.engines.rexx.RexxEngine
All Implemented Interfaces:
org.apache.bsf.BSFEngine, java.util.EventListener, java.beans.PropertyChangeListener

public class RexxEngine
extends org.apache.bsf.util.BSFEngineImpl

This class manages the calls from Java via JNI to Rexx or Object Rexx using the RexxSAA interface.

------------------------ Apache Version 2.0 license -------------------------
    Copyright (C) 2001-2008 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.
 ----------------------------------------------------------------------------- 

Version:
2.12, 2008-08-14
Author:
Rony G. Flatscher (WU-Wien/Wirtschaftsuniversität Wien, http://www.wu-wien.ac.at/english)

Field Summary
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.
 
Fields inherited from class org.apache.bsf.util.BSFEngineImpl
classLoader, classPath, declaredBeans, lang, mgr, tempDir
 
Constructor Summary
RexxEngine()
           
 
Method Summary
 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)
          Deprecated. " This call(...) method may be enhanced in the future, once an openly defined and available interface to the OO-part of Object Rexx is made available by IBM. Then the argument "object" would denote an Object Rexx object, the argument "name" the name of one of its methods and the argument "args" the arguments for the method.
If possible at all, use method apply(...) instead.
 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.
protected  RexxAndJava getRexxInterface()
           
 boolean getThreadedRexxStart()
          Getter method for retrieving the actual setting.
 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 isThreadedRexxStart()
          Getter method for retrieving the actual setting.
 void setThreadedRexxStart(boolean newVal)
          Allows to control on which Java thread the Rexx interpreter is executed.
 void undeclareBean(org.apache.bsf.BSFDeclaredBean bean)
          Method implemented in order to avoid an exeption to be thrown by the default implementation.
 
Methods inherited from class org.apache.bsf.util.BSFEngineImpl
compileApply, compileExpr, compileScript, exec, iexec, propertyChange, terminate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final 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.

See Also:
Constant Field Values
Constructor Detail

RexxEngine

public RexxEngine()
Method Detail

getRexxInterface

protected RexxAndJava getRexxInterface()

initialize

public void initialize(org.apache.bsf.BSFManager mgr,
                       java.lang.String lang,
                       java.util.Vector declaredBeans)
                throws org.apache.bsf.BSFException
Initializes the Rexx engine and causes the external functions 'BSF' and 'BSFPollEvents' to be registered with the Rexx interpreter. Therefore Rexx programs invoked from Java have these two functions available to them and are therefore able to communicate with Java.

Throws:
org.apache.bsf.BSFException

eval

public java.lang.Object eval(java.lang.String source,
                             int lineNo,
                             int columnNo,
                             java.lang.Object oscript)
                      throws org.apache.bsf.BSFException
Evaluates (executes) a piece of Rexx code (can be a whole program as well) without any Java-supplied arguments and returns the result.

Parameters:
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).
Returns:
a String object with the result from Rexx or null.
Throws:
org.apache.bsf.BSFException

call

public java.lang.Object call(java.lang.Object object,
                             java.lang.String name,
                             java.lang.Object[] args)
                      throws org.apache.bsf.BSFException
Deprecated. " This call(...) method may be enhanced in the future, once an openly defined and available interface to the OO-part of Object Rexx is made available by IBM. Then the argument "object" would denote an Object Rexx object, the argument "name" the name of one of its methods and the argument "args" the arguments for the method.
If possible at all, use method apply(...) instead.

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.

[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.]

Parameters:
object - not used.
name - not used.
args - arguments to be passed to Rexx.
Returns:
a String object with the result from Rexx or null.
Throws:
org.apache.bsf.BSFException

apply

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
Applies (evaluates) a piece of Rexx code (can be a whole program as well) with Java-supplied arguments and returns the result.

Parameters:
source - name of source containing the script (e.g. fully qualified file name) or null
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 an LF (line-feed, "0x0a"), preceeded by an optional CR (carriage-return, "0x0d").
vArgNames - not used.
vArgs - arguments to be passed to Rexx.
Returns:
a String object with the result from Rexx or null.
Throws:
org.apache.bsf.BSFException

declareBean

public void declareBean(org.apache.bsf.BSFDeclaredBean bean)
                 throws org.apache.bsf.BSFException
Method implemented in order to avoid an exeption to be thrown by the default implementation.

Parameters:
bean - the bean to be declared for the already started language.
Throws:
org.apache.bsf.BSFException

undeclareBean

public void undeclareBean(org.apache.bsf.BSFDeclaredBean bean)
                   throws org.apache.bsf.BSFException
Method implemented in order to avoid an exeption to be thrown by the default implementation.

Parameters:
bean - the bean to be declared for the already started language.
Throws:
org.apache.bsf.BSFException

setThreadedRexxStart

public void setThreadedRexxStart(boolean newVal)
Allows to control on which Java thread the Rexx interpreter is executed.

Parameters:
newVal - if false (default) the Rexx interpreter will be invoked in the current Java thread, if true, then the Rexx interpreter will be invoked via a separate Java thread

getThreadedRexxStart

public boolean getThreadedRexxStart()
Getter method for retrieving the actual setting. Cf. setThreadedRexxStart(boolean newVal).


isThreadedRexxStart

public boolean isThreadedRexxStart()
Getter method for retrieving the actual setting. Cf. setThreadedRexxStart(boolean newVal).


20080913, rgf