Package org.drasyl.pipeline
Interface Handler
-
- All Known Implementing Classes:
AddressHandlerAdapter
,ArmHandler
,ChunkingHandler
,HandlerAdapter
,HopCountGuard
,InboundMessageFilter
,InternetDiscovery
,IntraVmDiscovery
,InvalidProofOfWorkFilter
,LocalHostDiscovery
,LocalNetworkDiscovery
,LoopbackMessageHandler
,MessageSerializer
,MessagesThroughputHandler
,MessageToByteEncoder
,MessageToMessageCodec
,MessageToMessageDecoder
,MessageToMessageEncoder
,Monitoring
,OtherNetworkFilter
,OutboundMessageFilter
,OutboundMessagesThrottlingHandler
,PortMapper
,RateLimiter
,RemoteEnvelopeToByteBufCodec
,SimpleDuplexEventAwareHandler
,SimpleDuplexHandler
,SimpleDuplexRemoteEnvelopeSkipLoopbackHandler
,SimpleInboundEventAwareHandler
,SimpleInboundHandler
,SimpleOutboundHandler
,StaticRoutesHandler
,TcpClient
,TcpServer
,UdpMulticastServer
,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
onAdded(HandlerContext ctx)
Gets called after theHandler
was added to the actual context and it's ready to handle events.void
onEvent(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.void
onException(HandlerContext ctx, Exception cause)
Gets called if aException
was thrown.void
onInbound(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future)
Gets called if aObject
was received.void
onOutbound(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future)
Gets called if aObject
was send from the application to a recipient.void
onRemoved(HandlerContext ctx)
Gets called after theHandler
was removed from the actual context and it doesn't handle events anymore.
-
-
-
Method Detail
-
onAdded
void onAdded(HandlerContext ctx)
Gets called after theHandler
was added to the actual context and it's ready to handle events.
-
onRemoved
void onRemoved(HandlerContext ctx)
Gets called after theHandler
was removed from the actual context and it doesn't handle events anymore.
-
onInbound
void onInbound(HandlerContext ctx, Address sender, Object msg, CompletableFuture<Void> future) throws Exception
Gets called if aObject
was received.- Parameters:
ctx
- handler contextsender
- the sender of the messagemsg
- the messagefuture
- a future for the message- Throws:
Exception
-
onEvent
void onEvent(HandlerContext ctx, Event event, CompletableFuture<Void> future)
Gets called if aEvent
was emitted.- Parameters:
ctx
- handler contextevent
- the eventfuture
- a future for the message
-
onException
void onException(HandlerContext ctx, Exception cause)
Gets called if aException
was thrown.
-
onOutbound
void onOutbound(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future) throws Exception
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- Throws:
Exception
-
-