Package org.activeio

Examples of org.activeio.SynchChannel


        log.info("HTTP response: " + b);
    }

    protected void hitIIOPServer() throws Exception {
        SynchChannel channel = channelFactory.openSynchChannel(server.getConnectURI());
        ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
        channel.write(new ByteArrayPacket("GIOPcrapcrap".getBytes("UTF-8")));
        channel.flush();
        channel.dispose();
    }
View Full Code Here


        channel.flush();
        channel.dispose();
    }

    public void testUnknownAccept() throws IOException, URISyntaxException, InterruptedException {
        SynchChannel channel = channelFactory.openSynchChannel(server.getConnectURI());
        ((SocketMetadata)channel.narrow(SocketMetadata.class)).setTcpNoDelay(true);
        channel
                .write(new ByteArrayPacket("Licensed under the Apache License, Version 2.0 (the \"License\")"
                        .getBytes("UTF-8")));
        channel.flush();
        String type = (String) resultSlot.poll(1000 * 5);
        assertNull(type);
        channel.dispose();
    }
View Full Code Here

        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 {
                        Packet packet = super.read(timeout);
                        if( packet!=null && packet.hasRemaining() )
                            serverPacketCounter.increment();
View Full Code Here

    public Socket accept() throws IOException {
        Channel channel = channelServer.accept(timeout);
        if( channel==null )
            throw new InterruptedIOException();
       
        SynchChannel synchChannel = AsynchToSynchChannelAdapter.adapt(channel);           
        synchChannel.start();
        return new SynchChannelToSocketAdapter(synchChannel);
                   
    }
View Full Code Here

        this.createWriteBufferedChannels = createWriteBufferedChannels;
    this.useDirectBuffers = useDirectBuffers;
    }
   
    protected Channel createChannel(Socket socket) throws IOException {
        SynchChannel channel = new NIOSynchChannel(socket.getChannel());
        if( createWriteBufferedChannels ) {
            channel = new WriteBufferedSynchChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
        }
        return channel;
    }
View Full Code Here

     * @param channel
     * @return
     * @throws IOException
     */
    protected SynchChannel createSynchChannel(SocketChannel socketChannel) throws IOException {
        SynchChannel channel = new NIOSynchChannel(socketChannel);
        if( createWriteBufferedChannels ) {
            channel = new WriteBufferedSynchChannel(channel, ByteBufferPacket.createDefaultBuffer(useDirectBuffers));
        }
        return channel;
    }
View Full Code Here

        }
    }
   
    private static RequestChannel createRequestChannel(URI target) throws IOException, URISyntaxException {
        SocketSynchChannelFactory factory = new SocketSynchChannelFactory();
        SynchChannel channel = factory.openSynchChannel(target);
        SocketMetadata socket = (SocketMetadata) channel.narrow(SocketMetadata.class);
        socket.setTcpNoDelay(true);
        return new AsynchChannelToClientRequestChannel(
                 new PacketAggregatingSynchChannel(
                       channel));       
    }
View Full Code Here

        server = createAsynchChannelServer();
        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel=null;
                try {
                    SynchChannel synchChannel = AsynchToSynchChannelAdapter.adapt(channel);
                    SocketMetadata socket = (SocketMetadata) synchChannel.narrow(SocketMetadata.class);
                    socket.setTcpNoDelay(true);
                   
                    requestChannel = createRequestChannel(synchChannel);    
                   
                    RequestChannelInterceptorInvoker invoker = new RequestChannelInterceptorInvoker(loginServiceInterceptor, loginService.getClass().getClassLoader() );
View Full Code Here

TOP

Related Classes of org.activeio.SynchChannel

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.