Package org.jivesoftware.openfire.nio
Class NettyConnectionHandler<H extends StanzaHandler>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<String>
org.jivesoftware.openfire.nio.NettyConnectionHandler<H>
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
- Direct Known Subclasses:
NettyClientConnectionHandler,NettyComponentConnectionHandler,NettyMultiplexerConnectionHandler,NettyOutboundConnectionHandler,NettyServerConnectionHandler
public abstract class NettyConnectionHandler<H extends StanzaHandler>
extends io.netty.channel.SimpleChannelInboundHandler<String>
A NettyConnectionHandler is responsible for creating new sessions, destroying sessions and delivering
received XML stanzas to the proper StanzaHandler.
Subclasses of this will supply a specific StanzaHandler implementation depending on the
type of connection to be handled, e.g. C2S, S2S.
- Author:
- Matthew Vivian, Alex Gidman
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ConnectionConfigurationThe configuration for new connections.static final io.netty.util.AttributeKey<NettyConnection>static final io.netty.util.AttributeKey<Boolean>protected static final ThreadLocal<XMPPPacketReader>static final io.netty.util.AttributeKey<Long>protected booleanstatic final io.netty.util.AttributeKey<Long> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedNettyConnectionHandler(ConnectionConfiguration configuration) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, String message) voidchannelUnregistered(io.netty.channel.ChannelHandlerContext ctx) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) abstract DurationReturns the time that a connection can be idle before being closed.Returns a future that completes when theStanzaHandlerfor this connection has been created and added to the Netty pipeline.voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx) voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx) toString()voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelWritabilityChangedMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
CONNECTION
-
READ_BYTES
-
WRITTEN_BYTES
-
IDLE_FLAG
-
PARSER_CACHE
-
sslInitDone
protected boolean sslInitDone -
configuration
The configuration for new connections.
-
-
Constructor Details
-
NettyConnectionHandler
-
-
Method Details
-
getMaxIdleTime
Returns the time that a connection can be idle before being closed.- Returns:
- the time a connection can be idle.
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter
-
getStanzaHandlerFuture
Returns a future that completes when theStanzaHandlerfor this connection has been created and added to the Netty pipeline. This is used to safely coordinate with asynchronous Netty handler initialization and avoids race conditions where the handler is accessed beforehandlerAdded(io.netty.channel.ChannelHandlerContext)has executed.- Returns:
- a future that completes with the stanza handler once it is available
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter
-
channelRead0
- Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<String>
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelUnregistered
- Specified by:
channelUnregisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelUnregisteredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception - Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
toString
-