public class OptionalSslHandler extends ByteToMessageDecoder
OptionalSslHandler
is a utility decoder to support both SSL and non-SSL handlers
based on the first message received.ByteToMessageDecoder.Cumulator
ChannelHandler.Sharable
COMPOSITE_CUMULATOR, MERGE_CUMULATOR
构造器和说明 |
---|
OptionalSslHandler(SslContext sslContext) |
限定符和类型 | 方法和说明 |
---|---|
protected void |
decode(ChannelHandlerContext context,
ByteBuf in,
java.util.List<java.lang.Object> out)
Decode the from one
ByteBuf to an other. |
protected ChannelHandler |
newNonSslHandler(ChannelHandlerContext context)
Override to configure the ChannelHandler.
|
protected java.lang.String |
newNonSslHandlerName()
Optionally specify the non-SSL handler name, this method may return
null . |
protected SslHandler |
newSslHandler(ChannelHandlerContext context,
SslContext sslContext)
Override to configure the SslHandler eg.
|
protected java.lang.String |
newSslHandlerName()
Optionally specify the SSL handler name, this method may return
null . |
actualReadableBytes, callDecode, channelInactive, channelRead, channelReadComplete, decodeLast, discardSomeReadBytes, handlerRemoved, handlerRemoved0, internalBuffer, isSingleDecode, setCumulator, setDiscardAfterReads, setSingleDecode, userEventTriggered
channelActive, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught
ensureNotSharable, handlerAdded, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
handlerAdded
public OptionalSslHandler(SslContext sslContext)
protected void decode(ChannelHandlerContext context, ByteBuf in, java.util.List<java.lang.Object> out) throws java.lang.Exception
ByteToMessageDecoder
ByteBuf
to an other. This method will be called till either the input
ByteBuf
has nothing to read when return from this method or till nothing was read from the input
ByteBuf
.decode
在类中 ByteToMessageDecoder
context
- the ChannelHandlerContext
which this ByteToMessageDecoder
belongs toin
- the ByteBuf
from which to read dataout
- the List
to which decoded messages should be addedjava.lang.Exception
- is thrown if an error occursprotected java.lang.String newSslHandlerName()
null
.protected SslHandler newSslHandler(ChannelHandlerContext context, SslContext sslContext)
SSLParameters.setEndpointIdentificationAlgorithm(String)
.
The hostname and port is not known by this method so servers may want to override this method and use the
SslContext.newHandler(ByteBufAllocator, String, int)
variant.context
- the ChannelHandlerContext
to use.sslContext
- the SSLContext
to use.SslHandler
which will replace the OptionalSslHandler
in the pipeline if the
traffic is SSL.protected java.lang.String newNonSslHandlerName()
null
.protected ChannelHandler newNonSslHandler(ChannelHandlerContext context)
context
- the ChannelHandlerContext
to use.ChannelHandler
which will replace the OptionalSslHandler
in the pipeline
or null
to simply remove the OptionalSslHandler
if the traffic is non-SSL.