use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project camel by apache.
the class ReverserServer method start.
public void start() throws Exception {
acceptor = new SocketAcceptor();
// Prepare the configuration
SocketAcceptorConfig cfg = new SocketAcceptorConfig();
cfg.setReuseAddress(true);
Charset charset = Charset.forName("UTF-8");
cfg.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));
// Bind
acceptor.bind(new InetSocketAddress(port), new ReverseProtocolHandler(), cfg);
}
use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project camel by apache.
the class Mina2ReverserServer method start.
public void start() throws Exception {
acceptor = new NioSocketAcceptor();
// Prepare the configuration
((NioSocketAcceptor) acceptor).setReuseAddress(true);
Charset charset = Charset.forName("UTF-8");
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(charset)));
acceptor.setHandler(new Mina2ReverseProtocolHandler());
// Bind
acceptor.bind(new InetSocketAddress(port));
}
use of org.apache.mina.filter.codec.textline.TextLineCodecFactory in project opennms by OpenNMS.
the class AsyncSimpleServer method startServer.
/**
* <p>startServer</p>
*
* @throws java.lang.Exception if any.
*/
public void startServer() throws Exception {
m_acceptor = new NioSocketAcceptor();
m_acceptor.getFilterChain().addLast("logger", new LoggingFilter());
m_acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new TextLineCodecFactory(StandardCharsets.UTF_8)));
m_acceptor.setHandler(getServerHandler());
m_acceptor.getSessionConfig().setReadBufferSize(getBufferSize());
m_acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, getIdleTime());
((NioSocketAcceptor) m_acceptor).setReuseAddress(true);
m_acceptor.bind(new InetSocketAddress(getPort()));
}
Aggregations