Package org.activeio

Examples of org.activeio.AsynchChannelServer


    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


            public Thread newThread(Runnable arg0) {
                return new Thread(arg0, "activeio:"+(count++));
            }});
        AsynchChannelFactory factory = SynchToAsynchChannelFactoryAdaptor.adapt(channelFactory,executor);

        AsynchChannelServer cs = factory.bindAsynchChannel(new URI("tcp://localhost:0"));
        cs = new FilterAsynchChannelServer(cs) {
            public void onAccept(Channel channel) {
                SynchChannel synchChannel = AsynchToSynchChannelAdapter.adapt(channel);               
                super.onAccept(new FilterSynchChannel(synchChannel) {
                    public org.activeio.Packet read(long timeout) throws IOException {
View Full Code Here

            echoedBytesCounter.reset();
           
            shutdownLatch = new Latch();
               
            ChannelFactory factory = new ChannelFactory();
            AsynchChannelServer server = factory.bindAsynchChannel(url);
            System.out.println("Server accepting connections on: "+server.getConnectURI());
            server.setAcceptListener(this);
            server.start();
           
            while(!shutdownLatch.attempt(sampleInterval)) {
                printSampleData();
            }
           
            System.out.println("Stopping server.");
            server.stop(1000*5);
            server.dispose();
           
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
        }
View Full Code Here

     * @param bindAddress
     * @return the TransportChannel bound to the remote node
     * @throws JMSException
     */
    public TransportServerChannel create(WireFormat wireFormat, URI bindAddress) throws JMSException {
        AsynchChannelServer server = createAsynchChannelServer(bindAddress);
        return new ActiveIOTransportServerChannel(wireFormat, server);
    }
View Full Code Here

     * @return
     */
    private AsynchChannelServer createAsynchChannelServer(URI bindAddress) throws JMSException {
        try {
            bindAddress = URIConverter.convert(bindAddress);
            AsynchChannelServer server = new ChannelFactory().bindAsynchChannel(bindAddress);
            return server;
        } catch (IOException e) {
            throw JMSExceptionHelper.newJMSException(e.getMessage(), e);
        } catch (URISyntaxException e) {
            throw JMSExceptionHelper.newJMSException(e.getMessage(), e);
View Full Code Here

     * @param bindAddress
     * @return the TransportChannel bound to the remote node
     * @throws JMSException
     */
    public TransportServerChannel create(WireFormat wireFormat, URI bindAddress) throws JMSException {
        AsynchChannelServer server = createAsynchChannelServer(bindAddress);
        return new ActiveIOTransportServerChannel(wireFormat, server);
    }
View Full Code Here

     * @return
     */
    private AsynchChannelServer createAsynchChannelServer(URI bindAddress) throws JMSException {
        try {
            bindAddress = URIConverter.convert(bindAddress);
            AsynchChannelServer server = new ChannelFactory().bindAsynchChannel(bindAddress);
            return server;
        } catch (IOException e) {
            throw JMSExceptionHelper.newJMSException(e.getMessage(), e);
        } catch (URISyntaxException e) {
            throw JMSExceptionHelper.newJMSException(e.getMessage(), e);
View Full Code Here

TOP

Related Classes of org.activeio.AsynchChannelServer

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.