Package org.apache.mina.core.future

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


        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

                        }

                        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

        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

        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

        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

                        }

                        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

        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);

        finishSessionInitialization(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

        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

                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

TOP

Related Classes of org.apache.mina.core.future.DefaultConnectFuture

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.