Class IDExecutionEnvironment
- All Implemented Interfaces:
ExecutableComponent
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.
- Author:
- Andreas Lanz
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
ExecutableComponent.Signals -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExecutableComponentThe Executable Component to be executed inside this ID Execution Environmentprotected SessionContextThe Session Context which will be passed along to the inner Componentprotected booleanIndicates if the inner Component should be resumed or started from scratch.protected StringThe 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_SAVEPOINTFields inherited from interface de.aristaflow.adept2.model.runtimeenvironment.ExecutableComponent
CONF_DATA_DIRECTORY, CONF_LIB_DIRECTORY, CONF_LOG_DIRECTORY, UNLOADING_CLASS_METHOD -
Constructor Summary
ConstructorsConstructorDescriptionIDExecutionEnvironment(ActivityInstance activityInstance) Creates a newIDExecutionEnvironmentfor the designated activity instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanclose()Returns false - overwrite this method to support closing.voidcommit()Throws anIsNotSupportedException- overwrite this method to support committing.protected voidfinish()Finishes the execution of the inner component by resetting context fields and logging an info message.protected ExecutableComponentgetComponentToExecute(ActivityInstance actInstance) Determines the Executable Component to be executed inside thisIDExecutionEnvironment.voidinit(SessionContext sessContext) Initialises thisExecutionEnvironmentby setting the session context, the logger field and the activity data.protected voidSets 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".voidinitResume(String savepointId, SessionContext sessContext) Does nothing - overwrite this method to support resuming.booleankill()Returns false - overwrite this method to support killing.Throws anIsNotSupportedException- overwrite this method to support Two-phase-commit.booleanreset()Returns false - overwrite this method to support reset.booleanrollback()Throws anIsNotSupportedException- overwrite this method to support rolling back.voidrun()Resemblesexcept that this method is expected to throw exceptions indicating that the environment was unexpected or an internal failure occurred.Runnable.run()booleansignal(int signal) Returns false - overwrite this method to support signalling.booleansuspend()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 Details
-
innerComponent
The Executable Component to be executed inside this ID Execution Environment -
innerSessionContext
The Session Context which will be passed along to the inner Component -
resume
protected boolean resumeIndicates if the inner Component should be resumed or started from scratch. -
savepoint
The Savepoint to resume from if resume is true.
-
-
Constructor Details
-
IDExecutionEnvironment
Creates a newIDExecutionEnvironmentfor 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 thisIDExecutionEnvironmentwhich is also the activity instance for the inner Component.- Throws:
ApplicationEnvironmentException- if any problems occur while instantiating the inner class
-
-
Method Details
-
getComponentToExecute
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
Description copied from class:ExecutionEnvironmentInitialises thisExecutionEnvironmentby 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:
initin interfaceExecutableComponent- Overrides:
initin classExecutionEnvironment- Parameters:
sessContext- The session context to associate with thisExecutionEnvironment.
-
initResume
Description copied from class:ExecutionEnvironmentDoes 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:
initResumein interfaceExecutableComponent- Overrides:
initResumein 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:ExecutableComponentResemblesexcept 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 toRuntimeExceptionFAILED.- Specified by:
runin interfaceExecutableComponent- Specified by:
runin classExecutionEnvironment
-
close
public boolean close()Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support closing.Instructs the component to terminate. Within this method the component should deallocate all allocated resources.
- Specified by:
closein interfaceExecutableComponent- Overrides:
closein classExecutionEnvironment- Returns:
false
-
reset
public boolean reset()Description copied from class:ExecutionEnvironmentReturns 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:
resetin interfaceExecutableComponent- Overrides:
resetin classExecutionEnvironment- Returns:
false
-
signal
public boolean signal(int signal) Description copied from class:ExecutionEnvironmentReturns false - overwrite this method to support signalling.Signals an event to the application.
- Specified by:
signalin interfaceExecutableComponent- Overrides:
signalin classExecutionEnvironment- Parameters:
signal- Ignored.- Returns:
false- See Also:
-
suspend
public boolean suspend()Description copied from class:ExecutionEnvironmentReturns 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:
suspendin interfaceExecutableComponent- Overrides:
suspendin classExecutionEnvironment- Returns:
false
-
kill
public boolean kill()Description copied from class:ExecutionEnvironmentReturns 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:
killin interfaceExecutableComponent- Overrides:
killin classExecutionEnvironment- Returns:
false
-
prepareCommit
Description copied from class:ExecutionEnvironmentThrows 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:
prepareCommitin interfaceExecutableComponent- Overrides:
prepareCommitin classExecutionEnvironment- Returns:
- Nothing, since an
IsNotSupportedExceptionis always thrown. - Throws:
IsNotSupportedException- This exception is always thrown.
-
rollback
Description copied from class:ExecutionEnvironmentThrows 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:
rollbackin interfaceExecutableComponent- Overrides:
rollbackin classExecutionEnvironment- Returns:
- Nothing, since an
IsNotSupportedExceptionis always thrown. - Throws:
IsNotSupportedException- This exception is always thrown.
-
commit
Description copied from class:ExecutionEnvironmentThrows anIsNotSupportedException- overwrite this method to support committing.Instructs the component to commit its modifications not managed by ADEPT.
- Specified by:
commitin interfaceExecutableComponent- Overrides:
commitin 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".
-