Class CommunicationStackTerminator<I,O>
- Type Parameters:
I- The type of the input this communication stack element handles.O- The type of the value this communication stack element returns.
- All Implemented Interfaces:
CommunicationStack<I,O>
CommunicationStack. It represents the last step within a
request and response handling strategy.
It provides a default shutdown behaviour. That is: If a shutdown is initiated
by shutdown(), all active threads are
allowed to finish their job, but no other requests are accepted any more.
Attempts are answered with an appropriate
CommunicationStackException.
Concrete communication stack terminators must implement
processInputAndReturn(URI, Object) and
shutdownStackLayer().
- Author:
- Markus Lauer, Ulrich Kreher
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LoggerThe logger.protected final int[]Object for sync purposes. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCommunicationStackTerminator(LogService logService) Initialises the instance variables appropriately. -
Method Summary
Modifier and TypeMethodDescriptionfinal OHandles the request and returns the response.protected abstract OprocessInputAndReturn(URI remoteIdentifier, I input) Transforms the given input of typeIaccordingly to the functionality this communication stack element is designed for and returns the result of typeOof this transformation process.final voidshutdown()Initiate the shutdown of this communication stack layer.protected abstract voidShuts down this CommunicationStackLayer.
-
Field Details
-
logger
The logger. -
syncObject
protected final int[] syncObjectObject for sync purposes.
-
-
Constructor Details
-
CommunicationStackTerminator
Initialises the instance variables appropriately.- Parameters:
logService- The log service to retrieve the logger from.
-
-
Method Details
-
process
public final O process(URI remoteIdentifier, I input) throws de.aristaflow.adept2.model.communication.CommunicationStackException Description copied from interface:CommunicationStackHandles the request and returns the response.It accepts the request as input, modifies it accordingly to the functionality this layer is meant for and delegates it to the lower communication stack layer. Beside it modifies the response returned by the lower communication stack layer and returns the result.
If this component is instructed to shutdown by calling
CommunicationStack.shutdown()this method returns immediately by throwing a appropriateCommunicationStackException.- Specified by:
processin interfaceCommunicationStack<I,O> - Parameters:
remoteIdentifier- The identifier of the object/service the request is targeted at. This may benullin case the information is not available for the communication service. This information may also be provided by the input parameter (for instance in anInvocationMessage.input- The request in the form of what this layer expects.- Returns:
- The response
- Throws:
de.aristaflow.adept2.model.communication.CommunicationStackException- If there are problems processing the request, aCommunicationStackExceptionwill be thrown. This may encapsulate any occurred exception.
-
processInputAndReturn
protected abstract O processInputAndReturn(URI remoteIdentifier, I input) throws de.aristaflow.adept2.model.communication.CommunicationStackException Transforms the given input of typeIaccordingly to the functionality this communication stack element is designed for and returns the result of typeOof this transformation process.Hint: It is ensured that this method is not called any more after the shutdown was initiated by
shutdown(). The attempt to call after a requested shutdown is answered with an appropriateCommunicationStackException.- Parameters:
remoteIdentifier- The URI identifying the object this communication call is meant for.input- The input that should be transformed.- Returns:
- The result of this transformation process.
- Throws:
de.aristaflow.adept2.model.communication.CommunicationStackException- If there are problems processing the input, aCommunicationStackExceptionwill be thrown. This may encapsulate any occurred exception.
-
shutdownStackLayer
protected abstract void shutdownStackLayer()Shuts down this CommunicationStackLayer.This method should be overwritten for communication stack layer depended shutdown behaviour.
This method is called not until all active requests are handled. Further requests are refused.
-
shutdown
public final void shutdown()Initiate the shutdown of this communication stack layer.It ensures that no other requests are handled any more and that this stack layer shuts down as soon as there are no more running jobs.
- Specified by:
shutdownin interfaceCommunicationStack<I,O> - See Also:
-