Class NioSelectableChannelIoHandle<S extends java.nio.channels.SelectableChannel>

java.lang.Object
io.netty.channel.nio.NioSelectableChannelIoHandle<S>
All Implemented Interfaces:
IoHandle, NioIoHandle, java.lang.AutoCloseable

public abstract class NioSelectableChannelIoHandle<S extends java.nio.channels.SelectableChannel> extends java.lang.Object implements IoHandle, NioIoHandle
Allows to create an IoHandle for a SelectableChannel, not necessarily created by Netty. This IoHandle can be used together with NioIoHandler and so have events dispatched for the SelectableChannel.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final S
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called once the IoHandle should be closed.
    protected void
    deregister(S channel)
     
    void
    handle(IoRegistration registration, IoEvent ioEvent)
    Be called once there is something to handle.
    protected abstract void
    handle(S channel, java.nio.channels.SelectionKey key)
     
    java.nio.channels.SelectableChannel
    The underlying SelectableChannel.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface IoHandle

    registered, unregistered
  • Field Details

    • channel

      private final S extends java.nio.channels.SelectableChannel channel
  • Constructor Details

    • NioSelectableChannelIoHandle

      public NioSelectableChannelIoHandle(S channel)
  • Method Details

    • handle

      public void handle(IoRegistration registration, IoEvent ioEvent)
      Description copied from interface: IoHandle
      Be called once there is something to handle.
      Specified by:
      handle in interface IoHandle
      Parameters:
      registration - the IoRegistration for this IoHandle.
      ioEvent - the IoEvent that must be handled. The IoEvent is only valid while this method is executed and so must not escape it.
    • close

      public void close() throws java.lang.Exception
      Description copied from interface: IoHandle
      Called once the IoHandle should be closed. Even once this method is called this handle might still receive events via IoHandle.handle(IoRegistration, IoEvent) (if it was previous be registered and so its IoHandle.registered() method was called) until the IoHandle.unregistered() method is called.
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface IoHandle
      Throws:
      java.lang.Exception
    • selectableChannel

      public java.nio.channels.SelectableChannel selectableChannel()
      Description copied from interface: NioIoHandle
      The underlying SelectableChannel.
      Specified by:
      selectableChannel in interface NioIoHandle
      Returns:
      the channel
    • handle

      protected abstract void handle(S channel, java.nio.channels.SelectionKey key)
    • deregister

      protected void deregister(S channel)