Class ProtonEnginePipelineProxy
- java.lang.Object
-
- org.apache.qpid.protonj2.engine.impl.ProtonEnginePipelineProxy
-
- All Implemented Interfaces:
EnginePipeline
public class ProtonEnginePipelineProxy extends Object implements EnginePipeline
Wrapper around the internalProtonEnginePipeline
used to present a guarded pipeline to the outside world when theEngine.pipeline()
method is used to gain access to the pipeline. The proxy will ensure that any read or write calls enforceEngine
state such as not started and shutdown.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ProtonEnginePipelineProxy
addFirst(String name, EngineHandler handler)
Adds the given handler to the front of the pipeline with the given name stored for later lookup or remove operations.ProtonEnginePipelineProxy
addLast(String name, EngineHandler handler)
Adds the given handler to the end of the pipeline with the given name stored for later lookup or remove operations.ProtonEngine
engine()
EngineHandler
find(String name)
Finds and returns first handler that is found in the pipeline that matches the given name.ProtonEnginePipelineProxy
fireEngineStarting()
Fires an engine starting event to each handler in the pipeline.ProtonEnginePipelineProxy
fireEngineStateChanged()
Fires an engine state changed event to each handler in the pipeline.ProtonEnginePipelineProxy
fireFailed(EngineFailedException e)
Fires an engine failed event into eachEngineHandler
in the pipeline indicating that the engine is now failed and should not accept or produce new work.ProtonEnginePipelineProxy
fireRead(ProtonBuffer input)
Fires a read event consisting of the givenProtonBuffer
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.ProtonEnginePipelineProxy
fireRead(HeaderEnvelope header)
Fires a read event consisting of the givenHeaderEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.ProtonEnginePipelineProxy
fireRead(IncomingAMQPEnvelope envelope)
Fires a read event consisting of the givenIncomingAMQPEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.ProtonEnginePipelineProxy
fireRead(SASLEnvelope envelope)
Fires a read event consisting of the givenSASLEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed.ProtonEnginePipelineProxy
fireWrite(ProtonBuffer buffer, Runnable ioComplete)
Fires a write event consisting of the givenProtonBuffer
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.ProtonEnginePipelineProxy
fireWrite(HeaderEnvelope envelope)
Fires a write event consisting of the givenHeaderEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.ProtonEnginePipelineProxy
fireWrite(OutgoingAMQPEnvelope envelope)
Fires a write event consisting of the givenOutgoingAMQPEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.ProtonEnginePipelineProxy
fireWrite(SASLEnvelope envelope)
Fires a write event consisting of the givenSASLEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed.EngineHandler
first()
EngineHandlerContext
firstContext()
EngineHandler
last()
EngineHandlerContext
lastContext()
ProtonEnginePipelineProxy
remove(String name)
Removes the first handler that is found in the pipeline that matches the given name.EnginePipeline
remove(EngineHandler handler)
Removes the givenEngineHandler
from the pipeline if present.ProtonEnginePipelineProxy
removeFirst()
Removes the firstEngineHandler
in the pipeline.ProtonEnginePipelineProxy
removeLast()
Removes the lastEngineHandler
in the pipeline.
-
-
-
Method Detail
-
engine
public ProtonEngine engine()
- Specified by:
engine
in interfaceEnginePipeline
- Returns:
- the
Engine
that this pipeline is linked to.
-
addFirst
public ProtonEnginePipelineProxy addFirst(String name, EngineHandler handler)
Description copied from interface:EnginePipeline
Adds the given handler to the front of the pipeline with the given name stored for later lookup or remove operations. It is not mandatory that each handler have unique names although if handlers do share a name theEnginePipeline.remove(String)
method will only remove them one at a time starting from the first in the pipeline.- Specified by:
addFirst
in interfaceEnginePipeline
- Parameters:
name
- The name to assign to the handlerhandler
- TheEngineHandler
to add into the pipeline.- Returns:
- this
EnginePipeline
.
-
addLast
public ProtonEnginePipelineProxy addLast(String name, EngineHandler handler)
Description copied from interface:EnginePipeline
Adds the given handler to the end of the pipeline with the given name stored for later lookup or remove operations. It is not mandatory that each handler have unique names although if handlers do share a name theEnginePipeline.remove(String)
method will only remove them one at a time starting from the first in the pipeline.- Specified by:
addLast
in interfaceEnginePipeline
- Parameters:
name
- The name to assign to the handlerhandler
- TheEngineHandler
to add into the pipeline.- Returns:
- this
EnginePipeline
.
-
removeFirst
public ProtonEnginePipelineProxy removeFirst()
Description copied from interface:EnginePipeline
Removes the firstEngineHandler
in the pipeline.- Specified by:
removeFirst
in interfaceEnginePipeline
- Returns:
- this
EnginePipeline
.
-
removeLast
public ProtonEnginePipelineProxy removeLast()
Description copied from interface:EnginePipeline
Removes the lastEngineHandler
in the pipeline.- Specified by:
removeLast
in interfaceEnginePipeline
- Returns:
- this
EnginePipeline
.
-
remove
public ProtonEnginePipelineProxy remove(String name)
Description copied from interface:EnginePipeline
Removes the first handler that is found in the pipeline that matches the given name.- Specified by:
remove
in interfaceEnginePipeline
- Parameters:
name
- The name to search for in the pipeline moving from first to last.- Returns:
- this
EnginePipeline
.
-
remove
public EnginePipeline remove(EngineHandler handler)
Description copied from interface:EnginePipeline
Removes the givenEngineHandler
from the pipeline if present.- Specified by:
remove
in interfaceEnginePipeline
- Parameters:
handler
- The handler instance to remove if contained in the pipeline.- Returns:
- this
EnginePipeline
.
-
find
public EngineHandler find(String name)
Description copied from interface:EnginePipeline
Finds and returns first handler that is found in the pipeline that matches the given name.- Specified by:
find
in interfaceEnginePipeline
- Parameters:
name
- The name to search for in the pipeline moving from first to last.- Returns:
- the
EngineHandler
that matches the given name or null if none in the pipeline.
-
first
public EngineHandler first()
- Specified by:
first
in interfaceEnginePipeline
- Returns:
- the first
EngineHandler
in the pipeline or null if empty.
-
last
public EngineHandler last()
- Specified by:
last
in interfaceEnginePipeline
- Returns:
- the last
EngineHandler
in the pipeline or null if empty.
-
firstContext
public EngineHandlerContext firstContext()
- Specified by:
firstContext
in interfaceEnginePipeline
- Returns:
- the first
EngineHandlerContext
in the pipeline or null if empty.
-
lastContext
public EngineHandlerContext lastContext()
- Specified by:
lastContext
in interfaceEnginePipeline
- Returns:
- the last
EngineHandlerContext
in the pipeline or null if empty.
-
fireEngineStarting
public ProtonEnginePipelineProxy fireEngineStarting()
Description copied from interface:EnginePipeline
Fires an engine starting event to each handler in the pipeline. Should be used by the engine implementation to signal its handlers that they should initialize.- Specified by:
fireEngineStarting
in interfaceEnginePipeline
- Returns:
- this
EnginePipeline
.
-
fireEngineStateChanged
public ProtonEnginePipelineProxy fireEngineStateChanged()
Description copied from interface:EnginePipeline
Fires an engine state changed event to each handler in the pipeline. Should be used by the engine implementation to signal its handlers that they should respond to the new engine state, e.g. the engine failed or was shutdown.- Specified by:
fireEngineStateChanged
in interfaceEnginePipeline
- Returns:
- this
EnginePipeline
.
-
fireFailed
public ProtonEnginePipelineProxy fireFailed(EngineFailedException e)
Description copied from interface:EnginePipeline
Fires an engine failed event into eachEngineHandler
in the pipeline indicating that the engine is now failed and should not accept or produce new work.- Specified by:
fireFailed
in interfaceEnginePipeline
- Parameters:
e
- The cause of the engine failure.- Returns:
- this
EnginePipeline
.
-
fireRead
public ProtonEnginePipelineProxy fireRead(ProtonBuffer input)
Description copied from interface:EnginePipeline
Fires a read event consisting of the givenProtonBuffer
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Specified by:
fireRead
in interfaceEnginePipeline
- Parameters:
input
- TheProtonBuffer
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
public ProtonEnginePipelineProxy fireRead(HeaderEnvelope header)
Description copied from interface:EnginePipeline
Fires a read event consisting of the givenHeaderEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Specified by:
fireRead
in interfaceEnginePipeline
- Parameters:
header
- TheHeaderEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
public ProtonEnginePipelineProxy fireRead(SASLEnvelope envelope)
Description copied from interface:EnginePipeline
Fires a read event consisting of the givenSASLEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Specified by:
fireRead
in interfaceEnginePipeline
- Parameters:
envelope
- TheSASLEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireRead
public ProtonEnginePipelineProxy fireRead(IncomingAMQPEnvelope envelope)
Description copied from interface:EnginePipeline
Fires a read event consisting of the givenIncomingAMQPEnvelope
into the pipeline starting from the lastEngineHandler
in the pipeline and moving through each until the incoming work is fully processed. If the read events reaches the head of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Specified by:
fireRead
in interfaceEnginePipeline
- Parameters:
envelope
- TheIncomingAMQPEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
public ProtonEnginePipelineProxy fireWrite(HeaderEnvelope envelope)
Description copied from interface:EnginePipeline
Fires a write event consisting of the givenHeaderEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenHeaderEnvelope
will have been written or if held for later the object must be copied.- Specified by:
fireWrite
in interfaceEnginePipeline
- Parameters:
envelope
- TheHeaderEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
public ProtonEnginePipelineProxy fireWrite(OutgoingAMQPEnvelope envelope)
Description copied from interface:EnginePipeline
Fires a write event consisting of the givenOutgoingAMQPEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenOutgoingAMQPEnvelope
will have been written or if held for later the object must be copied. When the payload given exceeds the maximum allowed frame size when encoded into an outbound frame the encoding handler should either throw an error in the case that the performative being written cannot truncate its payload or should invoke the payload to large handler of the envelope before re-encoding the outbound performative and truncating the payload.- Specified by:
fireWrite
in interfaceEnginePipeline
- Parameters:
envelope
- TheOutgoingAMQPEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
public ProtonEnginePipelineProxy fireWrite(SASLEnvelope envelope)
Description copied from interface:EnginePipeline
Fires a write event consisting of the givenSASLEnvelope
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state. It is expected that after the fire write method returns the givenSASLEnvelope
will have been written or if held for later the object must be copied.- Specified by:
fireWrite
in interfaceEnginePipeline
- Parameters:
envelope
- TheSASLEnvelope
to inject into the engine pipeline.- Returns:
- this
EnginePipeline
.
-
fireWrite
public ProtonEnginePipelineProxy fireWrite(ProtonBuffer buffer, Runnable ioComplete)
Description copied from interface:EnginePipeline
Fires a write event consisting of the givenProtonBuffer
into the pipeline starting from the firstEngineHandler
in the pipeline and moving through each until the outgoing work is fully processed. If the write events reaches the tail of the pipeline and is not handled by any handler an error is thrown and the engine should enter the failed state.- Specified by:
fireWrite
in interfaceEnginePipeline
- Parameters:
buffer
- TheProtonBuffer
to inject into the engine pipeline.ioComplete
- An optional callback that should be signaled when the underlying transport complete the I/O write- Returns:
- this
EnginePipeline
.
-
-