org.apache.mina.transport.socket.nio.SocketConnector Java Examples

The following examples show how to use org.apache.mina.transport.socket.nio.SocketConnector. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IoSessionFactory.java    From cougar with Apache License 2.0 5 votes vote down vote up
public IoSessionFactory(NioLogger logger,
                        String hosts,
                        JMXReportingThreadPoolExecutor executorService,
                        JMXReportingThreadPoolExecutor reconnectExecutor,
                        NioConfig config,
                        IoHandler ioHandler,
                        IoFutureListener sessionClosedListener,
                        int reconnectInterval,
                        int handshakeResponseTimeout,
                        long sessionRecycleInterval,
                        NetworkAddressResolver addressResolver) {
    this.logger = logger;
    this.reconnectInterval = reconnectInterval;
    this.handshakeResponseTimeout = handshakeResponseTimeout;

    this.hosts = hosts;

    this.nioConfig = config;

    this.socketConnector = new SocketConnector(executorService.getCorePoolSize(), executorService);
    this.socketConnector.setWorkerTimeout(config.getWorkerTimeout());

    this.ioHandler = ioHandler;
    this.sessionClosedListener = sessionClosedListener;

    this.keepRunning = false;
    this.reconnectExecutor = reconnectExecutor;
    sessionRecycler = new SessionRecycler(this, addressResolver, hosts, sessionRecycleInterval);
}
 
Example #2
Source File: CougarProtocolTest.java    From cougar with Apache License 2.0 4 votes vote down vote up
public IoSession createClient(NioConfig cfg, IoHandler handler) throws IOException {
    SocketConnector sc = new SocketConnector();
    ConnectFuture cf = sc.connect(new InetSocketAddress("127.0.0.1", 2227), handler, cfg.configureSocketSessionConfig());
    cf.join();
    return cf.getSession();
}