Package org.jivesoftware.openfire.spi
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
-
-
Field Summary
-
Fields inherited from class org.jivesoftware.openfire.spi.ConnectionAcceptor
configuration
-
-
Constructor Summary
Constructors Constructor Description NettyConnectionAcceptor(ConnectionConfiguration configuration)
Instantiates, but does not start, a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.Set<NettyChannelHandlerFactory>
getChannelHandlerFactories()
Returns a copy of the collection of ChannelHandler factories that are registered with this instance.int
getPort()
boolean
isIdle()
Determines if this instance is currently in a state where it is actively serving connections or not.void
reconfigure(ConnectionConfiguration configuration)
Reloads the acceptor configuration, without causing a disconnect of already established connections.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.static void
shutdownEventLoopGroups()
Shuts down event loop groups if they are not already shutdown - this will close all channels.void
start()
Starts this acceptor by binding the socket acceptor.void
stop()
Stops this acceptor by unbinding the socket acceptor.
-
-
-
Constructor Detail
-
NettyConnectionAcceptor
public NettyConnectionAcceptor(ConnectionConfiguration configuration)
Instantiates, but does not start, a new instance.
-
-
Method Detail
-
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 classConnectionAcceptor
-
stop
public void stop()
Stops this acceptor by unbinding the socket acceptor. Does nothing when the instance is not started.- Specified by:
stop
in classConnectionAcceptor
-
shutdownEventLoopGroups
public static void shutdownEventLoopGroups()
Shuts down event loop groups if they are not already shutdown - this will close all channels.
-
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 classConnectionAcceptor
- 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 classConnectionAcceptor
- 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:
ConnectionListener.SocketAcceptorEventListener
-
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()
-
-