ChannelPipeline depending on the application-level protocol negotiation result of
SslHandler. For example, you could configure your HTTP pipeline depending on the result of ALPN:
public class MyInitializer extendsChannelInitializer<Channel> { private finalSslContextsslCtx; public MyInitializer(SslContextsslCtx) { this.sslCtx = sslCtx; } protected void initChannel(Channelch) {ChannelPipelinep = ch.pipeline(); p.addLast(sslCtx.newHandler(...)); // AddsSslHandlerp.addLast(new MyNegotiationHandler()); } } public class MyNegotiationHandler extendsApplicationProtocolNegotiationHandler{ public MyNegotiationHandler() { super(ApplicationProtocolNames.HTTP_1_1); } protected void configurePipeline(ChannelHandlerContextctx, String protocol) { if (ApplicationProtocolNames.HTTP_2.equals(protocol) { configureHttp2(ctx); } else if (ApplicationProtocolNames.HTTP_1_1.equals(protocol)) { configureHttp1(ctx); } else { throw new IllegalStateException("unknown protocol: " + protocol); } } }
| Modifier and Type | Field and Description |
|---|---|
| private final RecyclableArrayList | |
| private ChannelHandlerContext | |
| private final String | |
| private static final InternalLogger | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| protected | ApplicationProtocolNegotiationHandler(String
the name of the protocol to use when
ALPN/NPN negotiation fails or the client does not support ALPN/NPN fallbackProtocol)Creates a new instance with the specified fallback protocol name. |
| bufferedMessages | back to summary |
|---|---|
| private final RecyclableArrayList bufferedMessages | |
| ctx | back to summary |
|---|---|
| private ChannelHandlerContext ctx | |
| fallbackProtocol | back to summary |
|---|---|
| private final String fallbackProtocol | |
| logger | back to summary |
|---|---|
| private static final InternalLogger logger | |
| sslHandlerChecked | back to summary |
|---|---|
| private boolean sslHandlerChecked | |
| ApplicationProtocolNegotiationHandler | back to summary |
|---|---|
| protected ApplicationProtocolNegotiationHandler(String fallbackProtocol) Creates a new instance with the specified fallback protocol name.
| |
| channelInactive | back to summary |
|---|---|
| public void channelInactive(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| channelRead | back to summary |
|---|---|
| public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| configurePipeline | back to summary |
|---|---|
| protected abstract void configurePipeline(ChannelHandlerContext ctx, String protocol) throws Exception Invoked on successful initial SSL/TLS handshake. Implement this method to configure your pipeline for the negotiated application-level protocol.
| |
| exceptionCaught | back to summary |
|---|---|
| public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception Overrides io. Implements io. Doc from io. Calls
| |
| fireBufferedMessages | back to summary |
|---|---|
| private void fireBufferedMessages() Process all backlog into pipeline from List. | |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides io. Implements io. Doc from io. Gets called after the
| |
| handshakeFailure | back to summary |
|---|---|
| protected void handshakeFailure(ChannelHandlerContext ctx, Throwable cause) throws Exception Invoked on failed initial SSL/TLS handshake. | |
| removeSelfIfPresent | back to summary |
|---|---|
| private void removeSelfIfPresent(ChannelHandlerContext ctx) | |
| userEventTriggered | back to summary |
|---|---|
| public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception Overrides io. Implements io. Doc from io. Calls
| |