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 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
  • Field Details

    • 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 Details

    • IDExecutionEnvironment

      public IDExecutionEnvironment(ActivityInstance activityInstance)
      Creates a new IDExecutionEnvironment 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 calling getComponentToExecute(ActivityInstance)
      Parameters:
      activityInstance - The activity instance for this IDExecutionEnvironment which is also the activity instance for the inner Component.
      Throws:
      ApplicationEnvironmentException - if any problems occur while instantiating the inner class
  • Method Details

    • getComponentToExecute

      protected ExecutableComponent getComponentToExecute(ActivityInstance actInstance)
      Determines the Executable Component to be executed inside this IDExecutionEnvironment.
      Parameters:
      actInstance - the activity instance for which the Executable Component should created. The get("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 by get("ComponentURI")
    • init

      public void init(SessionContext sessContext)
      Description copied from class: ExecutionEnvironment
      Initialises this ExecutionEnvironment 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 interface ExecutableComponent
      Overrides:
      init in class ExecutionEnvironment
      Parameters:
      sessContext - The session context to associate with this ExecutionEnvironment.
    • 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 interface ExecutableComponent
      Overrides:
      initResume in class ExecutionEnvironment
      Parameters:
      savepointId - 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.
    • run

      public void run()
      Description copied from interface: ExecutableComponent
      Resembles 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.
      Specified by:
      run in interface ExecutableComponent
      Specified by:
      run in class ExecutionEnvironment
    • 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 interface ExecutableComponent
      Overrides:
      close in class ExecutionEnvironment
      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 calling RuntimeEnvironment.applicationReset(). The component will be re-initialised and executed again later.

      Specified by:
      reset in interface ExecutableComponent
      Overrides:
      reset in class ExecutionEnvironment
      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 interface ExecutableComponent
      Overrides:
      signal in class ExecutionEnvironment
      Parameters:
      signal - Ignored.
      Returns:
      false
      See Also:
    • 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 interface ExecutableComponent
      Overrides:
      suspend in class ExecutionEnvironment
      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 interface ExecutableComponent
      Overrides:
      kill in class ExecutionEnvironment
      Returns:
      false
    • prepareCommit

      public Vote prepareCommit() throws IsNotSupportedException
      Description copied from class: ExecutionEnvironment
      Throws an IsNotSupportedException - 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 interface ExecutableComponent
      Overrides:
      prepareCommit in class ExecutionEnvironment
      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 an IsNotSupportedException - 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 interface ExecutableComponent
      Overrides:
      rollback in class ExecutionEnvironment
      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 an IsNotSupportedException - overwrite this method to support committing.

      Instructs the component to commit its modifications not managed by ADEPT.

      Specified by:
      commit in interface ExecutableComponent
      Overrides:
      commit in class ExecutionEnvironment
      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".