{
SSLEngine engine = context.createSSLEngine();
engine.setUseClientMode(false);
SslHandler handler = new SslHandler(engine);
handlers.put("ssl", handler);
}
if (httpEnabled)
{
handlers.put("http-decoder", new HttpRequestDecoder());
handlers.put("http-aggregator", new HttpChunkAggregator(Integer.MAX_VALUE));
handlers.put("http-encoder", new HttpResponseEncoder());
httpHandler = new HttpAcceptorHandler(httpKeepAliveRunnable, httpResponseTime);
handlers.put("http-handler", httpHandler);
}
if (protocol == ProtocolType.CORE)
{
// Core protocol uses its own optimised decoder
handlers.put("hornetq-decoder", new HornetQFrameDecoder2());
}
else if (protocol == ProtocolType.STOMP_WS)
{
handlers.put("http-decoder", new HttpRequestDecoder());
handlers.put("http-aggregator", new HttpChunkAggregator(65536));
handlers.put("http-encoder", new HttpResponseEncoder());
handlers.put("hornetq-decoder", new HornetQFrameDecoder(decoder));
handlers.put("websocket-handler", new WebSocketServerHandler());
}
else if (protocol == ProtocolType.STOMP)
{
//With STOMP the decoding is handled in the StompFrame class
}
else
{
handlers.put("hornetq-decoder", new HornetQFrameDecoder(decoder));
}
handlers.put("handler", new HornetQServerChannelHandler(channelGroup, handler, new Listener()));
/**
* STOMP_WS protocol mandates use of named handlers to be able to replace http codecs
* by websocket codecs after handshake.
* Other protocols can use a faster static channel pipeline directly.
*/
ChannelPipeline pipeline;
if (protocol == ProtocolType.STOMP_WS)
{
pipeline = new DefaultChannelPipeline();
for (Entry<String, ChannelHandler> handler : handlers.entrySet())
{
pipeline.addLast(handler.getKey(), handler.getValue());
}
}
else
{
pipeline = new StaticChannelPipeline(handlers.values().toArray(new ChannelHandler[handlers.size()]));