Interface StateHandler
-
- All Known Implementing Classes:
ClientEvaluate,ClientInit,ClientListenChoice,ClientSend,ClientServerWait,CloseDevA,CloseDevB,CmiInitStart,ConnectionDataExchange,ConnectionDataPreparation,HelloOk,InitListen,PendingInit,PendingListen,PendingTimeout,PinOk,ProtHOk,ReadyInit,ReadyListen,ReadyTimeout,ServerEvaluate,ServerInit,ServerListenConfirm,ServerListenProposal,Timeout
public interface StateHandlerAStateHandleris a collection of event handlers associated with a given SHIP connection state. Its methods will be called by the state machine if it is in the appropriate state and the corresponding event occurs.Any class that implements this interface should be totally stateless, i.e. should have no non-final fields and no fields that contain mutable objects. Instances also should not directly start timers, communicate over the network, etc. Instead, these should be done via the
StateHandlerContextpassed to each method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceStateHandler.HandlesIndicates which state(s) this handler takes care of.static interfaceStateHandler.UsesExtraDataIndicates that this state needs some extra data of the specified type.
-
Field Summary
Fields Modifier and Type Field Description static org.slf4j.LoggerLOGGERstatic StateHandlerUNIMPLEMENTEDPlaceholder value.
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default java.lang.Class<?>getExtraDataType()default voidonBeforeExit(State pendingNext, StateHandlerContext context)Called just before the state machine transitions to a next state.default voidonEntered(State previous, StateHandlerContext context)Called when the state machine enters this state.default voidonMessageReceived(StateHandlerContext context)Called when a message was received from the communication partner.default voidonTimeoutExpired(SpecifiedTimeout kind, StateHandlerContext context)Called when a previously started timeout expires.default voidprocessMessage(byte[] msg, StateHandlerContext context)Called afterStateHandlerContext.processMessage().
-
-
-
Field Detail
-
LOGGER
static final org.slf4j.Logger LOGGER
-
UNIMPLEMENTED
static final StateHandler UNIMPLEMENTED
Placeholder value.
-
-
Method Detail
-
onEntered
default void onEntered(State previous, StateHandlerContext context)
Called when the state machine enters this state.Invoking
StateHandlerContext.transitionTo(State)inside this method will defer the transition untilonEnteredfinishes.- Parameters:
previous- the previous statecontext- the execution context
-
onBeforeExit
default void onBeforeExit(State pendingNext, StateHandlerContext context)
Called just before the state machine transitions to a next state.Invoking
StateHandlerContext.transitionTo(State)inside this method is an error.- Parameters:
pendingNext- the state that will be enteredcontext- the execution context
-
onMessageReceived
default void onMessageReceived(StateHandlerContext context)
Called when a message was received from the communication partner.If you wish to evaluate the message, the returned command should contain
StateHandlerContext.processMessage(), which will causeprocessMessage(byte[], StateHandlerContext)to be called with the message contents.- Parameters:
context- the execution context
-
processMessage
default void processMessage(byte[] msg, StateHandlerContext context)Called afterStateHandlerContext.processMessage().- Parameters:
msg- the raw message bytescontext- the execution context
-
onTimeoutExpired
default void onTimeoutExpired(SpecifiedTimeout kind, StateHandlerContext context)
Called when a previously started timeout expires.- Parameters:
kind- which timeout expired
-
getExtraDataType
default java.lang.Class<?> getExtraDataType()
-
-