|
20070921, rgf | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.rexxla.bsf.engines.rexx.RexxAndJava
This class manages the calls from Rexx or Object Rexx into Java. (Any scripting language being able to pass Strings to and from Java will be able to use this interface, making it really easy to interface with Java.)
------------------------ Apache Version 2.0 license ------------------------- Copyright (C) 2001-2007 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. -----------------------------------------------------------------------------
Nested Class Summary | |
(package private) class |
RexxAndJava.ExitDelayed
Class to exit the JVM, will be executed concurrently, sleeps and then calls System.exit(exit_number) . |
protected class |
RexxAndJava.SyncPutGet
Inner class to implement a Synchronized ReaderWriter, where a read on an empty Vector blocks the read, until a write occurs (with optional timeout). |
Field Summary | |
(package private) static boolean |
bMethodHasSetAccessible
true if setting accessibility rights is available, false else. |
protected static java.lang.String |
DLL_NAME
Defines the name of DLL to be used to resolve the native functions. |
protected static java.lang.String |
EVENT_LISTENER_ARGUMENTS_LEADIN
Defines the string that leads in the BSFRegistry key to the Object array containing the event object and additional information. |
protected static java.lang.String |
EVENT_LISTENER_ARGUMENTS_LEADOUT
Defines the string that leads out the BSFRegistry key to the Object array containing the event object and additional information. |
protected static java.lang.String |
EVENT_TEXT
Defines the string to indicate an 'eventText' is passed in: "<eventText>". |
protected RexxAndJava.SyncPutGet |
eventTextList
Allows Synchronized access to the vector storing the text sent by the eventListeners. |
(package private) org.apache.bsf.util.type.TypeConvertorRegistry |
glob_tcr
To store the default TypeConvertorRegistry, if needed. |
(package private) java.util.Hashtable |
methodReferences
Allows storing successfully reflected methods. |
(package private) org.apache.bsf.BSFManager |
mgr
Stores the BSF manager. |
protected static java.lang.Class |
nlR_class
Stores the "netrexx.lang.Rexx" class object, if available. |
protected static java.lang.String |
null4Rexx
Defines the string which represents null , by default
".NIL" . |
(package private) java.util.Hashtable |
orxReferences
Stores the number of references from Object Rexx to Java objects using beanName as the key. |
(package private) org.apache.bsf.BSFEngine |
rexxEngine
Stores the Rexx engine. |
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 Summary | |
(package private) |
RexxAndJava(org.apache.bsf.BSFManager mgr,
org.apache.bsf.BSFEngine rengine)
Constructor to receive and store the BSF manager and the Rexx engine. |
Method Summary | |
(package private) java.lang.Object[] |
coerceArgs(java.lang.Object[] funcArgs,
java.lang.Class[] paramTypes)
Coerces the arguments from Rexx to the appropriate Java types. |
(package private) java.lang.Object |
invokeMethod(java.lang.reflect.Method m,
java.lang.Object o,
java.lang.Object[] params)
Invokes method and makes sure that any public method will get successfully invoked. |
java.lang.String |
javaCallBSF(java.lang.String[] args)
Entry point for Rexx calls into Java. |
int |
jniInitialize4Rexx()
rgf, 2003-01-15, used for allowing the BSF4Rexx-DLL to get at *env, *obj and then to mid etc. |
int |
jniRegisterBSF()
This native method makes sure that the function 'BSF' is registered with Rexx, making it thereby available to all Rexx and Object Rexx programs, called from Java. |
int |
jniRexxDidRexxTerminate()
Deprecated. This native method indicates whether the Object Rexx interpreter is still running or not. |
java.lang.String |
jniRexxStart(java.lang.String script,
java.lang.String[] args)
This native method Calls the Rexx interpreter, having it execute the passed in script with the given array of arguments. |
int |
jniRexxWaitForTermination()
Deprecated. This native method waits for the Object Rexx interpreter to terminate and waits until all of the cleanup (e.g. of Object Rexx) is done. |
java.lang.String |
makeBeanName(java.lang.Object o)
This method creates a unique string value for the passed in object. |
protected java.lang.String |
makeString4Rexx(java.lang.Object o)
This method determines what String content to return. |
(package private) java.lang.String |
pp(java.lang.Object o)
'Pretty print': returns string value of supplied object enclosed in square brackets. |
protected boolean |
unregisterBean(java.lang.String beanName)
This method allows for unregistering Beans, taking into account reference counters. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static java.lang.String version
protected static final java.lang.String DLL_NAME
protected static final java.lang.String EVENT_TEXT
protected static final java.lang.String EVENT_LISTENER_ARGUMENTS_LEADIN
protected static final java.lang.String EVENT_LISTENER_ARGUMENTS_LEADOUT
protected static java.lang.String null4Rexx
null
, by default
".NIL"
. Arguments given by Rexx can in addition
be indicated to be null
by merely omitting them on the Rexx side.
protected RexxAndJava.SyncPutGet eventTextList
static boolean bMethodHasSetAccessible
true
if setting accessibility rights is available, false
else.
protected static java.lang.Class nlR_class
org.apache.bsf.BSFManager mgr
org.apache.bsf.BSFEngine rexxEngine
java.util.Hashtable orxReferences
beanName
as the key. This way it becomes possible for the
Object Rexx implementation using "BSF.cls"
to
transparently create Object Rexx proxy objects, if objects are returned
from Java method invocations and to transparently unregister them, when
the Object Rexx proxy objects are garbage collected.
java.util.Hashtable methodReferences
org.apache.bsf.util.type.TypeConvertorRegistry glob_tcr
Constructor Detail |
RexxAndJava(org.apache.bsf.BSFManager mgr, org.apache.bsf.BSFEngine rengine)
Preregisters the most important class objects. Referring to them is possible by using the following strings from Rexx (case *is* significant!):
Method Detail |
public int jniRegisterBSF()
public java.lang.String jniRexxStart(java.lang.String script, java.lang.String[] args)
script
- a String consisting of Rexx statements separated by
by line-end characters (';' or CR-LF).args
- an array of Strings representing the arguments
or null
, if no arguments are available.
null
, if
no result is returned or the Rexx interpreter stopped
execution due to a runtime error.public int jniRexxWaitForTermination()
public int jniRexxDidRexxTerminate()
public int jniInitialize4Rexx()
public java.lang.String javaCallBSF(java.lang.String[] args) throws org.apache.bsf.BSFException
TypeIndicator | Following Argument is of Type: |
"BOolean"
| "boolean" i.e. the value 0 (false) or 1 (true)
|
"BYte"
| "byte" a byte value
|
"Char"
| "char" i.e. a single (UTF8) character
|
"Double"
| "double" a double value
|
"Float"
| "float" a float value
|
"Int"
| "int" an integer value
|
"Long"
| "long" a long value
|
"Object"
| "Object" an Object which must be registered already |
"SHort"
| "short" a short value
|
"STring"
| "String" a string value (UTF8)
|
Hence, for the "...Strict"-subfunctions the Rexx supplied arguments must be given in pairs by Rexx: first the type argument (from the above table) and then the argument itself.
The call syntax from Rexx looks like, e.g.:
call BSF "SubFunctionName", "argument1", "argument2", "", ... or: a=BSF("SubFunctionName", "argument1", "argument2", ...)
The following BSF methods are made available to Rexx and can therefore be indicated as the first argument (the 'subfunction') to the 'BSF' call from Rexx:
SubFunctionName | Argument | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"addEventListener"
| Adds an event listener to a bean and defines the eventText
to be generated. These generated texts can be retrieved with the
function pollEventText .
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
beanName
| Mandatory, name of a registered bean which should get monitored. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
eventSetName
| Mandatory, name of the set the event belongs to. This name is used to create an event adapter at runtime. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
filter
| Mandatory, name of the actual event which should cause a notification. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
eventText
| Mandatory, text which should be sent by this event listener, each time the event occurs. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"addEventListenerReturningEventInfos"
| Adds an event listener to a bean and defines the eventText
to be generated. These generated texts can be retrieved with the
function pollEventText .
The supplied event text will get the string "/ * B S F B E A N/ * n a m e - o f - b e a n * / * /" prepended, where "name-of-bean" is the key into the BSFRegistry of a Java array object that contains:
|
null
.
org.apache.bsf.BSFException
java.lang.Object invokeMethod(java.lang.reflect.Method m, java.lang.Object o, java.lang.Object[] params) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
m
- method object to use for invocationo
- object for which the method should get invokedparams
- Object[] with parameters to supply
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
java.lang.Object[] coerceArgs(java.lang.Object[] funcArgs, java.lang.Class[] paramTypes)
funcArgs
- an Object
array (actually the Rexx arguments of type
String
)paramTypes
- an Class
array, containing the Java class objects to which
the Rexx arguments have to be converted to
null
else.protected boolean unregisterBean(java.lang.String beanName)
beanName
- name of the Bean to be unregistered
true
, if the Bean exists, false
else.protected java.lang.String makeString4Rexx(java.lang.Object o)
o
- the object which should get returned as a string to Rexx.
null
,
then the string of null4Rexx
is returned to Rexx.public java.lang.String makeBeanName(java.lang.Object o)
o.getClass().getName() + "@"
+ Integer.toHexString(o.hashCode())
.
o
- the object for which a unique string value should be created
null
, if the argument was null
,
else a String, uniquely denoting the objectjava.lang.String pp(java.lang.Object o)
|
20070921, rgf | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |