Package org.apache.mina.transport.socket.nio

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


   
    public void testTCPWithSSL() throws Exception
    {
        useSSL = true;
        // Create a connector
        IoConnector connector = new SocketConnector();
       
        // Add an SSL filter to connector
        connector.getDefaultConfig().getFilterChain().addLast( "SSL", connectorSSLFilter );
        testConnector( connector );
    }
View Full Code Here


     * @see org.xmatthew.spy2servers.command.Command#execute(java.util.List)
     */
    public void execute(List<String> params) {
        LOGGER.info("doing shutdown...");

        SocketConnector connector = new SocketConnector();

        SocketAddress address;
        address = new InetSocketAddress(NetConstant.LOCALHOST_IP, NetShutdownHandlerCommand.DEFAULT_PORT);

        SocketConnectorConfig config = new SocketConnectorConfig();

        ConnectFuture future1 = connector.connect(address, new IoHandlerAdapter(), config);
        future1.join();
        if (!future1.isConnected()) {
            return;
        }
        IoSession session = future1.getSession();
View Full Code Here

    {
        IoAcceptor acceptor = new SocketAcceptor();
        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
        SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );

        IoConnector connector = new SocketConnector();
       
        FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
       
        SenderHandler sender = new SenderHandler( stream );
        ReceiverHandler receiver = new ReceiverHandler( stream.size );
       
        acceptor.bind( address, sender );
       
        synchronized( sender.lock )
        {
            synchronized( receiver.lock )
            {
                connector.connect( address, receiver );
               
                sender.lock.wait();
                receiver.lock.wait();
            }
        }
View Full Code Here

        ExecutorService acceptorPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaSocketAcceptor");
        ExecutorService connectorPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaSocketConnector");
        ExecutorService workerPool = getCamelContext().getExecutorServiceManager().newCachedThreadPool(this, "MinaThreadPool");

        IoAcceptor acceptor = new SocketAcceptor(processorCount, acceptorPool);
        IoConnector connector = new SocketConnector(processorCount, connectorPool);
        SocketAddress address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
        // must use manual thread model according to Mina documentation
View Full Code Here

        {
            values[ i ] = Integer.parseInt( args[ i ] );
        }

        // Set connect timeout.
        IoConnector connector = new SocketConnector();
        ( ( IoConnectorConfig ) connector.getDefaultConfig() ).setConnectTimeout( CONNECT_TIMEOUT );
       
        IoSession session;
        for( ;; )
        {
            try
            {
                ConnectFuture future = connector.connect(
                        new InetSocketAddress( HOSTNAME, PORT ),
                        new ClientSessionHandler( USE_CUSTOM_CODEC, values ) );
               
                future.join();
                session = future.getSession();
View Full Code Here

            System.out.println( Main.class.getName() + " <hostname> <port>" );
            return;
        }

        // Create TCP/IP connector.
        SocketConnector connector = new SocketConnector();

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
       
        // Start communication.
        connector.connect(
                new InetSocketAddress( args[ 0 ],
                Integer.parseInt( args[ 1 ] ) ),
                new NetCatProtocolHandler() );
    }
View Full Code Here

        // Create TCP/IP acceptor.
        IoAcceptor acceptor = new SocketAcceptor();
        ( ( SocketAcceptorConfig ) acceptor.getDefaultConfig() ).setReuseAddress( true );
       
        // Create TCP/IP connector.
        IoConnector connector = new SocketConnector();

        // Set connect timeout.
        ( ( IoConnectorConfig ) connector.getDefaultConfig()).setConnectTimeout( 30 );
       
        ClientToProxyIoHandler handler = new ClientToProxyIoHandler(
                new ServerToProxyIoHandler(), connector,
                new InetSocketAddress( args[ 1 ],
                        Integer.parseInt( args[ 2 ] ) ) );
View Full Code Here

    connectorConfig.getFilterChain().addLast("serialization",
        new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
    LOCAL_ADDRESS = new InetSocketAddress("localhost", remotePort);

    String processors = getProperty("pastrybroker.maxprocessors", "5");
    SocketConnector clientConnector = new SocketConnector(Integer
        .parseInt(processors), Executors.newCachedThreadPool());
    log.info("Connecting to local broker...");
    ConnectFuture connectFuture = clientConnector.connect(LOCAL_ADDRESS,
        new IoHandlerAdapter() {
          public void messageReceived(IoSession session, Object msg) {
            context = (PastryContext) msg;
            log.info("Pastry context retrieved");
          }
View Full Code Here

  PastryNode getNode() {
    return node;
  }

  private void initConnector() {
    connector = new SocketConnector();
    connectorConfig = new SocketConnectorConfig();
    // connectorConfig.setThreadModel(ThreadModel.MANUAL);
    connectorConfig.getFilterChain().addLast("logger", new LoggingFilter());
    connectorConfig.getFilterChain().addLast("serialization",
        new ProtocolCodecFilter(new ObjectSerializationCodecFactory()));
View Full Code Here

        long timeout = configuration.getTimeout();
        boolean sync = configuration.isSync();
        final int processorCount = Runtime.getRuntime().availableProcessors() + 1;

        IoAcceptor acceptor = new SocketAcceptor(processorCount, Executors.newCachedThreadPool());
        IoConnector connector = new SocketConnector(processorCount, Executors.newCachedThreadPool());
        SocketAddress address = new InetSocketAddress(configuration.getHost(), configuration.getPort());

        // connector config
        SocketConnectorConfig connectorConfig = new SocketConnectorConfig();
        // must use manual thread model according to Mina documentation
View Full Code Here

TOP

Related Classes of org.apache.mina.transport.socket.nio.SocketConnector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.