Package com.lucimber.dbus.connection
Class DefaultPipeline
java.lang.Object
com.lucimber.dbus.connection.DefaultPipeline
- All Implemented Interfaces:
InboundPropagator
,OutboundPropagator
,Pipeline
A thread-safe pipeline of
OutboundHandler
instances associated with a Connection
.
This class maintains the order of handlers and ensures propagation of read, write, exception, and
user-defined events.-
Constructor Summary
ConstructorsConstructorDescriptionDefaultPipeline
(Connection connection) Constructs a new pipeline for the given connection. -
Method Summary
Modifier and TypeMethodDescriptionAppends a newHandler
to the end of the pipeline.Retrieves theConnection
that this pipeline is bound to.void
Propagates a connection-activated event to the next handler in the pipeline.void
Propagates a connection-inactivated event to the next handler in the pipeline.void
propagateInboundFailure
(Throwable cause) Propagates an exception or failure encountered during inbound message processing.void
Propagates an inbound message to the next handler in the pipeline.void
propagateOutboundMessage
(OutboundMessage msg, CompletableFuture<Void> future) Propagates an outbound message to the previous handler in the pipeline.Removes theHandler
with the specified name from the pipeline.
-
Constructor Details
-
DefaultPipeline
Constructs a new pipeline for the given connection.
-
-
Method Details
-
addLast
Description copied from interface:Pipeline
Appends a newHandler
to the end of the pipeline. -
getConnection
Description copied from interface:Pipeline
Retrieves theConnection
that this pipeline is bound to.- Specified by:
getConnection
in interfacePipeline
- Returns:
- the associated
Connection
instance.
-
remove
Description copied from interface:Pipeline
Removes theHandler
with the specified name from the pipeline. -
propagateConnectionActive
public void propagateConnectionActive()Description copied from interface:InboundPropagator
Propagates a connection-activated event to the next handler in the pipeline.If not intercepted, this event will reach the tail handler.
- Specified by:
propagateConnectionActive
in interfaceInboundPropagator
-
propagateConnectionInactive
public void propagateConnectionInactive()Description copied from interface:InboundPropagator
Propagates a connection-inactivated event to the next handler in the pipeline.If not intercepted, this event will reach the tail handler.
- Specified by:
propagateConnectionInactive
in interfaceInboundPropagator
-
propagateInboundMessage
Description copied from interface:InboundPropagator
Propagates an inbound message to the next handler in the pipeline.This allows handlers to process or forward the message as needed.
- Specified by:
propagateInboundMessage
in interfaceInboundPropagator
- Parameters:
msg
- theInboundMessage
to propagate.
-
propagateInboundFailure
Description copied from interface:InboundPropagator
Propagates an exception or failure encountered during inbound message processing.If not intercepted, the failure will be delivered to the final handler in the chain.
- Specified by:
propagateInboundFailure
in interfaceInboundPropagator
- Parameters:
cause
- theThrowable
representing the failure.
-
propagateOutboundMessage
Description copied from interface:OutboundPropagator
Propagates an outbound message to the previous handler in the pipeline.If not intercepted, the message will eventually reach the head handler.
- Specified by:
propagateOutboundMessage
in interfaceOutboundPropagator
- Parameters:
msg
- theOutboundMessage
to propagate.future
- aCompletableFuture
to complete once the message is successfully handled or if an error occurs during propagation.
-