Automatic
Wrapping of Existing Java Objects
How
ISDK/Java does "introspection"
How
we can magically wrap around a Java object wrapper function
that will... The specific object is called (I think)
javaObject.
The
Java package includes several support classes found
in the distribution in 'libs/JavaObject.java' which
implement the introspection being discussed. The sample
'samples/simple/Simple0.java' demonstrates using this
code.
The
standard way to allow a ScriptEase script to interact
with Java objects is to write wrapper functions to explicitly
extract needed information from these Java objects and
make it available to the script. We have provided a
Java class to do this in a generic way without the need
to code explicit wrapper functions.
This
code uses the Java reflection capability to examine
any particular Java object and map it to a corresponding
ScriptEase object. This ScriptEase object will have
the same class members and methods that the Java object
does.
When
the script reads from or assigns to any member, the
ScriptEase data is translated underneath from or to
the corresponding Java data. When the script calls a
method of the object, the parameters are translated
to Java and the Java method is called. The Java return
is translated back to ScriptEase data and made available
to the script.
The
result is that the script has access to a Java object
that can be manipulated like any other ScriptEase object.
The code to use this capability in your own ScriptEase:
ISDK for Java application is in the file libs/JavaObject.java.
This file documents in the comment section near the
top of the file how it is used.
A
sample application that uses it is provided in,
samples/simple/Simple0.java .
The
file samples/simple/JOTest.java is a very simple Java
class that is made available and then manipulated in
this sample.
|