Package org.apache.qpid.protonj2.engine
Interface EngineHandler
-
- All Known Implementing Classes:
ProtonFrameDecodingHandler
,ProtonFrameEncodingHandler
,ProtonFrameLoggingHandler
,ProtonPerformativeHandler
,ProtonSaslHandler
public interface EngineHandler
Listen for events generated from the Engine
-
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default void
engineFailed(EngineHandlerContext context, EngineFailedException failure)
Called when the engine has transitioned to a failed state and cannot process any additional input or output.default void
engineStarting(EngineHandlerContext context)
Called when the engine is started to allow handlers to prepare for use based on the configuration state at start of the engine.default void
handleEngineStateChanged(EngineHandlerContext context)
Called when the engine state has changed and handlers may need to update their internal state to respond to the change or prompt some new work based on the change, e.g state changes from not writable to writable.default void
handlerAdded(EngineHandlerContext context)
Called when the handler is successfully added to theEnginePipeline
and will later be initialized before use.default void
handleRead(EngineHandlerContext context, ProtonBuffer buffer)
Handle the read of new incoming bytes from a remote sender.default void
handleRead(EngineHandlerContext context, HeaderEnvelope header)
Handle the receipt of an incoming AMQP Header or SASL Header based on the current state of this handler.default void
handleRead(EngineHandlerContext context, IncomingAMQPEnvelope envelope)
Handle the receipt of an incoming AMQP envelope based on the current state of this handler.default void
handleRead(EngineHandlerContext context, SASLEnvelope envelope)
Handle the receipt of an incoming SASL performative based on the current state of this handler.default void
handlerRemoved(EngineHandlerContext context)
Called when the handler is successfully removed to theEnginePipeline
.default void
handleWrite(EngineHandlerContext context, ProtonBuffer buffer, Runnable ioComplete)
Writes the given bytes to the output target or if no handler in the pipeline handles this calls the registered output handler of the parent Engine instance.default void
handleWrite(EngineHandlerContext context, HeaderEnvelope envelope)
Handles write of AMQPHeader either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
default void
handleWrite(EngineHandlerContext context, OutgoingAMQPEnvelope envelope)
Handles write of AMQP performative envelope either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
default void
handleWrite(EngineHandlerContext context, SASLEnvelope envelope)
Handles write of SaslPerformative either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
-
-
-
Method Detail
-
handlerAdded
default void handlerAdded(EngineHandlerContext context)
Called when the handler is successfully added to theEnginePipeline
and will later be initialized before use.- Parameters:
context
- The context that is assigned to this handler.
-
handlerRemoved
default void handlerRemoved(EngineHandlerContext context)
Called when the handler is successfully removed to theEnginePipeline
.- Parameters:
context
- The context that is assigned to this handler.
-
engineStarting
default void engineStarting(EngineHandlerContext context)
Called when the engine is started to allow handlers to prepare for use based on the configuration state at start of the engine. A handler can fail the engine start by throwing an exception.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handler
-
handleEngineStateChanged
default void handleEngineStateChanged(EngineHandlerContext context)
Called when the engine state has changed and handlers may need to update their internal state to respond to the change or prompt some new work based on the change, e.g state changes from not writable to writable.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handler
-
engineFailed
default void engineFailed(EngineHandlerContext context, EngineFailedException failure)
Called when the engine has transitioned to a failed state and cannot process any additional input or output. The handler can free and resources used for normal operations at this point as the engine is now considered shutdown.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handlerfailure
- The failure that triggered the engine to cease operations.
-
handleRead
default void handleRead(EngineHandlerContext context, ProtonBuffer buffer)
Handle the read of new incoming bytes from a remote sender. The handler should generally decode these bytes into an AMQP Performative or SASL Performative based on the current state of the connection and the handler in question.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handlerbuffer
- The buffer containing the bytes that the engine handler should decode.
-
handleRead
default void handleRead(EngineHandlerContext context, HeaderEnvelope header)
Handle the receipt of an incoming AMQP Header or SASL Header based on the current state of this handler.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handlerheader
- The AMQP Header envelope that wraps the received header instance.
-
handleRead
default void handleRead(EngineHandlerContext context, SASLEnvelope envelope)
Handle the receipt of an incoming SASL performative based on the current state of this handler.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handlerenvelope
- The SASL envelope that wraps the receivedSaslPerformative
.
-
handleRead
default void handleRead(EngineHandlerContext context, IncomingAMQPEnvelope envelope)
Handle the receipt of an incoming AMQP envelope based on the current state of this handler.- Parameters:
context
- The context for this handler which can be used to forward the event to the next handlerenvelope
- The AMQP envelope that wraps the receivedPerformative
.
-
handleWrite
default void handleWrite(EngineHandlerContext context, HeaderEnvelope envelope)
Handles write of AMQPHeader either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
- Parameters:
context
- TheEngineHandlerContext
associated with thisEngineHandler
instance.envelope
- TheHeaderEnvelope
instance to write.
-
handleWrite
default void handleWrite(EngineHandlerContext context, OutgoingAMQPEnvelope envelope)
Handles write of AMQP performative envelope either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
- Parameters:
context
- TheEngineHandlerContext
associated with thisEngineHandler
instance.envelope
- TheOutgoingAMQPEnvelope
instance to write.
-
handleWrite
default void handleWrite(EngineHandlerContext context, SASLEnvelope envelope)
Handles write of SaslPerformative either by directly writing it to the output target or by converting it to bytes and firing a write using theProtonBuffer
based API inEngineHandlerContext.fireWrite(ProtonBuffer, Runnable)
- Parameters:
context
- TheEngineHandlerContext
associated with thisEngineHandler
instance.envelope
- TheSASLEnvelope
instance to write.
-
handleWrite
default void handleWrite(EngineHandlerContext context, ProtonBuffer buffer, Runnable ioComplete)
Writes the given bytes to the output target or if no handler in the pipeline handles this calls the registered output handler of the parent Engine instance. If not output handler is found or not handler in the output chain consumes this write the Engine will be failed as an output sink is required for all low level engine writes.- Parameters:
context
- TheEngineHandlerContext
associated with thisEngineHandler
instance.buffer
- TheProtonBuffer
whose payload is to be written to the output target.ioComplete
- ARunnable
callback that indicates that the I/O operation is complete
-
-