use of org.apache.mina.filter.codec.ProtocolCodecFilter in project dubbo by alibaba.
the class MinaServer method doOpen.
@Override
protected void doOpen() throws Throwable {
// set thread pool.
acceptor = new SocketAcceptor(getUrl().getPositiveParameter(Constants.IO_THREADS_KEY, Constants.DEFAULT_IO_THREADS), Executors.newCachedThreadPool(new NamedThreadFactory("MinaServerWorker", true)));
// config
SocketAcceptorConfig cfg = (SocketAcceptorConfig) acceptor.getDefaultConfig();
cfg.setThreadModel(ThreadModel.MANUAL);
// set codec.
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
acceptor.bind(getBindAddress(), new MinaHandler(getUrl(), this));
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter in project opennms by OpenNMS.
the class FtpDetector method onInit.
/**
* <p>onInit</p>
*/
@Override
protected void onInit() {
// setup the correct codec for this Detector
setProtocolCodecFilter(new ProtocolCodecFilter(new MultilineOrientedCodecFactory(StandardCharsets.UTF_8, getMultilineIndicator())));
expectBanner(expectCodeRange(100, 600));
send(request("quit"), expectCodeRange(100, 600));
}
use of org.apache.mina.filter.codec.ProtocolCodecFilter 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.ProtocolCodecFilter 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.ProtocolCodecFilter in project dubbo by alibaba.
the class MinaClient method doOpen.
@Override
protected void doOpen() throws Throwable {
connectorKey = getUrl().toFullString();
SocketConnector c = connectors.get(connectorKey);
if (c != null) {
connector = c;
} else {
// set thread pool.
connector = new SocketConnector(Constants.DEFAULT_IO_THREADS, Executors.newCachedThreadPool(new NamedThreadFactory("MinaClientWorker", true)));
// config
SocketConnectorConfig cfg = (SocketConnectorConfig) connector.getDefaultConfig();
cfg.setThreadModel(ThreadModel.MANUAL);
cfg.getSessionConfig().setTcpNoDelay(true);
cfg.getSessionConfig().setKeepAlive(true);
int timeout = getTimeout();
cfg.setConnectTimeout(timeout < 1000 ? 1 : timeout / 1000);
// set codec.
connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new MinaCodecAdapter(getCodec(), getUrl(), this)));
connectors.put(connectorKey, connector);
}
}
Aggregations