Class NettyConnectionAcceptor

java.lang.Object
org.jivesoftware.openfire.spi.ConnectionAcceptor
org.jivesoftware.openfire.spi.NettyConnectionAcceptor

public class NettyConnectionAcceptor extends ConnectionAcceptor
Responsible for accepting new (socket) connections, using Java NIO implementation provided by the Netty framework.
Author:
Matthew Vivian, Alex Gidman
  • Constructor Details

    • NettyConnectionAcceptor

      public NettyConnectionAcceptor(ConnectionConfiguration configuration)
      Instantiates, but does not start, a new instance.
  • Method Details

    • start

      public void start()
      Starts this acceptor by binding the socket acceptor. When the acceptor is already started, a warning will be logged and the method invocation is otherwise ignored.
      Specified by:
      start in class ConnectionAcceptor
    • stop

      public void stop()
      Stops this acceptor by unbinding the socket acceptor. Does nothing when the instance is not started.
      Specified by:
      stop in class ConnectionAcceptor
    • isIdle

      public boolean isIdle()
      Determines if this instance is currently in a state where it is actively serving connections or not. Channel must be open with no connections if it is idle
      Specified by:
      isIdle in class ConnectionAcceptor
      Returns:
      false when this instance is started and is currently being used to serve connections (otherwise true)
    • reconfigure

      public void reconfigure(ConnectionConfiguration configuration)
      Description copied from class: ConnectionAcceptor
      Reloads the acceptor configuration, without causing a disconnect of already established connections. A best-effort reload will be attempted. Configuration changes that require a restart of connections, such as the bind-address and port, will not be applied. The configuration that's provided will replace the existing configuration. A restart of the connection acceptor after this method was invoked will apply all configuration changes.
      Specified by:
      reconfigure in class ConnectionAcceptor
      Parameters:
      configuration - The configuration for connections to be accepted (cannot be null).
    • addChannelHandler

      public void addChannelHandler(NettyChannelHandlerFactory factory)
      Adds a new ChannelHandler factory, which will cause ChannelHandlers to be added to existing and new Channels that are generated by this acceptor. Note that instances of NettyConnectionAcceptor are replaced when the configuration of the ConnectionListener is modified. The new instance will not automatically have the factory that was added to an earlier instance. Listen for ConnectionAcceptor events to be able to re-supply the factory if need be
      Parameters:
      factory - A factory of ChannelHandler instances.
      See Also:
    • removeChannelHandler

      public void removeChannelHandler(NettyChannelHandlerFactory factory)
      Removes a new ChannelHandler factory, which will cause the ChannelHandler that it created to be removed from existing Channels that were generated by this acceptor. New Channels will no longer get a ChannelHandler from this factory either.
      Parameters:
      factory - A factory of ChannelHandler instances.
    • getChannelHandlerFactories

      public Set<NettyChannelHandlerFactory> getChannelHandlerFactories()
      Returns a copy of the collection of ChannelHandler factories that are registered with this instance.
      Returns:
      A collection of ChannelHandler factory instances.
    • getPort

      public int getPort()