public class IDExecutionEnvironment extends ExecutionEnvironment
The ID Execution Environment is used for executing application which though
they implement the ExecutableComponent interface don't have an
ADEPT2-Registry conform constructor.
The activity URI is used for retrieving the class to be executed by this
environment. This class is instantiated via an empty Constructor which must
exist and be public. The component runs inside the same thread as this
execution environment so that no additional synchronisation is required and
it is ensured that the component is always called by the same thread. Most of
the signals send to this ExecutableComponent are simply
forwarded to the inner component.
In case the application fails this ExecutionEnvironment logs
an error message and rethrows the caught exception.
The getComponentToExecute(ActivityInstance) method may be overridden
or reimplemented in order to make it possible to call components which don't
have an empty constructor or need any other special treatment upon creation.
Also the initialise() and finish() methods may be
overridden if there are components which need any special treatment before or
after their execution.
ExecutableComponent.Signals| Modifier and Type | Field and Description |
|---|---|
protected ExecutableComponent |
innerComponent
The Executable Component to be executed inside this ID Execution
Environment
|
protected SessionContext |
innerSessionContext
The Session Context which will be passed along to the inner Component
|
protected boolean |
resume
Indicates if the inner Component should be resumed or started from scratch.
|
protected java.lang.String |
savepoint
The Savepoint to resume from if resume is true.
|
actData, activityInstance, localisedActInst, logger, sessionContext, SUSPEND_SAVEPOINTCONF_DATA_DIRECTORY, CONF_LIB_DIRECTORY, CONF_LOG_DIRECTORY, UNLOADING_CLASS_METHOD| Constructor and Description |
|---|
IDExecutionEnvironment(ActivityInstance activityInstance)
Creates a new
IDExecutionEnvironment for the designated
activity instance. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
Returns false - overwrite this method to support closing.
|
void |
commit()
Throws an
IsNotSupportedException - overwrite this method to
support committing. |
protected void |
finish()
Finishes the execution of the inner component by resetting context fields
and logging an info message.
|
protected ExecutableComponent |
getComponentToExecute(ActivityInstance actInstance)
Determines the Executable Component to be executed inside this
IDExecutionEnvironment. |
void |
init(SessionContext sessContext)
Initialises this
ExecutionEnvironment by setting the session
context, the logger field and the activity data. |
protected void |
initialise()
Sets the session context of the component, resumes the component, if
appropriate and logs an info.
|
void |
initResume(java.lang.String savepointId,
SessionContext sessContext)
Does nothing - overwrite this method to support resuming.
|
boolean |
kill()
Returns false - overwrite this method to support killing.
|
Vote |
prepareCommit()
Throws an
IsNotSupportedException - overwrite this method to
support Two-phase-commit. |
boolean |
reset()
Returns false - overwrite this method to support reset.
|
boolean |
rollback()
Throws an
IsNotSupportedException - overwrite this method to
support rolling back. |
void |
run()
Resembles
except that this method is
expected to throw exceptions indicating that the environment was unexpected
or an internal failure occurred. |
boolean |
signal(int signal)
Returns false - overwrite this method to support signalling.
|
boolean |
suspend()
Returns false - overwrite this method to support suspending.
|
createActivityData, getApplicationState, getApplicationState, getRawApplicationState, getRawApplicationState, requireGUIContext, setApplicationState, setApplicationState, setRawApplicationState, setRawApplicationStateprotected ExecutableComponent innerComponent
protected SessionContext innerSessionContext
protected boolean resume
protected java.lang.String savepoint
public IDExecutionEnvironment(ActivityInstance activityInstance)
IDExecutionEnvironment for the designated
activity instance. The constructor sets the necessary fields by calling the
constructor of the superclass.getComponentToExecute(ActivityInstance)activityInstance - The activity instance for this
IDExecutionEnvironment which is also the activity
instance for the inner Component.ApplicationEnvironmentException - if any problems occur while
instantiating the inner classprotected ExecutableComponent getComponentToExecute(ActivityInstance actInstance)
IDExecutionEnvironment.actInstance - the activity instance for which the Executable
Component should created. The
get("ComponentURI")
is used for retrieving the Component to be Executed.ApplicationEnvironmentException - if anything goes wrong during the
instantiation of the class specified by
get("ComponentURI")public void init(SessionContext sessContext)
ExecutionEnvironmentExecutionEnvironment by setting the session
context, the logger field and the activity data. These fields are not
available before! Therefore you should call this method very early when
initialising or initialising for resume.
Initialises and prepares the execution of the application and provides all
necessary data which maybe necessary for this. This method or
ExecutableComponent.initResume(String, SessionContext) is only called once in the
lifetime of an executable component. One of these methods is guaranteed to
be called before calling any other method.
When leaving this method the execution has to be completely prepared. This includes for instance the availability of the GUI in the GUI context, which is necessary for Web applications with HTML-UI.
init in interface ExecutableComponentinit in class ExecutionEnvironmentsessContext - The session context to associate with this
ExecutionEnvironment.public void initResume(java.lang.String savepointId,
SessionContext sessContext)
ExecutionEnvironment
Initialises and prepares the resuming of the application and provides all
necessary data which maybe necessary for this. This method or
ExecutableComponent.init(SessionContext) is only called once in the lifetime of an
executable component. One of these methods is guaranteed to be called
before calling any other method.
When leaving this method the execution has to be completely prepared for resuming. That is, the state of the application has to be restored. This includes the GUI.
Usually this method will delegate also call ExecutableComponent.init(SessionContext).
initResume in interface ExecutableComponentinitResume in class ExecutionEnvironmentsavepointId - The identifier of the savepoint at which the application
should resume. This must not be null, but it may be
the empty string.sessContext - The session context in which the component is to be
executed.public void run()
ExecutableComponentRunnable.run() except that this method is
expected to throw exceptions indicating that the environment was unexpected
or an internal failure occurred. Both exceptions as well as
RuntimeException will set the corresponding process
activity to FAILED.run in interface ExecutableComponentrun in class ExecutionEnvironmentpublic boolean close()
ExecutionEnvironmentInstructs the component to terminate. Within this method the component should deallocate all allocated resources.
close in interface ExecutableComponentclose in class ExecutionEnvironmentfalsepublic boolean reset()
ExecutionEnvironment
Instructs the component to reset. This is quite similar to ExecutableComponent.kill()
but the application does not fail but terminate normally (by calling
RuntimeEnvironment.applicationReset(). The component will be
re-initialised and executed again later.
reset in interface ExecutableComponentreset in class ExecutionEnvironmentfalsepublic boolean signal(int signal)
ExecutionEnvironmentSignals an event to the application.
signal in interface ExecutableComponentsignal in class ExecutionEnvironmentsignal - Ignored.falsefor possible signals. Usually the ones that have corresponding methods, e. g.
{@link Signals#SUSPEND} or {@link Signals#CLOSE}, will not be signaled via this method.public boolean suspend()
ExecutionEnvironmentInstructs the component to store its internal state to the data context and to terminate at once. The application should be able to continue its job later when resuming.
suspend in interface ExecutableComponentsuspend in class ExecutionEnvironmentfalsepublic boolean kill()
ExecutionEnvironmentEnforces the application to abort its execution at once. In the case of running a internal transaction application should abort the transaction and should rollback. Within this method the component should deallocate all allocated resources.
kill in interface ExecutableComponentkill in class ExecutionEnvironmentfalsepublic Vote prepareCommit() throws IsNotSupportedException
ExecutionEnvironmentIsNotSupportedException - overwrite this method to
support Two-phase-commit.
Instructs the component to vote for Commit or Abort of the distributed transaction it participates in and to prepare a commit.
prepareCommit in interface ExecutableComponentprepareCommit in class ExecutionEnvironmentIsNotSupportedException is always
thrown.IsNotSupportedException - This exception is always thrown.public boolean rollback()
throws IsNotSupportedException
ExecutionEnvironmentIsNotSupportedException - overwrite this method to
support rolling back.
Instructs the component to undo all its modifications done within the
current transaction. This method has to be implemented in case the
application is
resettable.
rollback in interface ExecutableComponentrollback in class ExecutionEnvironmentIsNotSupportedException is always
thrown.IsNotSupportedException - This exception is always thrown.public void commit()
throws IsNotSupportedException
ExecutionEnvironmentIsNotSupportedException - overwrite this method to
support committing.
Instructs the component to commit its modifications not managed by ADEPT.
commit in interface ExecutableComponentcommit in class ExecutionEnvironmentIsNotSupportedException - This exception is always thrown.protected void initialise()
protected void finish()