Class 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 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 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 Detail

      • 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.
      • 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
      • 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
      • 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".