use of org.apache.mina.filter.codec.ProtocolCodecFilter in project zm-mailbox by Zimbra.
the class NioServer method start.
/**
* Starts the server. Binds the server port and starts the connection
* handler. Optionally adds an SSLFilter if ssl is enabled.
*
* @throws IOException if an I/O error occured while starting the server
*/
@Override
public void start() {
ServerConfig sc = getConfig();
DefaultIoFilterChainBuilder fc = acceptor.getFilterChain();
if (sc.isSslEnabled()) {
fc.addFirst("ssl", newSSLFilter());
}
fc.addLast("executer", executorFilter);
fc.addLast("logger", new NioLoggingFilter(this, false));
fc.addLast("codec", new ProtocolCodecFilter(getProtocolCodecFactory()));
for (IoFilter filter : FILTERS.get(getClass())) {
// insert custom filters
fc.addLast(filter.getClass().getName(), filter);
}
acceptor.getSessionConfig().setBothIdleTime(sc.getMaxIdleTime());
acceptor.getSessionConfig().setWriteTimeout(sc.getWriteTimeout());
acceptor.setHandler(new NioHandlerDispatcher(this));
try {
acceptor.bind();
} catch (Throwable e) {
Zimbra.halt(getName() + " failed to start", e);
}
getLog().info("Starting %s on %s", getName(), acceptor.getLocalAddress());
}
Aggregations