Class IDExecutionEnvironment
- java.lang.Object
-
- de.aristaflow.adept2.core.runtimemanager.executionenvironments.ExecutionEnvironment
-
- de.aristaflow.adept2.core.runtimemanager.executionenvironments.IDExecutionEnvironment
-
- All Implemented Interfaces:
ExecutableComponent
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 thisExecutableComponent
are simply forwarded to the inner component.
In case the application fails thisExecutionEnvironment
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 theinitialise()
andfinish()
methods may be overridden if there are components which need any special treatment before or after their execution.- Author:
- Andreas Lanz
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
ExecutableComponent.Signals
-
-
Field Summary
Fields Modifier and Type Field Description protected ExecutableComponent
innerComponent
The Executable Component to be executed inside this ID Execution Environmentprotected SessionContext
innerSessionContext
The Session Context which will be passed along to the inner Componentprotected boolean
resume
Indicates if the inner Component should be resumed or started from scratch.protected String
savepoint
The Savepoint to resume from if resume is true.-
Fields inherited from class de.aristaflow.adept2.core.runtimemanager.executionenvironments.ExecutionEnvironment
actData, activityInstance, cleanup, localisedActInst, logger, sessionContext, SUSPEND_SAVEPOINT
-
Fields inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
CONF_DATA_DIRECTORY, CONF_LIB_DIRECTORY, CONF_LOG_DIRECTORY, UNLOADING_CLASS_METHOD
-
-
Constructor Summary
Constructors Constructor Description IDExecutionEnvironment(ActivityInstance activityInstance)
Creates a newIDExecutionEnvironment
for the designated activity instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
close()
Returns false - overwrite this method to support closing.void
commit()
Throws anIsNotSupportedException
- 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 thisIDExecutionEnvironment
.void
init(SessionContext sessContext)
Initialises thisExecutionEnvironment
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.
This is the first method called in the lifetime of this "executor".void
initResume(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 anIsNotSupportedException
- overwrite this method to support Two-phase-commit.boolean
reset()
Returns false - overwrite this method to support reset.boolean
rollback()
Throws anIsNotSupportedException
- 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.Runnable.run()
boolean
signal(int signal)
Returns false - overwrite this method to support signalling.boolean
suspend()
Returns false - overwrite this method to support suspending.-
Methods inherited from class de.aristaflow.adept2.core.runtimemanager.executionenvironments.ExecutionEnvironment
cleanup, createActivityData, getApplicationState, getApplicationState, getRawApplicationState, getRawApplicationState, requireGUIContext, setApplicationState, setApplicationState, setRawApplicationState, setRawApplicationState
-
-
-
-
Field Detail
-
innerComponent
protected ExecutableComponent innerComponent
The Executable Component to be executed inside this ID Execution Environment
-
innerSessionContext
protected SessionContext innerSessionContext
The Session Context which will be passed along to the inner Component
-
resume
protected boolean resume
Indicates if the inner Component should be resumed or started from scratch.
-
savepoint
protected String savepoint
The Savepoint to resume from if resume is true.
-
-
Constructor Detail
-
IDExecutionEnvironment
public IDExecutionEnvironment(ActivityInstance activityInstance)
Creates a newIDExecutionEnvironment
for the designated activity instance. The constructor sets the necessary fields by calling the constructor of the superclass.
After that it creates the inner Component to be executed by callinggetComponentToExecute(ActivityInstance)
- Parameters:
activityInstance
- The activity instance for thisIDExecutionEnvironment
which is also the activity instance for the inner Component.- Throws:
ApplicationEnvironmentException
- if any problems occur while instantiating the inner class
-
-
Method Detail
-
getComponentToExecute
protected ExecutableComponent getComponentToExecute(ActivityInstance actInstance)
Determines the Executable Component to be executed inside thisIDExecutionEnvironment
.- Parameters:
actInstance
- the activity instance for which the Executable Component should created. Theget("ComponentURI")
is used for retrieving the Component to be Executed.- Returns:
- An instance of the Component to be executed by this ID Runtime Environment
- Throws:
ApplicationEnvironmentException
- if anything goes wrong during the instantiation of the class specified byget("ComponentURI")
-
init
public void init(SessionContext sessContext)
Description copied from class:ExecutionEnvironment
Initialises thisExecutionEnvironment
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.
- Specified by:
init
in interfaceExecutableComponent
- Overrides:
init
in classExecutionEnvironment
- Parameters:
sessContext
- The session context to associate with thisExecutionEnvironment
.
-
initResume
public void initResume(String savepointId, SessionContext sessContext)
Description copied from class:ExecutionEnvironment
Does nothing - overwrite this method to support resuming.
Note that this does neither set the session context nor the logger.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)
.- Specified by:
initResume
in interfaceExecutableComponent
- Overrides:
initResume
in classExecutionEnvironment
- Parameters:
savepointId
- The identifier of the savepoint at which the application should resume. This must not benull
, but it may be the empty string.sessContext
- The session context in which the component is to be executed.
-
run
public void run()
Description copied from interface:ExecutableComponent
Resembles
except that this method is expected to throw exceptions indicating that the environment was unexpected or an internal failure occurred. Both exceptions as well asRunnable.run()
will set the corresponding process activity toRuntimeException
FAILED
.- Specified by:
run
in interfaceExecutableComponent
- Specified by:
run
in classExecutionEnvironment
-
close
public boolean close()
Description copied from class:ExecutionEnvironment
Returns false - overwrite this method to support closing.Instructs the component to terminate. Within this method the component should deallocate all allocated resources.
- Specified by:
close
in interfaceExecutableComponent
- Overrides:
close
in classExecutionEnvironment
- Returns:
false
-
reset
public boolean reset()
Description copied from class:ExecutionEnvironment
Returns false - overwrite this method to support reset.Instructs the component to reset. This is quite similar to
ExecutableComponent.kill()
but the application does not fail but terminate normally (by callingRuntimeEnvironment.applicationReset()
. The component will be re-initialised and executed again later.- Specified by:
reset
in interfaceExecutableComponent
- Overrides:
reset
in classExecutionEnvironment
- Returns:
false
-
signal
public boolean signal(int signal)
Description copied from class:ExecutionEnvironment
Returns false - overwrite this method to support signalling.Signals an event to the application.
- Specified by:
signal
in interfaceExecutableComponent
- Overrides:
signal
in classExecutionEnvironment
- Parameters:
signal
- Ignored.- Returns:
false
- See Also:
for possible signals. Usually the ones that have corresponding methods, e. g. or , will not be signaled via this method.
-
suspend
public boolean suspend()
Description copied from class:ExecutionEnvironment
Returns false - overwrite this method to support suspending.Instructs 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.
- Specified by:
suspend
in interfaceExecutableComponent
- Overrides:
suspend
in classExecutionEnvironment
- Returns:
false
-
kill
public boolean kill()
Description copied from class:ExecutionEnvironment
Returns false - overwrite this method to support killing.Enforces 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.
- Specified by:
kill
in interfaceExecutableComponent
- Overrides:
kill
in classExecutionEnvironment
- Returns:
false
-
prepareCommit
public Vote prepareCommit() throws IsNotSupportedException
Description copied from class:ExecutionEnvironment
Throws anIsNotSupportedException
- 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.
- Specified by:
prepareCommit
in interfaceExecutableComponent
- Overrides:
prepareCommit
in classExecutionEnvironment
- Returns:
- Nothing, since an
IsNotSupportedException
is always thrown. - Throws:
IsNotSupportedException
- This exception is always thrown.
-
rollback
public boolean rollback() throws IsNotSupportedException
Description copied from class:ExecutionEnvironment
Throws anIsNotSupportedException
- 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
.- Specified by:
rollback
in interfaceExecutableComponent
- Overrides:
rollback
in classExecutionEnvironment
- Returns:
- Nothing, since an
IsNotSupportedException
is always thrown. - Throws:
IsNotSupportedException
- This exception is always thrown.
-
commit
public void commit() throws IsNotSupportedException
Description copied from class:ExecutionEnvironment
Throws anIsNotSupportedException
- overwrite this method to support committing.Instructs the component to commit its modifications not managed by ADEPT.
- Specified by:
commit
in interfaceExecutableComponent
- Overrides:
commit
in classExecutionEnvironment
- Throws:
IsNotSupportedException
- This exception is always thrown.
-
initialise
protected void initialise()
Sets the session context of the component, resumes the component, if appropriate and logs an info.
This is the first method called in the lifetime of this "executor".
-
finish
protected void finish()
Finishes the execution of the inner component by resetting context fields and logging an info message.
This method is the last method called in the lifetime of this "executor".
-
-