Class AbstractGUIManager

    • Field Detail

      • CONF_TERMINATION_TIMEOUT

        public static final String CONF_TERMINATION_TIMEOUT
        The key for the configuration value that specifies the total time in milliseconds to wait for the component to terminate. This time is distributed equally among different escalation levels if supported, for instance suspending or closing from the outside.
        See Also:
        Constant Field Values
      • TERMINATION_TIMEOUT

        protected final long TERMINATION_TIMEOUT
        The total time in milliseconds to wait for the termination of a component.
      • guiContexts

        protected final Map<Pair<EBPInstanceReference,​String>,​Pair<GUIContext,​de.aristaflow.adept2.model.runtimeenvironment.guicontext.TransferableGUIContext>> guiContexts
        The local and the corresponding transferred GUI contexts that have been created and not been closed yet, indexed by the pair that identifies the corresponding activity and its execution session.
        The activity can only be executed on one runtime manager. However, due to synchronisation issues between the executing remote machine, for a short time there may be two GUI contexts for the very same activity. Therefore they additionally have their execution session ID which changes for every execution.
      • localGuiContexts

        protected final Map<Closeable,​?> localGuiContexts
        The GUI contexts created locally. These will be closed when shutting down. The map contains weak keys, so the GUI contexts may be garbage-collected before.
        Subclasses should add their created GUI contexts to this map.
      • earlyTerminates

        protected final Set<Pair<EBPInstanceReference,​String>> earlyTerminates
        The activities (identified by the EBP instance reference and the execution session ID) of which the termination has already been notified but the corresponding GUI context has not yet been created. This can happen due to synchronisation issues between the executing remote machine and the local GUI manager.
        Access to this is synchronised via guiContexts.
      • listeners

        protected final Map<EBPInstanceReference,​Triple<LocalActivityStateNotifier,​URI[],​SessionToken>> listeners
        The activity state listeners this GUI manager is registered at for the corresponding activities. The URIs allow to reuse the entry, the session token is required for unregistering the GUI manager when closing the corresponding GUI context.
        Access to this is synchronised via guiContexts.
    • Constructor Detail

      • AbstractGUIManager

        public AbstractGUIManager​(org.apache.commons.configuration2.Configuration configuration,
                                  Registry registry)
        Creates a new GUI manager providing the basic means for a RemoteGUIManager. This includes accepting and forwarding the activity state notifications and allowing subclasses to terminate the remote execution.
        Parameters:
        configuration - The configuration of this service.
        registry - The registry to be used for accessing the execution control managers of remotely executed activities.
      • AbstractGUIManager

        public AbstractGUIManager​(org.apache.commons.configuration2.Configuration configuration,
                                  Registry registry,
                                  String[] startupRequiredServices,
                                  String[] runtimeRequiredServices)
        Creates a new GUI manager providing the basic means for a RemoteGUIManager. This includes accepting and forwarding the activity state notifications and allowing subclasses to terminate the remote execution. Subclasses can provide their required services.
        Parameters:
        configuration - The configuration of this service.
        registry - The registry to be used for accessing the execution control managers of remotely executed activities.
        startupRequiredServices - The service type names of services required by subclasses at startup time (in AbstractADEPT2Service.init(URI[], URI[]) and AbstractADEPT2Service.start()).
        runtimeRequiredServices - The service type names of services required by subclasses at runtime (after startup time).
    • Method Detail

      • shutdown

        public void shutdown​(boolean emergency)
        Description copied from class: AbstractADEPT2Service
        This implementation waits 10 seconds in case of an emergency and otherwise indefinitely for the termination of the active sessions. In case of an emergency shutdown may proceed even if there are active sessions.
        Specified by:
        shutdown in interface ADEPT2Service
        Overrides:
        shutdown in class AbstractADEPT2Service
        Parameters:
        emergency - Whether the shutdown will be an emergency shutdown.
      • getLocalForRemoteGuiContext

        public GUIContext getLocalForRemoteGuiContext​(SessionToken session,
                                                      de.aristaflow.adept2.model.runtimeenvironment.guicontext.TransferableGUIContext transfrdCtxt)
                                               throws GUIContextUnavailableException
        Description copied from interface: RemoteGUIManager
        Gets an appropriate GUI context for the designated TransferableGUIContext. The created context represents the designated context locally and can be any arbitrary appropriate GUI context. This can be the same GUI context provided by GUIManager but usually the remote execution requires some special logic in the local GUI context.
        Applications using the GUI context should cast the returned instance to the appropriate implementation.
        Specified by:
        getLocalForRemoteGuiContext in interface RemoteGUIManager
        Parameters:
        session - The session which is used to check for access rights on this method.
        transfrdCtxt - The GUI context retrieved from the component that is executed remotely. This needs to be wrapped appropriately in a local GUI context.
        Returns:
        The context containing the appropriate GUI for remotely execution of the component of the designated RemoteGUIContext. This can usually be ignored since the RemoteGUIManager integrates the GUIContext in the local GUI and handles closing it.
        Throws:
        GUIContextUnavailableException - If no GUI context can be created for the designated TransferableGUIContext, a GUIContextUnavailableException will be thrown.
      • createGUIContext

        public GUIContext createGUIContext​(SessionToken session,
                                           de.aristaflow.adept2.model.runtimeenvironment.guicontext.TransferableGUIContext trCtxt,
                                           ExecutionControlManager ecm)
                                    throws GUIContextUnavailableException
        Creates a GUI context for the designated TransferrableGUIContext and the designated ExecutionControlManager. This is similar to getLocalForRemoteGuiContext(SessionToken, TransferableGUIContext) but provides the corresponding execution control manager and may be overridden in subclasses. getLocalForRemoteGuiContext(SessionToken, TransferableGUIContext) may not be overridden since it provides the means for the ActivityStateNotification.
        Parameters:
        session - The session which is used to check for access rights on this method.
        trCtxt - The GUI context retrieved from the component that is executed remotely. A local GUI context for this has to be created.
        Returns:
        The context containing the appropriate GUI for remotely execution of the component of the designated RemoteGUIContext. This can usually be ignored since this RemoteGUIManager already handles closing and displaying of the created local GUIContext.
        Throws:
        GUIContextUnavailableException - If no GUI context can be created for the designated TransferableGUIContext, a GUIContextUnavailableException will be thrown.
      • getActivityStateListenerURIs

        public URI[] getActivityStateListenerURIs​(SessionToken session,
                                                  EBPInstanceReference activity)
                                           throws ServiceNotKnownException
        Description copied from interface: RemoteGUIManager
        Registers this GUI manager as state listener for the designated activity and returns the URIs of the (local) notification service that needs to be registered at the SynchronousActivityStarting.
        Specified by:
        getActivityStateListenerURIs in interface RemoteGUIManager
        Parameters:
        session - The session which is used to check for access rights on this method.
        activity - The activity for which to receive activity state notifications.
        Returns:
        The URIs of the (local) notification service to be registered at the SynchronousActivityStarting.
        Throws:
        ServiceNotKnownException - If the notification service cannot be retrieved, a ServiceNotKnownException will be thrown.
      • activitySuspended

        public void activitySuspended​(EBPInstanceReference activity,
                                      String sessionID)
        Description copied from interface: ActivityStateNotification
        Notifies that the designated activity in the designated execution session has been suspended normally. There may be an resume and further notifications afterwards.
        Specified by:
        activitySuspended in interface ActivityStateNotification
        Parameters:
        activity - The activity that has been suspended normally.
        sessionID - The ID of the execution session of the suspended activity.
      • activitySuspended

        public void activitySuspended​(EBPInstanceReference activity,
                                      String sessionID,
                                      long timeout)
        Description copied from interface: ActivityStateNotification
        Notifies that the designated activity in the designated execution session has been suspended and needs to be resumed after the designated timeout. Usually this will be started by a ResumingRuntimeManager and thus there will be a resume and further notifications afterwards.
        Specified by:
        activitySuspended in interface ActivityStateNotification
        Parameters:
        activity - The activity that has been suspended normally.
        sessionID - The ID of the execution session of the suspended activity.
        timeout - The time period (in milliseconds) when the suspended application wants to be resumed automatically.
      • activitySignalled

        public void activitySignalled​(EBPInstanceReference activity,
                                      String sessionID,
                                      int signal)
        Description copied from interface: ActivityStateNotification
        Notifies that the designated activity in the designated execution session has terminated with the designated signal.
        Specified by:
        activitySignalled in interface ActivityStateNotification
        Parameters:
        activity - The activity that has been terminated.
        sessionID - The ID of the execution session of the signalled activity.
        signal - The signal that led to the termination of the activity.
      • activityFailed

        public void activityFailed​(EBPInstanceReference activity,
                                   String sessionID,
                                   String errorMessage,
                                   String state,
                                   long errorCode)
        Description copied from interface: ActivityStateNotification
        Notifies that the designated activity in the designated execution session has failed with the designated additional failure information.
        Specified by:
        activityFailed in interface ActivityStateNotification
        Parameters:
        activity - The activity that has failed.
        sessionID - The ID of the execution session of the failed activity.
        errorMessage - The error message to be interpreted by a user or by a failure handling routine.
        state - Arbitrary state information specific to the instance, comparable to the vendor code in SQLException.
        errorCode - The error code specifying the type of error.
      • closeGUIContext

        protected void closeGUIContext​(EBPInstanceReference activity,
                                       String sessionID)
        Closes the local GUI context of the designated activity. This is usually done after a termination notification has been received by this ActivityStateNotification. The GUI context will be removed so that it will not be reached by any further notifications for the same activity.
        Parameters:
        activity - The activity of which to close the local GUI context.
        sessionID - The ID of the execution session of the activity of which to close the local GUI context.
      • terminateRemoteExecution

        public ProcessConstants.NodeState terminateRemoteExecution​(SessionToken session,
                                                                   EBPInstanceReference activity,
                                                                   String sessionID)
                                                            throws ServiceNotKnownException
        Terminates the (remote) execution of the designated activity, that is, the execution control manager of the designated activity is instructed appropriately. This can be used by subclasses to forward the closing of a GUIContext.
        The component is tried to terminate based on its execution control properties. If it does not respond to termination requests, an escalation takes place which forces the termination. This can even abort the component.

        If the designated activity (and session ID) is not known by this RemoteGUIManager this will be logged but no further action will be taken. Note that this does not prevent the activity state notification! This should occur as consequence of this termination request and then close the local GUI context. If the GUI context has already been closed before or right after calling this method, it will probably be called twice.

        Parameters:
        session - The session which is used to check for access rights on this method.
        activity - The activity which to terminate.
        sessionID - The ID of the execution session of the activity to terminate.
        Returns:
        The state of the node of the designated activity after the activity has been terminated. If it is not known by this RemoteGUIManager or the corresponding runtime manager, null will be returned.
        Throws:
        ServiceNotKnownException - If the execution control manager/runtime manager of the designated activity cannot be retrieved, a ServiceNotKnownException will be thrown.
      • getExecutionControlManager

        protected ExecutionControlManager getExecutionControlManager​(SessionToken session,
                                                                     EBPInstanceReference activity)
                                                              throws ServiceNotKnownException
        Gets the execution control manager for the designated activity, that is, the execution control manager of the runtime manager of the designated activity.
        Parameters:
        session - The session which is used to check for access rights on this method.
        activity - The activity for which to retrieve the execution control manager.
        Returns:
        The execution control manager for the designated activity.
        Throws:
        ServiceNotKnownException - If the execution control manager/runtime manager of the designated activity cannot be retrieved, a ServiceNotKnownException will be thrown.