public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = pipeline();
pipeline.addLast("groupHandler", groupHandler);
pipeline.addLast("timeoutHandler", new TimeoutHandler(timer, TIMEOUT));
pipeline.addLast("connectionLimit", new ConnectionLimitUpstreamHandler(IMAPServer.this.connectionLimit));
pipeline.addLast("connectionPerIpLimit", new ConnectionPerIpLimitUpstreamHandler(IMAPServer.this.connPerIP));
if (isSSLSocket()) {
SSLEngine engine = getSSLContext().createSSLEngine();
engine.setUseClientMode(false);
pipeline.addFirst("sslHandler", new SslHandler(engine));
}
pipeline.addLast("connectionCountHandler", countHandler);
final ImapRequestStreamHandler handler = new ImapRequestStreamHandler(decoder, processor, encoder);
if (isStartTLSSupported()) {
pipeline.addLast("coreHandler", new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), IMAPServer.this.getTimeout(), getSSLContext().createSSLEngine()));
} else {
pipeline.addLast("coreHandler", new ImapStreamChannelUpstreamHandler(hello, handler, getLogger(), IMAPServer.this.getTimeout()));
}
return pipeline;
}