Package org.drasyl.pipeline
Interface Handler
- All Known Implementing Classes:
AddressHandlerAdapter
,ApplicationMessage2ObjectHolderHandler
,Codec
,DefaultCodec
,DirectConnectionMessageSinkHandler
,GroupsClientHandler
,GroupsManagerHandler
,HandlerAdapter
,LoopbackMessageSinkHandler
,ObjectHolder2ApplicationMessageHandler
,SimpleDuplexHandler
,SimpleInboundHandler
,SimpleOutboundHandler
,SuperPeerMessageSinkHandler
public interface Handler
Handles an I/O event or intercepts an I/O operation, and forwards it to its next handler in its
Extend
Pipeline
.
Extend HandlerAdapter
instead
Because this interface has many methods to implement, you might want to extend HandlerAdapter
instead.
The context object
A Handler
is provided with a HandlerContext
object. A Handler
is
supposed to interact with the Pipeline
it belongs to via a context object. Using the
context object, the Handler
can pass events upstream or downstream or modify the pipeline
dynamically.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
eventTriggered
(HandlerContext ctx, Event event, CompletableFuture<Void> future) Gets called if aEvent
was emitted.void
exceptionCaught
(HandlerContext ctx, Exception cause) Gets called if aException
was thrown.void
Gets called after theHandler
was added to the actual context and it's ready to handle events.void
Gets called after theHandler
was removed from the actual context and it doesn't handle events anymore.void
read
(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future) Gets called if aObject
was received.void
write
(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future) Gets called if aObject
was send from the application to a recipient.
-
Method Details
-
handlerAdded
Gets called after theHandler
was added to the actual context and it's ready to handle events. -
handlerRemoved
Gets called after theHandler
was removed from the actual context and it doesn't handle events anymore. -
read
Gets called if aObject
was received.- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- a future for the message
-
eventTriggered
Gets called if aEvent
was emitted.- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
exceptionCaught
Gets called if aException
was thrown. -
write
Gets called if aObject
was send from the application to a recipient.- Parameters:
ctx
- handler contextrecipient
- the recipient of the messagemsg
- the messagefuture
- a future for the message
-