Examples of DefaultConnectFuture


Examples of org.apache.mina.common.support.DefaultConnectFuture

            ch.configureBlocking(false);

            if (ch.connect(address))
            {
                DefaultConnectFuture future = new DefaultConnectFuture();
                newSession(ch, handler, config, future);
                success = true;
                return future;
            }
View Full Code Here

Examples of org.apache.mina.common.support.DefaultConnectFuture

        boolean success = false;

        try
        {
            DefaultConnectFuture future = new DefaultConnectFuture();
            newSession(_openSocket, handler, config, future);
            success = true;
            return future;
        }
        catch (IOException e)
View Full Code Here

Examples of org.apache.mina.common.support.DefaultConnectFuture

        {
            return DefaultConnectFuture.newFailedFuture(
                    new IOException( "Endpoint unavailable: " + address ) );
        }

        DefaultConnectFuture future = new DefaultConnectFuture();
        VmPipeSessionImpl localSession =
            new VmPipeSessionImpl(
                    this,
                    config,
                    getListeners(),
                    new Object(), // lock
                    new AnonymousSocketAddress(),
                    handler,
                    entry );

           // initialize acceptor session
        VmPipeSessionImpl remoteSession = localSession.getRemoteSession();
        try
        {
            IoFilterChain filterChain = remoteSession.getFilterChain();
            entry.getAcceptor().getFilterChainBuilder().buildFilterChain( filterChain );
            entry.getConfig().getFilterChainBuilder().buildFilterChain( filterChain );
            entry.getConfig().getThreadModel().buildFilterChain( filterChain );

            // The following sentences don't throw any exceptions.
            entry.getListeners().fireSessionCreated( remoteSession );
            VmPipeIdleStatusChecker.getInstance().addSession( remoteSession );
        }
        catch( Throwable t )
        {
            ExceptionMonitor.getInstance().exceptionCaught( t );
            remoteSession.close();
        }


        // initialize connector session
        try
        {
            IoFilterChain filterChain = localSession.getFilterChain();
            this.getFilterChainBuilder().buildFilterChain( filterChain );
            config.getFilterChainBuilder().buildFilterChain( filterChain );
            config.getThreadModel().buildFilterChain( filterChain );

            // The following sentences don't throw any exceptions.
            localSession.setAttribute( AbstractIoFilterChain.CONNECT_FUTURE, future );
            getListeners().fireSessionCreated( localSession );
            VmPipeIdleStatusChecker.getInstance().addSession( localSession);
        }
        catch( Throwable t )
        {
            future.setException( t );
        }



        return future;
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

                throw new IllegalArgumentException(
                        "IoHandler must be an instance of AbstractProxyIoHandler");
            }

            connector.setHandler(handler);
            future = new DefaultConnectFuture();
        }

        ConnectFuture conFuture = connector.connect(proxyIoSession
                .getProxyAddress(), new ProxyIoSessionInitializer(
                sessionInitializer, proxyIoSession));
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

        if (entry == null) {
            return DefaultConnectFuture.newFailedFuture(new IOException(
                    "Endpoint unavailable: " + remoteAddress));
        }

        DefaultConnectFuture future = new DefaultConnectFuture();

        // Assign the local address dynamically,
        VmPipeAddress actualLocalAddress;
        try {
            actualLocalAddress = nextLocalAddress();
        } catch (IOException e) {
            return DefaultConnectFuture.newFailedFuture(e);
        }

        VmPipeSession localSession = new VmPipeSession(this,
                getListeners(), actualLocalAddress, getHandler(), entry);

        initSession(localSession, future, sessionInitializer);

        // and reclaim the local address when the connection is closed.
        localSession.getCloseFuture().addListener(LOCAL_ADDRESS_RECLAIMER);

        // initialize connector session
        try {
            IoFilterChain filterChain = localSession.getFilterChain();
            this.getFilterChainBuilder().buildFilterChain(filterChain);

            // The following sentences don't throw any exceptions.
            getListeners().fireSessionCreated(localSession);
            idleChecker.addSession(localSession);
        } catch (Throwable t) {
            future.setException(t);
            return future;
        }

        // initialize acceptor session
        VmPipeSession remoteSession = localSession.getRemoteSession();
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

                        }

                        SerialPort serialPort = initializePort("Apache MINA",
                                portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
                        SerialSessionImpl session = new SerialSessionImpl(
                                this, getListeners(), portAddress, serialPort);
                        initSession(session, future, sessionInitializer);
                        session.start();
                        return future;
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

        assertTrue(future.isClosed());
    }

    @Test
    public void testConnectFuture() throws Exception {
        DefaultConnectFuture future = new DefaultConnectFuture();
        assertFalse(future.isDone());
        assertFalse(future.isConnected());
        assertNull(future.getSession());
        assertNull(future.getException());

        TestThread thread = new TestThread(future);
        thread.start();

        IoSession session = new DummySession();

        future.setSession(session);
        thread.join();

        assertTrue(thread.success);
        assertTrue(future.isDone());
        assertTrue(future.isConnected());
        assertEquals(session, future.getSession());
        assertNull(future.getException());

        future = new DefaultConnectFuture();
        thread = new TestThread(future);
        thread.start();
        future.setException(new IOException());
        thread.join();

        assertTrue(thread.success);
        assertTrue(future.isDone());
        assertFalse(future.isConnected());
        assertTrue(future.getException() instanceof IOException);

        try {
            future.getSession();
            fail("IOException should be thrown.");
        } catch (Exception e) {
        }
    }
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

        H handle = null;
        boolean success = false;
        try {
            handle = newHandle(localAddress);
            if (connect(handle, remoteAddress)) {
                ConnectFuture future = new DefaultConnectFuture();
                T session = newSession(processor, handle);
                initSession(session, future, sessionInitializer);
                // Forward the remaining process to the IoProcessor.
                session.getProcessor().add(session);
                success = true;
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

        H handle = null;
        boolean success = false;
        try {
            handle = newHandle(localAddress);
            if (connect(handle, remoteAddress)) {
                ConnectFuture future = new DefaultConnectFuture();
                T session = newSession(processor, handle);
                finishSessionInitialization(session, future, sessionInitializer);
                // Forward the remaining process to the IoProcessor.
                session.getProcessor().add(session);
                success = true;
View Full Code Here

Examples of org.apache.mina.core.future.DefaultConnectFuture

                        }

                        SerialPort serialPort = initializePort("Apache MINA",
                                portId, portAddress);

                        ConnectFuture future = new DefaultConnectFuture();
                        SerialSessionImpl session = new SerialSessionImpl(
                                this, getListeners(), portAddress, serialPort);
                        finishSessionInitialization(session, future, sessionInitializer);
                        session.start();
                        return future;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.