Class AbstractGUIManager
- java.lang.Object
-
- de.aristaflow.adept2.base.service.AbstractADEPT2Service
-
- de.aristaflow.adept2.core.runtimemanager.gui.AbstractGUIManager
-
- All Implemented Interfaces:
ADEPT2Service
,LogService
,ServiceThreadHandling
,ActivityStateNotification
,GUIManager
,RemoteGUIManager
- Direct Known Subclasses:
NullGUIManager
,RemoteHTMLGUIManager
@ConfigurationDescription(properties=) public abstract class AbstractGUIManager extends AbstractADEPT2Service implements RemoteGUIManager
This class provides the basic means for aRemoteGUIManager
which is the interaction between remotely executed component to GUI context (viaActivityStateNotification
and vice versa (viaterminateRemoteExecution(SessionToken, EBPInstanceReference, String)
). As soon as a termination notification is received for an activity, the corresponding local GUI context will be closed. If closing is initiated by the local GUI context, subclasses of this GUI manager or implementations of the local GUI context should useterminateRemoteExecution(SessionToken, EBPInstanceReference, String)
which terminates the remote execution under all circumstances using several escalation steps in case the remotely executed component does not respond.For simpler migration from
GUIManager
toRemoteGUIManager
this class provides a convenience implementation forgetLocalForRemoteGuiContext(SessionToken, TransferableGUIContext)
. However, this is rather limited. It just forwards the data from the transferred GUI context to (GUIManager.getGUIContext(SessionToken, ActivityInstance, EBPInstanceReference, String, ExecutionContext, ExecutionControlManager, Thread)
). The thread will always benull
and the GUI context ID in the activity instance will be exchanged by the ID of the transferred GUI context. This ID then no longer specifies the ID of the requested GUI context but that of the provided transferred GUI context! Usually, the additional information provided by the (subclass of the) transferable GUI context is required and thus simple forwarding is not sufficient at all.Besides this class also provides a convenience method for
GUIManager2
that is creating a GUI context with the information about whether the activity is resumed. The implementation just ignores this information and forwards the call to the creating without this information.- See Also:
TerminationExecutor
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
AbstractADEPT2Service.ActiveSessions
-
-
Field Summary
Fields Modifier and Type Field Description static String
CONF_TERMINATION_TIMEOUT
The key for the configuration value that specifies the total time in milliseconds to wait for the component to terminate.protected 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.protected 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.protected Map<EBPInstanceReference,Triple<LocalActivityStateNotifier,URI[],SessionToken>>
listeners
The activity state listeners this GUI manager is registered at for the corresponding activities.protected Map<Closeable,?>
localGuiContexts
The GUI contexts created locally.protected long
TERMINATION_TIMEOUT
The total time in milliseconds to wait for the termination of a component.-
Fields inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
CONF_CSV_LOGGING, configuration, logger, registry, runtimeRequiredServices, startupRequiredServices
-
-
Constructor Summary
Constructors Constructor Description AbstractGUIManager(org.apache.commons.configuration2.Configuration configuration, Registry registry)
Creates a new GUI manager providing the basic means for aRemoteGUIManager
.AbstractGUIManager(org.apache.commons.configuration2.Configuration configuration, Registry registry, String[] startupRequiredServices, String[] runtimeRequiredServices)
Creates a new GUI manager providing the basic means for aRemoteGUIManager
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activityClosed(EBPInstanceReference activity, String sessionID)
Notifies that the designated activity in the designated execution session has been closed.void
activityFailed(EBPInstanceReference activity, String sessionID, String errorMessage, String state, long errorCode)
Notifies that the designated activity in the designated execution session has failed with the designated additional failure information.void
activityReset(EBPInstanceReference activity, String sessionID)
Notifies that the designated activity in the designated execution session has been reset.void
activityResumed(EBPInstanceReference activity, String sessionID, URI[] newListener)
Notifies that the designated activity has been resumed.void
activitySignalled(EBPInstanceReference activity, String sessionID, int signal)
Notifies that the designated activity in the designated execution session has terminated with the designated signal.void
activitySuspended(EBPInstanceReference activity, String sessionID)
Notifies that the designated activity in the designated execution session has been suspended normally.void
activitySuspended(EBPInstanceReference activity, String sessionID, long timeout)
Notifies that the designated activity in the designated execution session has been suspended and needs to be resumed after the designated timeout.protected void
closeGUIContext(EBPInstanceReference activity, String sessionID)
Closes the local GUI context of the designated activity.GUIContext
createGUIContext(SessionToken session, de.aristaflow.adept2.model.runtimeenvironment.guicontext.TransferableGUIContext trCtxt, ExecutionControlManager ecm)
Creates a GUI context for the designatedTransferrableGUIContext
and the designatedExecutionControlManager
.URI[]
getActivityStateListenerURIs(SessionToken session, EBPInstanceReference activity)
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 theSynchronousActivityStarting
.protected ExecutionControlManager
getExecutionControlManager(SessionToken session, EBPInstanceReference activity)
Gets the execution control manager for the designated activity, that is, the execution control manager of the runtime manager of the designated activity.GUIContext
getLocalForRemoteGuiContext(SessionToken session, de.aristaflow.adept2.model.runtimeenvironment.guicontext.TransferableGUIContext transfrdCtxt)
Gets an appropriate GUI context for the designatedTransferableGUIContext
.void
shutdown(boolean emergency)
This implementation waits 10 seconds in case of an emergency and otherwise indefinitely for the termination of the active sessions.ProcessConstants.NodeState
terminateRemoteExecution(SessionToken session, EBPInstanceReference activity, String sessionID)
Terminates the (remote) execution of the designated activity, that is, the execution control manager of the designated activity is instructed appropriately.-
Methods inherited from class de.aristaflow.adept2.base.service.AbstractADEPT2Service
_sessionActive, _sessionFinished, activeOrInvalidServiceStateException, changeLogContext, changeLogContext, changeLogContext, consoleLog, csvLoggingEnabled, getClassSpecificJulLogger, getDependencyRegistry, getLocalUris, getLogger, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, getUserCredentials, init, isActive, isSessionActive, isShutdown, logMethodEntry, logMethodEntry, logMethodEntry, logMethodExit, logMethodExit, ping, preShutdown, privilegeSession, privilegeThread, revertLogContextChanges, sessionActive, sessionActive, sessionActive, sessionActive, sessionFinished, sessionFinished, signalShutdown, signalStart, start, unprivilegeThread
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.aristaflow.adept2.base.service.ADEPT2Service
getLocalUris, getRelease, getRuntimeRequiredServices, getServiceInstanceName, getStartupRequiredServices, getURIs, init, ping, preShutdown, start
-
Methods inherited from interface de.aristaflow.adept2.core.runtimemanager.gui.GUIManager
getGUIContext
-
-
-
-
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 viaguiContexts
.
-
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 viaguiContexts
.
-
-
Constructor Detail
-
AbstractGUIManager
public AbstractGUIManager(org.apache.commons.configuration2.Configuration configuration, Registry registry)
Creates a new GUI manager providing the basic means for aRemoteGUIManager
. 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 aRemoteGUIManager
. 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 (inAbstractADEPT2Service.init(URI[], URI[])
andAbstractADEPT2Service.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 interfaceADEPT2Service
- Overrides:
shutdown
in classAbstractADEPT2Service
- 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 designatedTransferableGUIContext
. The created context represents the designated context locally and can be any arbitrary appropriate GUI context. This can be the same GUI context provided byGUIManager
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 interfaceRemoteGUIManager
- 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 theRemoteGUIManager
integrates theGUIContext
in the local GUI and handles closing it. - Throws:
GUIContextUnavailableException
- If no GUI context can be created for the designatedTransferableGUIContext
, aGUIContextUnavailableException
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 designatedTransferrableGUIContext
and the designatedExecutionControlManager
. This is similar togetLocalForRemoteGuiContext(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 theActivityStateNotification
.- 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 thisRemoteGUIManager
already handles closing and displaying of the created localGUIContext
. - Throws:
GUIContextUnavailableException
- If no GUI context can be created for the designatedTransferableGUIContext
, aGUIContextUnavailableException
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 theSynchronousActivityStarting
.- Specified by:
getActivityStateListenerURIs
in interfaceRemoteGUIManager
- 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, aServiceNotKnownException
will be thrown.
-
activityClosed
public void activityClosed(EBPInstanceReference activity, String sessionID)
Description copied from interface:ActivityStateNotification
Notifies that the designated activity in the designated execution session has been closed.- Specified by:
activityClosed
in interfaceActivityStateNotification
- Parameters:
activity
- The activity that has been closed.sessionID
- The ID of the execution session of the closed activity.
-
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 interfaceActivityStateNotification
- 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 aResumingRuntimeManager
and thus there will be a resume and further notifications afterwards.- Specified by:
activitySuspended
in interfaceActivityStateNotification
- 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.
-
activityResumed
public void activityResumed(EBPInstanceReference activity, String sessionID, URI[] newListener)
Description copied from interface:ActivityStateNotification
Notifies that the designated activity has been resumed. This will only be sent if the activity is resumed on the very same runtime manager.- Specified by:
activityResumed
in interfaceActivityStateNotification
- Parameters:
activity
- The activity that has been suspended normally.sessionID
- The ID of the new execution session of the resumed activity.newListener
- The URIs of the listener that has been registered when resuming ornull
in case no listener has been registered when resuming. If a new listener has been registered, this listener will not be notified any more.- See Also:
SynchronousActivityStarting.resumeActivitySynchronously(de.aristaflow.adept2.base.sessionmanagement.SessionToken, EBPInstanceReference)
-
activityReset
public void activityReset(EBPInstanceReference activity, String sessionID)
Description copied from interface:ActivityStateNotification
Notifies that the designated activity in the designated execution session has been reset.- Specified by:
activityReset
in interfaceActivityStateNotification
- Parameters:
activity
- The activity that has been reset.sessionID
- The ID of the execution session of the reset activity.
-
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 interfaceActivityStateNotification
- 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 interfaceActivityStateNotification
- 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 thisActivityStateNotification
. 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 aGUIContext
.
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, aServiceNotKnownException
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, aServiceNotKnownException
will be thrown.
-
-