Package org.apache.mina.common

Examples of org.apache.mina.common.IoAcceptor


        }

        try
        {
            // IoAcceptor acceptor = new SocketAcceptor(connectorConfig.processors);
            IoAcceptor acceptor = connectorConfig.createAcceptor();
            SocketAcceptorConfig sconfig = (SocketAcceptorConfig) acceptor.getDefaultConfig();
            SocketSessionConfig sc = (SocketSessionConfig) sconfig.getSessionConfig();

            sc.setReceiveBufferSize(connectorConfig.socketReceiveBufferSize);
            sc.setSendBufferSize(connectorConfig.socketWriteBuferSize);
            sc.setTcpNoDelay(connectorConfig.tcpNoDelay);

            // if we do not use the executor pool threading model we get the default leader follower
            // implementation provided by MINA
            if (connectorConfig.enableExecutorPool)
            {
                sconfig.setThreadModel(ReadWriteThreadModel.getInstance());
            }

            if (!connectorConfig.enableSSL || !connectorConfig.sslOnly)
            {
                AMQPFastProtocolHandler handler = new AMQPProtocolProvider().getHandler();
                InetSocketAddress bindAddress;
                if (bindAddr.equals("wildcard"))
                {
                    bindAddress = new InetSocketAddress(port);
                }
                else
                {
                    bindAddress = new InetSocketAddress(InetAddress.getByAddress(parseIP(bindAddr)), port);
                }

                acceptor.bind(bindAddress, handler, sconfig);
                //fixme  qpid.AMQP should be using qpidproperties to get value
                _brokerLogger.info("Qpid.AMQP listening on non-SSL address " + bindAddress);
            }

            if (connectorConfig.enableSSL)
            {
                AMQPFastProtocolHandler handler = new AMQPProtocolProvider().getHandler();
                try
                {

                    acceptor.bind(new InetSocketAddress(connectorConfig.sslPort), handler, sconfig);
                    //fixme  qpid.AMQP should be using qpidproperties to get value
                    _brokerLogger.info("Qpid.AMQP listening on SSL port " + connectorConfig.sslPort);

                }
                catch (IOException e)
View Full Code Here


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

        // 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 ] ) ) );
       
        // Start proxy.
        acceptor.bind( new InetSocketAddress( Integer.parseInt( args[ 0 ] ) ), handler );

        System.out.println( "Listening on port " + Integer.parseInt( args[ 0 ] ) );
    }
View Full Code Here

    }
   
    public void testDisconnectOnUnbind() throws Exception
    {
        MockControl acceptorControl = MockControl.createControl( IoAcceptor.class );
        IoAcceptor acceptor = ( IoAcceptor ) acceptorControl.getMock();
        MockControl configControl = MockControl.createControl( IoAcceptorConfig.class );
        IoAcceptorConfig config = ( IoAcceptorConfig ) configControl.getMock();
        final IoSession session = new TestSession( acceptor, ADDRESS );
        MockControl listenerControl = MockControl.createControl( IoServiceListener.class );
        IoServiceListener listener = ( IoServiceListener ) listenerControl.getMock();
View Full Code Here

    private static final boolean USE_CUSTOM_CODEC = true;

    public static void main( String[] args ) throws Throwable
    {
        // Create ServiceRegistry.
        IoAcceptor acceptor = new SocketAcceptor();

        acceptor.bind(
                new InetSocketAddress( SERVER_PORT ),
                new ServerSessionHandler( USE_CUSTOM_CODEC ) );

        System.out.println( "Listening on port " + SERVER_PORT );
    }
View Full Code Here

public class Main
{

    public static void main( String[] args ) throws Exception
    {
        IoAcceptor acceptor = new VmPipeAcceptor();
        VmPipeAddress address = new VmPipeAddress( 8080 );

        // Set up server
        acceptor.bind( address, new TennisPlayer() );

        // Connect to the server.
        VmPipeConnector connector = new VmPipeConnector();
        ConnectFuture future = connector.connect( address,
                                                  new TennisPlayer() );
        future.join();
        IoSession session = future.getSession();

        // Send the first ping message
        session.write( new TennisBall( 10 ) );

        // Wait until the match ends.
        session.getCloseFuture().join();
       
        acceptor.unbind( address );
    }
View Full Code Here

    /** Set this to true if you want to make the server SSL */
    private static final boolean USE_SSL = false;

    public static void main( String[] args ) throws Exception
    {
        IoAcceptor acceptor = new SocketAcceptor();
        IoAcceptorConfig config = new SocketAcceptorConfig();
        DefaultIoFilterChainBuilder chain = config.getFilterChain();
       
        // Add SSL filter if SSL is enabled.
        if( USE_SSL )
        {
            addSSLSupport( chain  );
        }
       
        addLogger( chain );
       
        // Bind
        acceptor.bind(
                new InetSocketAddress( PORT ),
                new EchoProtocolHandler(),
                config );

        System.out.println( "Listening on port " + PORT );
View Full Code Here

   
    private static final boolean USE_SSL = false;

    public static void main( String[] args ) throws Exception
    {
        IoAcceptor acceptor = new SocketAcceptor();
        IoAcceptorConfig config = new SocketAcceptorConfig();
        DefaultIoFilterChainBuilder chain = config.getFilterChain();

        // Add SSL filter if SSL is enabled.
        if( USE_SSL )
        {
            addSSLSupport( chain );
        }

        // Bind
        acceptor.bind(
                new InetSocketAddress( PORT ),
                new HttpProtocolHandler(),
                config );

        System.out.println( "Listening on port " + PORT );
View Full Code Here

{
    private static final int PORT = 8080;

    public static void main( String[] args ) throws Exception
    {
        IoAcceptor acceptor = new SocketAcceptor();

        // Bind
        acceptor.bind(
                new InetSocketAddress( PORT ),
                new ReverseProtocolHandler() );

        System.out.println( "Listening on port " + PORT );
    }
View Full Code Here

        IoServiceConfig config1 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        IoServiceConfig config2 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        MockControl mockIoAcceptor = MockControl.createControl( IoAcceptor.class );
        IoAcceptor acceptor = ( IoAcceptor ) mockIoAcceptor.getMock();
       
        acceptor.bind( new InetSocketAddress( 80 ), handler1, config1 );
        acceptor.bind( new InetSocketAddress( "192.168.0.1", 22 ), handler2, config2 );
        acceptor.bind( new InetSocketAddress( "10.0.0.1", 9876 ), handler3 );
        acceptor.unbind( new InetSocketAddress( 80 ) );
        acceptor.unbind( new InetSocketAddress( "192.168.0.1", 22 ) );
        acceptor.unbind( new InetSocketAddress( "10.0.0.1", 9876 ) );
       
        mockIoAcceptor.replay();
       
        IoAcceptorFactoryBean factory = new IoAcceptorFactoryBean();
        factory.setTarget( acceptor );
View Full Code Here

        assertEquals( IoAcceptor.class, new IoAcceptorFactoryBean().getObjectType() );
    }
   
    public void testGetObject() throws Exception
    {
        IoAcceptor acceptor =
            ( IoAcceptor ) MockControl.createControl( IoAcceptor.class ).getMock();
        IoAcceptorFactoryBean factory = new IoAcceptorFactoryBean();
        factory.setTarget( acceptor );

        assertEquals( acceptor, factory.getObject() );
View Full Code Here

TOP

Related Classes of org.apache.mina.common.IoAcceptor

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.