Package org.activeio

Examples of org.activeio.RequestChannel


    public InvocationResult invoke(Invocation invocation) throws Throwable {

        ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
        try {

            RequestChannel channel = createRequestChannel(target);
            Packet response;
            try {
                channel.start();
                Packet request = serialize(invocation);
                response = channel.request(request, Service.WAIT_FOREVER_TIMEOUT);
            } finally {
                channel.dispose();               
            }
           
            Object obj;
            try {           
                obj =  deserialize(response, cl);
View Full Code Here


        final ReflexiveInterceptor loginServiceInterceptor = new ReflexiveInterceptor(loginService);

        server = createAsyncChannelServer();
        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel = null;
                try {
                    SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);
                    SocketMetadata socket = (SocketMetadata) syncChannel.narrow(SocketMetadata.class);
                    socket.setTcpNoDelay(true);

                    requestChannel = createRequestChannel(syncChannel);

                    RequestChannelInterceptorInvoker invoker = new RequestChannelInterceptorInvoker(loginServiceInterceptor, loginService.getClass().getClassLoader());
                    requestChannel.setRequestListener(invoker);
                    requestChannel.start();
                } catch (IOException e) {
                    log.warn("Failed to accept connection.", e);
                    if (requestChannel != null)
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }
View Full Code Here

     * Enable this test again once its working.
     */
    public void disabledtest() throws Exception {

        SocketSyncChannelFactory factory = new SocketSyncChannelFactory();
        final RequestChannel channel =
            new AsyncChannelToClientRequestChannel(
                AsyncToSyncChannel.adapt(
                    new SubjectCarryingChannel(
                        new PacketAggregatingAsyncChannel(
                            SyncToAsyncChannel.adapt(
                                 factory.openSyncChannel(serverURI))))));
        try {
            channel.start();
          Subject.doAs(clientSubject, new PrivilegedExceptionAction() {
              public Object run() throws Exception {

                  Subject subject = Subject.getSubject(AccessController.getContext());
                  String p = subject.getPrincipals().iterator().next().toString();
                  log.info("Sending request as: "+p);

                    Packet request = new ByteArrayPacket("whoami".getBytes());
                    Packet response = channel.request(request, 1000*5*1000);

                    assertNotNull(response);
                    assertEquals( p, new String(response.sliceAsBytes()) );
                    return null;
              }
          });
        } finally {
            channel.dispose();
        }
    }
View Full Code Here

        server = new SyncToAsyncChannelServer(
                factory.bindSyncChannel(new URI("tcp://localhost:0")));

        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel=null;
                try {

                    requestChannel =
                        new AsyncChannelToServerRequestChannel(
                          new SubjectCarryingChannel(
                              new PacketAggregatingAsyncChannel(
                                  SyncToAsyncChannel.adapt(channel))));

                    requestChannel.setRequestListener(SubjectCarryingProtocolTest.this);
                    requestChannel.start();

                } catch (IOException e) {
                    log.info("Failed to accept connection.", e);
                    if( requestChannel!=null )
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }
            public void onAcceptError(IOException error) {
View Full Code Here

     * Enable this test again once its working.
     */
    public void disabledtest() throws Exception {

        SocketSyncChannelFactory factory = new SocketSyncChannelFactory();
        final RequestChannel channel =
            new AsyncChannelToClientRequestChannel(
                AsyncToSyncChannel.adapt(
                    new SubjectCarryingChannel(
                        new PacketAggregatingAsyncChannel(
                            SyncToAsyncChannel.adapt(
                                 factory.openSyncChannel(serverURI))))));
        try {
            channel.start();
          Subject.doAs(clientSubject, new PrivilegedExceptionAction() {
              public Object run() throws Exception {

                  Subject subject = Subject.getSubject(AccessController.getContext());
                  String p = subject.getPrincipals().iterator().next().toString();
                  log.info("Sending request as: "+p);

                    Packet request = new ByteArrayPacket("whoami".getBytes());
                    Packet response = channel.request(request, 1000*5*1000);

                    assertNotNull(response);
                    assertEquals( p, new String(response.sliceAsBytes()) );
                    return null;
              }
          });
        } finally {
            channel.dispose();
        }
    }
View Full Code Here

        final ReflexiveInterceptor loginServiceInterceptor = new ReflexiveInterceptor(loginService);

        server = createAsyncChannelServer();
        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel = null;
                try {
                    SyncChannel syncChannel = AsyncToSyncChannel.adapt(channel);
                    SocketMetadata socket = (SocketMetadata) syncChannel.narrow(SocketMetadata.class);
                    socket.setTcpNoDelay(true);

                    requestChannel = createRequestChannel(syncChannel);

                    RequestChannelInterceptorInvoker invoker = new RequestChannelInterceptorInvoker(loginServiceInterceptor, loginService.getClass().getClassLoader());
                    requestChannel.setRequestListener(invoker);
                    requestChannel.start();
                } catch (IOException e) {
                    log.info("Failed to accept connection.", e);
                    if (requestChannel != null)
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }
View Full Code Here

        server = new SyncToAsyncChannelServer(
                factory.bindSyncChannel(new URI("tcp://localhost:0")));

        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel=null;
                try {

                    requestChannel =
                        new AsyncChannelToServerRequestChannel(
                          new SubjectCarryingChannel(
                              new PacketAggregatingAsyncChannel(
                                  SyncToAsyncChannel.adapt(channel))));

                    requestChannel.setRequestListener(SubjectCarryingProtocolTest.this);
                    requestChannel.start();

                } catch (IOException e) {
                    log.info("Failed to accept connection.", e);
                    if( requestChannel!=null )
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }
            public void onAcceptError(IOException error) {
View Full Code Here

    public InvocationResult invoke(Invocation invocation) throws Throwable {

        ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
        try {

            RequestChannel channel = createRequestChannel(target);
            Packet response;
            try {
                channel.start();
                Packet request = serialize(invocation);
                response = channel.request(request, Service.WAIT_FOREVER_TIMEOUT);
            } finally {
                channel.dispose();               
            }
           
            Object obj;
            try {           
                obj =  deserialize(response, cl);
View Full Code Here

     * Enable this test again once its working.
     */
    public void disabledtest() throws Exception {

        SocketSyncChannelFactory factory = new SocketSyncChannelFactory();
        final RequestChannel channel =
            new AsyncChannelToClientRequestChannel(
                AsyncToSyncChannel.adapt(
                    new SubjectCarryingChannel(
                        new PacketAggregatingAsyncChannel(
                            SyncToAsyncChannel.adapt(
                                 factory.openSyncChannel(serverURI))))));
        try {
            channel.start();
          Subject.doAs(clientSubject, new PrivilegedExceptionAction() {
              public Object run() throws Exception {

                  Subject subject = Subject.getSubject(AccessController.getContext());
                  String p = subject.getPrincipals().iterator().next().toString();
                  log.info("Sending request as: "+p);

                    Packet request = new ByteArrayPacket("whoami".getBytes());
                    Packet response = channel.request(request, 1000*5*1000);

                    assertNotNull(response);
                    assertEquals( p, new String(response.sliceAsBytes()) );
                    return null;
              }
          });
        } finally {
            channel.dispose();
        }
    }
View Full Code Here

        server = new SyncToAsyncChannelServer(
                factory.bindSyncChannel(new URI("tcp://localhost:0")));

        server.setAcceptListener(new AcceptListener() {
            public void onAccept(Channel channel) {
                RequestChannel requestChannel=null;
                try {

                    requestChannel =
                        new AsyncChannelToServerRequestChannel(
                          new SubjectCarryingChannel(
                              new PacketAggregatingAsyncChannel(
                                  SyncToAsyncChannel.adapt(channel))));

                    requestChannel.setRequestListener(SubjectCarryingProtocolTest.this);
                    requestChannel.start();

                } catch (IOException e) {
                    log.info("Failed to accept connection.", e);
                    if( requestChannel!=null )
                        requestChannel.dispose();
                    else
                        channel.dispose();
                }
            }
            public void onAcceptError(IOException error) {
View Full Code Here

TOP

Related Classes of org.activeio.RequestChannel

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.