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 TypeMethodDescriptionvoideventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future) Gets called if aEventwas emitted.voidexceptionCaught(HandlerContext ctx, Exception cause) Gets called if aExceptionwas thrown.voidGets called after theHandlerwas added to the actual context and it's ready to handle events.voidGets called after theHandlerwas removed from the actual context and it doesn't handle events anymore.voidread(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future) Gets called if aObjectwas received.voidwrite(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future) Gets called if aObjectwas send from the application to a recipient.
-
Method Details
-
handlerAdded
Gets called after theHandlerwas added to the actual context and it's ready to handle events. -
handlerRemoved
Gets called after theHandlerwas removed from the actual context and it doesn't handle events anymore. -
read
Gets called if aObjectwas received.- Parameters:
ctx- handler contextsender- the sender of the messagemsg- the messagefuture- a future for the message
-
eventTriggered
Gets called if aEventwas emitted.- Parameters:
ctx- handler contextevent- the eventfuture- a future for the message
-
exceptionCaught
Gets called if aExceptionwas thrown. -
write
Gets called if aObjectwas send from the application to a recipient.- Parameters:
ctx- handler contextrecipient- the recipient of the messagemsg- the messagefuture- a future for the message
-