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 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 Details

    • handlerAdded

      void handlerAdded(HandlerContext ctx)
      Gets called after the Handler was added to the actual context and it's ready to handle events.
    • handlerRemoved

      void handlerRemoved(HandlerContext ctx)
      Gets called after the Handler 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 a Object was received.
      Parameters:
      ctx - handler context
      sender - the sender of the message
      msg - the message
      future - a future for the message
    • eventTriggered

      void eventTriggered(HandlerContext ctx, Event event, CompletableFuture<Void> future)
      Gets called if a Event was emitted.
      Parameters:
      ctx - handler context
      event - the event
      future - a future for the message
    • exceptionCaught

      void exceptionCaught(HandlerContext ctx, Exception cause)
      Gets called if a Exception was thrown.
    • write

      void write(HandlerContext ctx, Address recipient, Object msg, CompletableFuture<Void> future)
      Gets called if a Object was send from the application to a recipient.
      Parameters:
      ctx - handler context
      recipient - the recipient of the message
      msg - the message
      future - a future for the message