Package org.activeio.adapter

Examples of org.activeio.adapter.SynchToAsynchChannelServerAdapter


    protected ChannelServer createChannelServer(final RequestListener requestListener) throws IOException, URISyntaxException {

        SynchChannelFactory factory = new SocketSynchChannelFactory();
       
        AsynchChannelServer server = new SynchToAsynchChannelServerAdapter(factory.bindSynchChannel(new URI("tcp://localhost:0")));
       
        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
             
                RequestChannel requestChannel = null;
                try {
                    ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
                    requestChannel =
                        new AsynchChannelToServerRequestChannel(
                            new PacketAggregatingAsynchChannel(
                                    SynchToAsynchChannelAdapter.adapt(channel)));

                    requestChannel.setRequestListener(requestListener);
                    requestChannel.start();

                } catch (IOException e) {
                    if (requestChannel != null)
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }

            public void onAcceptError(IOException error) {
                error.printStackTrace();
            }
        });
        serverURI = server.getConnectURI();
        return server;
    }
View Full Code Here


    }
   
    private AsynchChannelServer createAsynchChannelServer() throws IOException, URISyntaxException {
        SocketSynchChannelFactory factory = new SocketSynchChannelFactory();
        SynchChannelServer server = factory.bindSynchChannel(bindURI);
        return new SynchToAsynchChannelServerAdapter(server);       
    }
View Full Code Here

        context = new LoginContext("properties", new AbstractTest.UsernamePasswordCallback("izumi", "violin"));
        context.login();
        serverSubject = context.getSubject();

        SocketSynchChannelFactory factory = new SocketSynchChannelFactory();
        server = new SynchToAsynchChannelServerAdapter(
                factory.bindSynchChannel(new URI("tcp://localhost:0")));

        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel=null;
View Full Code Here

TOP

Related Classes of org.activeio.adapter.SynchToAsynchChannelServerAdapter

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.