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

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


            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.
        ConnectFuture cf = connector.connect(new InetSocketAddress(
                args[0], Integer.parseInt(args[1])), new NetCatProtocolHandler());
       
        // Wait for the connection attempt to be finished.
        cf.join();
        cf.getSession();
View Full Code Here


        {
            _socketConnector = new MultiThreadSocketConnector(1, new QpidThreadExecutor());
        }
        else
        {
            _socketConnector = new SocketConnector(1, new QpidThreadExecutor()); // non-blocking
                                                                                 // connector
        }
       
        org.apache.mina.common.ByteBuffer.setUseDirectBuffers(Boolean.getBoolean("amqj.enableDirectBuffers"));
        // the MINA default is currently to use the pooled allocator although this may change in future
View Full Code Here

            case TCP:
                return new SocketTransportConnection(new SocketTransportConnection.SocketConnectorFactory()
                {
                    public IoConnector newSocketConnector()
                    {
                        SocketConnector result;
                        // FIXME - this needs to be sorted to use the new Mina MultiThread SA.
                        if (Boolean.getBoolean("qpidnio"))
                        {
                            _logger.warn("Using Qpid MultiThreaded NIO - " + (System.getProperties().containsKey("qpidnio")
                                                                              ? "Qpid NIO is new default"
                                                                              : "Sysproperty 'qpidnio' is set"));
                            result = new MultiThreadSocketConnector(1, new QpidThreadExecutor());
                        }
                        else
                        {
                            _logger.info("Using Mina NIO");
                            result = new SocketConnector(1, new QpidThreadExecutor()); // non-blocking connector
                        }
                        // Don't have the connector's worker thread wait around for other connections (we only use
                        // one SocketConnector per connection at the moment anyway). This allows short-running
                        // clients (like unit tests) to complete quickly.
                        result.setWorkerTimeout(0);
                        return result;
                    }
                });
            case VM:
            {
View Full Code Here

            case TCP:
                instance = new SocketTransportConnection(new SocketTransportConnection.SocketConnectorFactory()
                {
                    public IoConnector newSocketConnector()
                    {
                        SocketConnector result;
                        // FIXME - this needs to be sorted to use the new Mina MultiThread SA.
                        if (Boolean.getBoolean("qpidnio"))
                        {
                            _logger.warn("Using Qpid MultiThreaded NIO - " + (System.getProperties().containsKey("qpidnio")
                                                                 ? "Qpid NIO is new default"
                                                                 : "Sysproperty 'qpidnio' is set"));
                            result = new MultiThreadSocketConnector();
                        }
                        else
                        {
                            _logger.info("Using Mina NIO");
                            result = new SocketConnector(); // non-blocking connector
                        }
                        // Don't have the connector's worker thread wait around for other connections (we only use
                        // one SocketConnector per connection at the moment anyway). This allows short-running
                        // clients (like unit tests) to complete quickly.
                        result.setWorkerTimeout(0);
                        return result;
                    }
                });
                break;
            case VM:
View Full Code Here

public class SocketConnectorFactoryBean extends AbstractIoConnectorFactoryBean
{

    protected IoConnector createIoConnector() throws Exception
    {
        return new SocketConnector();
    }
View Full Code Here

        ServiceRegistry reg = new SimpleServiceRegistry();
        ( ( SocketAcceptor ) reg.getAcceptor( TransportType.SOCKET ) ).setReuseAddress( true );
        SocketAddress address = new InetSocketAddress( "localhost", AvailablePortFinder.getNextAvailable() );
        Service service = new Service( "stream", TransportType.SOCKET, address );

        SocketConnector connector = new SocketConnector();
        connector.getFilterChain().addFirst( "threadPool", new ThreadPoolFilter() );
       
        FixedRandomInputStream stream = new FixedRandomInputStream( 4 * 1024 * 1024 );
       
        SenderHandler sender = new SenderHandler( stream );
        ReceiverHandler receiver = new ReceiverHandler( stream.size );
       
        reg.bind( service, sender );
       
        synchronized( sender.lock )
        {
            synchronized( receiver.lock )
            {
                connector.connect( address, receiver );
               
                sender.lock.wait();
                receiver.lock.wait();
            }
        }
View Full Code Here

    {
    }

    public void testTCP() throws Exception
    {
        IoConnector connector = new SocketConnector();
        testConnector( connector );
    }
View Full Code Here

            new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
        IoAcceptor acceptor = registry.getAcceptor( TransportType.SOCKET );
        acceptor.getFilterChain().addLast( "SSL", acceptorSSLFilter );
       
        // Create a connector
        IoConnector connector = new SocketConnector();
       
        // Add an SSL filter to connector
        SSLFilter connectorSSLFilter =
            new SSLFilter( BogusSSLContextFactory.getInstance( false ) );
        connectorSSLFilter.setUseClientMode( true ); // set client mode
        connector.getFilterChain().addLast( "SSL", connectorSSLFilter );

        testConnector( connector );
    }
View Full Code Here

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

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

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

        // Create I/O and Protocol thread pool filter.
        // I/O thread pool performs encoding and decoding of messages.
        // Protocol thread pool performs actual protocol flow.
        ThreadPoolFilter ioThreadPoolFilter = new ThreadPoolFilter();
        ThreadPoolFilter protocolThreadPoolFilter = new ThreadPoolFilter();
        IoConnector connector = new SocketConnector();
        connector.getFilterChain().addFirst(
                "ioThreadPool", ioThreadPoolFilter );
        connector.getFilterChain().addLast(
                "protocolThreadPool", protocolThreadPoolFilter );

        // Set connect timeout.
        connector.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

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.