public class EmbeddedEclipse extends EclipseConnectionImpl implements EclipseConnection, EclipseEngine
getInstance(EclipseEngineOptions)
method to create an embedded ECLiPSe engine if none exists.
The EclipseEngineOptions
object should be created, configured,
and then passed to this method to start the ECLiPSe with user-defined options.
Once started, a reference to the EmbeddedEclipse instance can be
obtained using the getInstance()
method.
Note that
once the EmbeddedEclipse has been shut down by calling its destroy()
method,
no more embedded ECLiPSe engines
can be started using getInstance(EclipseEngineOptions)
.
Here is some example code for working with an EmbeddedEclipse:
// create a new EclipseEngineOptions object EclipseEngineOptions options = new EclipseEngineOptions(new File("C:\Eclipse\")); // alter the useQueues option options.setUseQueues(true); // start up the embedded Eclipse. testEclipse is a reference to the // Eclipse engine. EclipseEngine testEclipse = EmbeddedEclipse.getInstance(options); // Direct the Eclipse to load a source file. testEclipse.compile(new File(".\myEclipseSourceFile.pl")); // Execute a top-level goal in ECLiPSe. testEclipse.rpc("go"); // Destroy the Eclipse ((EmbeddedEclipse) testEclipse).destroy();
EclipseConnection
,
EclipseEngine
,
EclipseEngineOptions
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Terminate access to the EmbeddedEclipse.
|
AsyncEclipseQueue |
getAsyncEclipseQueue(java.lang.String name)
Create or access an asynchronous queue to transfer data between Java
and ECLiPSe.
|
FromEclipseQueue |
getEclipseStderr()
Return a FromEclipseQueue which allows access to the ECLiPSe engine's
stderr stream. |
ToEclipseQueue |
getEclipseStdin()
Return a ToEclipseQueue which allows access to the ECLiPSe engine's
stdin stream. |
FromEclipseQueue |
getEclipseStdout()
Return a FromEclipseQueue which allows access to the ECLiPSe engine's
stdout stream. |
static EmbeddedEclipse |
getInstance()
Returns the unique EmbeddedEclipse object if the embedded ECLiPSe
has been started, but not yet terminated in this JVM.
|
static EmbeddedEclipse |
getInstance(EclipseEngineOptions options)
If the embedded ECLiPSe has not yet been started in this JVM, start the
embedded ECLiPSe using the options specified in the parameter
EclipseEngineOptions.
|
boolean |
isUsingQueues()
Query the ECLiPSe engine's "use queues" flag.
|
compile, getFromEclipseQueue, getPath, getPeerName, getToEclipseQueue, registerMultitask, rpc, rpc, rpc, rpc, rpc, rpc, rpc, rpc, rpc
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compile, getFromEclipseQueue, getPath, getPeerName, getToEclipseQueue, registerMultitask, rpc, rpc, rpc, rpc, rpc, rpc, rpc, rpc, rpc
public static EmbeddedEclipse getInstance(EclipseEngineOptions options) throws EclipseException, java.io.IOException
options
- user-definable options used to configure the embedded
ECLiPSe engine.EclipseException
- if the embedded ECLiPSe has already been started,
or if there was some ECLiPSe-related problem whilst
attempting to start ECLiPSe, for example if the ECLiPSe installation
directory was not set in the supplied EclipseEngineOptions object.EclipseTerminatedException
- if the embedded ECLiPSe has already been terminatedjava.io.IOException
- if there is some other I/O-related problem starting the ECLiPSe engine.public static EmbeddedEclipse getInstance() throws EclipseException, java.io.IOException
EclipseException
- if ECLiPSe has not been started.EclipseTerminatedException
- if the embedded ECLiPSe has been
terminated.java.io.IOException
public AsyncEclipseQueue getAsyncEclipseQueue(java.lang.String name) throws EclipseException, java.io.IOException
EclipseConnection
getAsyncEclipseQueue
in interface EclipseConnection
getAsyncEclipseQueue
in class EclipseConnectionImpl
name
- the name to be used for the stream representing the queue on
the ECLiPSe side.EclipseException
- if the name for the ECLiPSe stream is already in use,
or ECLiPSe could not create its side of the queue for some reason.java.io.IOException
- if there was an I/O problem while accessing ECLiPSe.EclipseTerminatedException
- if this EclipseConnection has
been terminated.public void destroy() throws java.io.IOException
destroy()
has been invoked, use of this EmbeddedEclipse's
methods will throw EclipseTerminatedExceptions. Also, once
destroy()
has been invoked, no more EmbeddedEclipse instances
can be created during the lifetime of this Java virtual machine.EclipseTerminatedException
- if the ECLiPSe engine has already been
terminated.java.io.IOException
- if there was a problem communicating with ECLiPSe
during termination.public ToEclipseQueue getEclipseStdin() throws EclipseTerminatedException
EclipseEngine
stdin
stream. Returns null if the ECLiPSe was not set
up to use queue objects for its standard streams (see EclipseEngineOptions
).getEclipseStdin
in interface EclipseEngine
EclipseTerminatedException
- if the ECLiPSe engine has been destroyed
or disconnected.public FromEclipseQueue getEclipseStdout() throws EclipseTerminatedException
EclipseEngine
stdout
stream. Returns null if the ECLiPSe was not set
up to use queue objects for its standard streams (see EclipseEngineOptions
).getEclipseStdout
in interface EclipseEngine
EclipseTerminatedException
- if the ECLiPSe engine has been
destroyed.public FromEclipseQueue getEclipseStderr() throws EclipseTerminatedException
EclipseEngine
stderr
stream. Returns null if the ECLiPSe was not set
up to use queue objects for its standard streams (see EclipseEngineOptions
).getEclipseStderr
in interface EclipseEngine
EclipseTerminatedException
- if the ECLiPSe engine has been
destroyed.public boolean isUsingQueues()
EclipseEngine
isUsingQueues
in interface EclipseEngine