Package org.drasyl.pipeline
Interface Handler
-
- All Known Implementing Classes:
AddressedEnvelopeHandler
,AddressHandlerAdapter
,ArmHandler
,ByteBuf2MessageHandler
,ChunkingHandler
,HandlerAdapter
,HopCountGuard
,InboundMessageGuard
,InternetDiscoveryHandler
,IntraVmDiscovery
,InvalidProofOfWorkFilter
,LocalHostDiscovery
,LoopbackMessageHandler
,Message2ByteBufHandler
,MessageSerializer
,MessagesThroughputHandler
,Monitoring
,OtherNetworkFilter
,PortMapper
,SimpleDuplexEventAwareHandler
,SimpleDuplexHandler
,SimpleInboundEventAwareHandler
,SimpleInboundHandler
,SimpleOutboundHandler
,StaticRoutesHandler
,UdpServer
public interface Handler
Handles an I/O event or intercepts an I/O operation, and forwards it to its next handler in itsPipeline
.Extend
HandlerAdapter
insteadBecause this interface has many methods to implement, you might want to extend
HandlerAdapter
instead.The context object
A
Handler
is provided with aHandlerContext
object. AHandler
is supposed to interact with thePipeline
it belongs to via a context object. Using the context object, theHandler
can pass events upstream or downstream or modify the pipeline dynamically.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
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
handlerAdded(HandlerContext ctx)
Gets called after theHandler
was added to the actual context and it's ready to handle events.void
handlerRemoved(HandlerContext ctx)
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 Detail
-
handlerAdded
void handlerAdded(HandlerContext ctx)
Gets called after theHandler
was added to the actual context and it's ready to handle events.
-
handlerRemoved
void handlerRemoved(HandlerContext ctx)
Gets called after theHandler
was removed from the actual context and it doesn't handle events anymore.
-
read
void read(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future)
Gets called if aObject
was received.- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- a future for the message
-
eventTriggered
void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
exceptionCaught
void exceptionCaught(HandlerContext ctx, Exception cause)
Gets called if aException
was thrown.
-
write
void write(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future)
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
-
-