Java源码示例:org.apache.mina.transport.socket.nio.SocketAcceptorConfig
示例1
@Override
protected void doOpen() throws Throwable {
// set thread pool. iothreads线程数默认是Runtime.getRuntime().availableProcessors() + 1
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));
}
示例2
@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));
}
示例3
@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));
}
示例4
@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));
}
示例5
@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));
}
示例6
public void configureSocketAcceptorConfig(SocketAcceptorConfig config) throws IOException {
if (reuseAddress != null) {
config.setReuseAddress(reuseAddress);
}
configureSocketSessionConfig(config.getSessionConfig());
configureProtocol(config, true);
}