public interface ExecutableComponent
Implementations of this interface need to provide a constructor accepting the
name of the instance (String), and the corresponding activity
instance object ().
The constructor should check the configuration for mandatory parameters and
throw a ActivityInstanceApplicationEnvironmentException in case not all
mandatory parameters are provided.
At first one of the methods init(SessionContext) or
initResume(String, SessionContext) are executed exactly once. This
initialises the component including its UI if available. Afterwards
run() is called which executes the component.
Important remark: The runtime environment ensures that every call to these
methods initiated by the runtime environment is executed by the main thread
of the component. So these methods do not have to be made thread safe when
the component has no other concurrent executing threads itself. But since the
component needs to react to external signals, the executing thread may be
interrupted any time. In this case it should call
RuntimeEnvironment.dispatch() which dispatches the external signal by
calling one of the signal methods (close() suspend(),
kill(), signal(int)). The value returned by this methods is
afterwards returned by RuntimeEnvironment.dispatch(). This allows the
executing thread to react to the external signal.
For cleaning-up statically acquired resources (for instance when using Axis
or similar frameworks), a static method may be provided by an
implementation class of this interface having the following signature:
public static void "unloadingClass"(. UnloadingClassEvent)
This method is called before the class is unloaded. For normal components
this is right after they have terminated. If they are shared, the method will
called right before the runtime environment terminates. Note that this method
cannot rely on being called by the main thread of the component! The
event provides some information which may be relevant for cleaning-up
statically.
The method will be called on the implementing class of the executable
component. If superclasses also implement this method, your implementation
may need to call them. Therefore your own implementation must expect that
the corresponding executable component has never been executed, that is no
method except the constructor has been called! This is the case, if a
subclass overrides all the methods of your class and does not provide the
static cleanup. Additionally, the method may be called several times in case
different subclasses are unloaded and all call the method of the superclass.
And obviously, the static cleanup may not access instance-specific fields or
alike.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
ExecutableComponent.Signals
Definition of the constants for signals that could be interpreted by
execution environments.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CONF_DATA_DIRECTORY
Key for the platform data directory which is injected into each activity configuration.
|
static java.lang.String |
CONF_LIB_DIRECTORY
Key for the platform directory for external libraries which is injected into each activity
configuration.
|
static java.lang.String |
CONF_LOG_DIRECTORY
Key for the platform log directory which is injected into each activity configuration.
|
static java.lang.String |
UNLOADING_CLASS_METHOD
The name of the static method which is called before the class of an
ExecutableComponent is unloaded. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
close()
Instructs the component to terminate.
|
void |
commit()
Instructs the component to commit its modifications not managed by
ADEPT.
|
void |
init(SessionContext sessionContext)
Initialises and prepares the execution of the application and provides all
necessary data which maybe necessary for this.
|
void |
initResume(java.lang.String savepointId,
SessionContext sessionContext)
Initialises and prepares the resuming of the application and provides all
necessary data which maybe necessary for this.
|
boolean |
kill()
Enforces the application to abort its execution at once.
|
Vote |
prepareCommit()
Instructs the component to vote for Commit or Abort of the
distributed transaction it participates in and to prepare a commit.
|
boolean |
reset()
Instructs the component to reset.
|
boolean |
rollback()
Instructs the component to undo all its modifications done within the
current transaction.
|
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)
Signals an event to the application.
|
boolean |
suspend()
Instructs the component to store its internal state to the data
context and to terminate at once.
|
static final java.lang.String UNLOADING_CLASS_METHOD
ExecutableComponent is unloaded. This allows to clean-up
static resources. In case of a shared class, this will be called before
terminating the runtime manager, otherwise right after the execution of the
component.static final java.lang.String CONF_LIB_DIRECTORY
static final java.lang.String CONF_DATA_DIRECTORY
static final java.lang.String CONF_LOG_DIRECTORY
void init(SessionContext sessionContext)
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.
sessionContext - The session context in which the component is to be
executed.ApplicationEnvironmentException - If the component is not provided
with the expected environment, for instance, the right input
data, an ApplicationEnvironmentException will be
thrown.void initResume(java.lang.String savepointId,
SessionContext sessionContext)
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 init(SessionContext).
savepointId - The identifier of the savepoint at which the application
should resume. This must not be null, but it may be
the empty string.sessionContext - The session context in which the component is to be
executed.ApplicationEnvironmentException - If the component is not provided
with the expected environment, for instance, the right input
data, an ApplicationEnvironmentException will be
thrown.void run()
Runnable.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.ApplicationEnvironmentException - If the component is not provided
with the expected environment, for instance, the right input
data, an ApplicationEnvironmentException will be
thrown.ApplicationFailedException - If the component fails due to internal
reasons, an ApplicationFailedException (resembling
a RuntimeException) will be thrown.java.lang.RuntimeException - If there is a runtime exception which is not
caught by the component, it will be caught by the runtime
environment which will set the process activity to
FAILED.boolean close()
boolean reset()
kill()
but the application does not fail but terminate normally (by calling
RuntimeEnvironment.applicationReset(). The component will be
re-initialised and executed again later.boolean signal(int signal)
signal - the code that specifies the type of the signaled event.for 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.boolean suspend()
boolean kill()
Vote prepareCommit() throws IsNotSupportedException
IsNotSupportedException - If the 2 Phase Commit Protocol is not
supported an IsNotSupportedException is thrown.boolean rollback()
throws IsNotSupportedException
resettable.true in case resetting/rollback was
successful, false if not.IsNotSupportedException - If the component does not support rollback,
an IsNotSupportedException will be thrown.void commit()
throws IsNotSupportedException
IsNotSupportedException - If the component does not support commit,
an IsNotSupportedException will be thrown.