本文整理汇总了Java中org.apache.mina.transport.socket.nio.SocketAcceptor.getDefaultConfig方法的典型用法代码示例。如果您正苦于以下问题:Java SocketAcceptor.getDefaultConfig方法的具体用法?Java SocketAcceptor.getDefaultConfig怎么用?Java SocketAcceptor.getDefaultConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mina.transport.socket.nio.SocketAcceptor
的用法示例。
在下文中一共展示了SocketAcceptor.getDefaultConfig方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doOpen
import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
@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));
}
示例2: accept
import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
public void accept(final NetworkTransportConfiguration config, final ProtocolEngineFactory factory,
final SSLContextFactory sslFactory)
{
int processors = config.getConnectorProcessors();
if (Transport.TCP.equalsIgnoreCase(config.getTransport()))
{
_acceptor = new SocketAcceptor(processors, new NewThreadExecutor());
SocketAcceptorConfig sconfig = (SocketAcceptorConfig) _acceptor.getDefaultConfig();
sconfig.setThreadModel(ExecutorThreadModel.getInstance("MinaNetworkTransport(Acceptor)"));
SocketSessionConfig sc = (SocketSessionConfig) sconfig.getSessionConfig();
sc.setTcpNoDelay(config.getTcpNoDelay());
sc.setSendBufferSize(config.getSendBufferSize());
sc.setReceiveBufferSize(config.getReceiveBufferSize());
if (config.getHost().equals(WILDCARD_ADDRESS))
{
_address = new InetSocketAddress(config.getPort());
}
else
{
_address = new InetSocketAddress(config.getHost(), config.getPort());
}
}
else
{
throw new TransportException("Unknown transport: " + config.getTransport());
}
try
{
_acceptor.bind(_address, new MinaNetworkHandler(sslFactory, factory));
}
catch (IOException e)
{
throw new TransportException("Could not bind to " + _address, e);
}
}
示例3: doOpen
import org.apache.mina.transport.socket.nio.SocketAcceptor; //导入方法依赖的package包/类
@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));
}