To Spawn TIBCO Enterprise Runtime for R Engines in a Separate Process
The terrJava package has been extended with the Java class
com.tibco.terr.TerrJavaRemote
, which can be used to spawn
a
TERR
engine running in a separate process, send commands to this engine, and get or
set data objects to this engine.
The
com.tibco.terr.TerrJavaRemote
class contains methods
similar in name and behavior to the methods of the
TerrJava
class that creates an embedded
TERR
engine within the Java process. One important difference is that the
TerrJava
methods are static class methods instead of
object methods, because they control the (single)
TERR
engine within the process. In contrast, it is possible to create multiple
TerrJavaRemote
objects, each connected to and
controlling a separate spawned
TERR
engine process.
TerrJavaRemote
objects rather than
TerrJava
.
- You can access more than one TERR engine at a time.
- You can use TERR from a Java application, where it is inconvenient or impossible to set the appropriate environment variables needed to run TERR within the Java process.
- You can spawn
TERR
within a Java JVM separate from the one containing the
TerrJavaRemote
object. For example, you can spawn a 64-bit Java and TERR process from a 32-bit Java application.
Like the
TerrJava
class, the
TerrJavaRemote
class is defined in
TERR_HOME/library/terrJava/java/terrJava.jar,
and documentation is available in
TERR_HOME/library/terrJava/doc/javadoc/index.html.
TerrJavaRemote
includes methods for sending expressions
to be evaluated in
TERR,
adding hooks for capturing
TERR
text input and output, and interrupting a running computation. There are also
methods for transferring
TerrData
objects going to or coming from the
TERR
engine.
TerrJavaRemote
methods are thread-safe, so a Java
application could create and access multiple
TerrJavaRemote
objects in separate Java threads. These
methods (except for
interrupt
) use Java synchronization so only one thread
can manipulate a given engine at a time. Separate
TerrJavaRemote
objects can access separate
TERR
engines at once without any interaction between these engines.
- A Console Application Using TerrJavaRemote
This is sample Java code for a simple console application using theTerrJavaRemote
API. - Run the Console Application Using TerrJavaRemote
This topic shows example user input and text output when running the TerrJavaRemoteConsoleExample application on Linux.