Examples of IoHandler


Examples of org.apache.mina.common.IoHandler

*/
public class IoAcceptorFactoryBeanTest extends TestCase
{
    public void testBindUnbind() throws Exception
    {
        IoHandler handler1 = new IoHandlerAdapter();
        IoHandler handler2 = new IoHandlerAdapter();
        IoHandler handler3 = new IoHandlerAdapter();
        IoServiceConfig config1 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        IoServiceConfig config2 =
            ( IoServiceConfig ) MockControl.createControl( IoServiceConfig.class ).getMock();
        MockControl mockIoAcceptor = MockControl.createControl( IoAcceptor.class );
View Full Code Here

Examples of org.apache.mina.common.IoHandler

        super.doStart();
        if (LOG.isInfoEnabled()) {
            LOG.info("Binding to server address: " + address + " using acceptor: " + acceptor);
        }

        IoHandler handler = new ReceiveHandler();
        acceptor.bind(address, handler, endpoint.getAcceptorConfig());
    }
View Full Code Here

Examples of org.apache.mina.common.IoHandler

        SocketAddress address = endpoint.getAddress();
        connector = endpoint.getConnector();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Creating connector to address: " + address + " using connector: " + connector + " timeout: " + timeout + " millis.");
        }
        IoHandler ioHandler = new ResponseHandler(endpoint);
        // connect and wait until the connection is established
        ConnectFuture future = connector.connect(address, ioHandler, endpoint.getConnectorConfig());
        future.join();
        session = future.getSession();
    }
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

            final SocketAddress remoteAddress,
            final SocketAddress localAddress,
            final IoSessionInitializer<? extends ConnectFuture> sessionInitializer) {
        if (!proxyIoSession.isReconnectionNeeded()) {
            // First connection
            IoHandler handler = getHandler();
            if (!(handler instanceof AbstractProxyIoHandler)) {
                throw new IllegalArgumentException(
                        "IoHandler must be an instance of AbstractProxyIoHandler");
            }
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

    }

    public void testAcceptorFilterChain() throws Exception {
        int port = AvailablePortFinder.getNextAvailable(1024);
        IoFilter mockFilter = new MockFilter();
        IoHandler mockHandler = new MockHandler();

        acceptor.getFilterChain().addLast("mock", mockFilter);
        acceptor.setHandler(mockHandler);
        acceptor.bind(new InetSocketAddress(port));
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

        DummySession session = new DummySession();
        session.setService(mockService);
        session.setLocalAddress(ADDRESS);

        IoHandler handler = EasyMock.createStrictMock( IoHandler.class );
        session.setHandler(handler);

        IoServiceListener listener = EasyMock.createStrictMock(IoServiceListener.class);

        // Test creation
        listener.sessionCreated(session);
        handler.sessionCreated(session);
        handler.sessionOpened(session);

        EasyMock.replay(listener);
        EasyMock.replay(handler);

        support.add(listener);
        support.fireSessionCreated(session);

        EasyMock.verify(listener);
        EasyMock.verify(handler);

        assertEquals(1, support.getManagedSessions().size());
        assertSame(session, support.getManagedSessions().get(session.getId()));

        // Test destruction & other side effects
        EasyMock.reset(listener);
        EasyMock.reset(handler);
        handler.sessionClosed(session);
        listener.sessionDestroyed(session);

        EasyMock.replay(listener);
        //// Activate more than once
        support.fireSessionCreated(session);
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

        final DummySession session = new DummySession();
        session.setService(acceptor);
        session.setLocalAddress(ADDRESS);

        IoHandler handler = EasyMock.createStrictMock(IoHandler.class);
        session.setHandler(handler);

        final IoServiceListener listener = EasyMock.createStrictMock(IoServiceListener.class);

        // Activate a service and create a session.
        listener.serviceActivated(acceptor);
        listener.sessionCreated(session);
        handler.sessionCreated(session);
        handler.sessionOpened(session);

        EasyMock.replay(listener);
        EasyMock.replay(handler);

        support.add(listener);
        support.fireServiceActivated();
        support.fireSessionCreated(session);

        EasyMock.verify(listener);
        EasyMock.verify(handler);

        // Deactivate a service and make sure the session is closed & destroyed.
        EasyMock.reset(listener);
        EasyMock.reset(handler);

        listener.serviceDeactivated(acceptor);
        EasyMock.expect(acceptor.isCloseOnDeactivation()).andReturn(true);
        listener.sessionDestroyed(session);
        handler.sessionClosed(session);

        EasyMock.replay(listener);
        EasyMock.replay(acceptor);
        EasyMock.replay(handler);
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

        final DummySession session = new DummySession();
        session.setService(connector);
        session.setRemoteAddress(ADDRESS);

        IoHandler handler = EasyMock.createStrictMock(IoHandler.class);
        session.setHandler(handler);

        IoServiceListener listener = EasyMock.createStrictMock(IoServiceListener.class);

        // Creating a session should activate a service automatically.
        listener.serviceActivated(connector);
        listener.sessionCreated(session);
        handler.sessionCreated(session);
        handler.sessionOpened(session);

        EasyMock.replay(listener);
        EasyMock.replay(handler);

        support.add(listener);
        support.fireSessionCreated(session);

        EasyMock.verify(listener);
        EasyMock.verify(handler);

        // Destroying a session should deactivate a service automatically.
        EasyMock.reset(listener);
        EasyMock.reset(handler);
        listener.sessionDestroyed(session);
        handler.sessionClosed(session);
        listener.serviceDeactivated(connector);

        EasyMock.replay(listener);
        EasyMock.replay(handler);
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

    @Override
    protected void doStart() throws Exception {
        super.doStart();

        IoHandler handler = new ReceiveHandler();
        acceptor.setHandler(handler);
        acceptor.bind(address);
        LOG.info("Bound to server address: {} using acceptor: {}", address, acceptor);
    }
View Full Code Here

Examples of org.apache.mina.core.service.IoHandler

     * in the handler.
     * @throws IOException if there are issues binding
     */
    public void start() throws IOException
    {
        IoHandler ntpProtocolHandler = new NtpProtocolHandler();
       
        // Create the chain for the NTP server
        DefaultIoFilterChainBuilder ntpChain = new DefaultIoFilterChainBuilder();
        ntpChain.addLast( "codec", new ProtocolCodecFilter( NtpProtocolCodecFactory.getInstance() ) );
       
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.