当前位置: 首页>>代码示例>>Java>>正文


Java SocketAcceptor.getDefaultConfig方法代码示例

本文整理汇总了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));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:MinaServer.java

示例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);
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:40,代码来源:MinaNetworkTransport.java

示例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));
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:15,代码来源:MinaServer.java


注:本文中的org.apache.mina.transport.socket.nio.SocketAcceptor.getDefaultConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。