use of org.apache.mina.filter.codec.ProtocolCodecFilter 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()));
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter in project opennms by OpenNMS.
the class SmtpDetector method onInit.
/**
* <p>onInit</p>
*/
@Override
protected void onInit() {
setProtocolCodecFilter(new ProtocolCodecFilter(new MultilineOrientedCodecFactory(StandardCharsets.UTF_8, "-")));
expectBanner(startsWith("220"));
send(request("HELO LOCALHOST"), startsWith("250"));
send(request("QUIT"), startsWith("221"));
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter in project vert.x by eclipse.
the class FakeDNSServer method start.
@Override
public void start() throws IOException {
UdpTransport transport = new UdpTransport("127.0.0.1", port);
setTransports(transport);
acceptor = transport.getAcceptor();
acceptor.setHandler(new DnsProtocolHandler(this, store) {
@Override
public void sessionCreated(IoSession session) throws Exception {
// Use our own codec to support AAAA testing
session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
}
});
// Allow the port to be reused even if the socket is in TIME_WAIT state
((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
// Start the listener
acceptor.bind();
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter in project netty by netty.
the class TestDnsServer method start.
@Override
public void start() throws IOException {
InetSocketAddress address = new InetSocketAddress(NetUtil.LOCALHOST4, 0);
UdpTransport transport = new UdpTransport(address.getHostName(), address.getPort());
setTransports(transport);
DatagramAcceptor acceptor = transport.getAcceptor();
acceptor.setHandler(new DnsProtocolHandler(this, store) {
@Override
public void sessionCreated(IoSession session) throws Exception {
// USe our own codec to support AAAA testing
session.getFilterChain().addFirst("codec", new ProtocolCodecFilter(new TestDnsProtocolUdpCodecFactory()));
}
});
((DatagramSessionConfig) acceptor.getSessionConfig()).setReuseAddress(true);
// Start the listener
acceptor.bind();
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter in project opennms by OpenNMS.
the class MultilineHttpDetector method contructDefaults.
private void contructDefaults() {
setProtocolCodecFilter(new ProtocolCodecFilter(new MultilineHttpProtocolFactory()));
setUrl(DEFAULT_URL);
setMaxRetCode(DEFAULT_MAX_RET_CODE);
}
Aggregations