Package org.springframework.remoting.support

Examples of org.springframework.remoting.support.RemoteInvocation


   * @see #invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)
   * @see #writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange, org.springframework.remoting.support.RemoteInvocationResult)
   */
  public void handle(HttpExchange exchange) throws IOException {
    try {
      RemoteInvocation invocation = readRemoteInvocation(exchange);
      RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy());
      writeRemoteInvocationResult(exchange, result);
      exchange.close();
    }
    catch (ClassNotFoundException ex) {
View Full Code Here


  public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    if (AopUtils.isToStringMethod(methodInvocation.getMethod())) {
      return "HTTP invoker proxy for service URL [" + getServiceUrl() + "]";
    }

    RemoteInvocation invocation = createRemoteInvocation(methodInvocation);
    RemoteInvocationResult result = null;
    try {
      result = executeRequest(invocation, methodInvocation);
    }
    catch (Throwable ex) {
View Full Code Here

   */
  public void handleRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    try {
      RemoteInvocation invocation = readRemoteInvocation(request);
      RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy());
      writeRemoteInvocationResult(request, response, result);
    }
    catch (ClassNotFoundException ex) {
      throw new NestedServletException("Class not found during deserialization", ex);
View Full Code Here

    HttpInvokerProxyFactoryBean pfb = new HttpInvokerProxyFactoryBean();
    pfb.setServiceInterface(ITestBean.class);
    pfb.setServiceUrl("http://myurl");
    pfb.setRemoteInvocationFactory(new RemoteInvocationFactory() {
      public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
        RemoteInvocation invocation = new RemoteInvocation(methodInvocation);
        invocation.addAttribute("myKey", "myValue");
        try {
          invocation.addAttribute("myKey", "myValue");
          fail("Should have thrown IllegalStateException");
        }
        catch (IllegalStateException ex) {
          // expected: already defined
        }
        assertNotNull(invocation.getAttributes());
        assertEquals(1, invocation.getAttributes().size());
        assertEquals("myValue", invocation.getAttributes().get("myKey"));
        assertEquals("myValue", invocation.getAttribute("myKey"));
        return invocation;
      }
    });

    pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
View Full Code Here

    HttpInvokerProxyFactoryBean pfb = new HttpInvokerProxyFactoryBean();
    pfb.setServiceInterface(ITestBean.class);
    pfb.setServiceUrl("http://myurl");
    pfb.setRemoteInvocationFactory(new RemoteInvocationFactory() {
      public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
        RemoteInvocation invocation = new TestRemoteInvocation(methodInvocation);
        assertNull(invocation.getAttributes());
        assertNull(invocation.getAttribute("myKey"));
        return invocation;
      }
    });

    pfb.setHttpInvokerRequestExecutor(new AbstractHttpInvokerRequestExecutor() {
View Full Code Here

      public AccessibleObject getStaticPart() {
        return setNameMethod;
      }
    };

    RemoteInvocation inv = new RemoteInvocation(mi);

    assertEquals("setName", inv.getMethodName());
    assertEquals("bla", inv.getArguments()[0]);
    assertEquals(String.class, inv.getParameterTypes()[0]);

    // this is a bit BS, but we need to test it
    inv = new RemoteInvocation();
    inv.setArguments(new Object[] { "bla" });
    assertEquals("bla", inv.getArguments()[0]);
    inv.setMethodName("setName");
    assertEquals("setName", inv.getMethodName());
    inv.setParameterTypes(new Class[] {String.class});
    assertEquals(String.class, inv.getParameterTypes()[0]);

    inv = new RemoteInvocation("setName", new Class[] {String.class}, new Object[] {"bla"});
    assertEquals("bla", inv.getArguments()[0]);
    assertEquals("setName", inv.getMethodName());
    assertEquals(String.class, inv.getParameterTypes()[0]);
  }
View Full Code Here

            }

            public Result invoke(Invocation invocation) throws RpcException {
                RpcResult result = new RpcResult();
                try {
                    RemoteInvocation i = new RemoteInvocation();
                    i.setMethodName(invocation.getMethodName());
                    i.setParameterTypes(invocation.getParameterTypes());
                    i.setArguments(invocation.getArguments());
                    result.setValue(((RmiInvocationHandler) remote).invoke(i));
                } catch (InvocationTargetException e) {
                    result.setException(e.getTargetException());
                } catch (Exception e) {
                    throw new RpcException(StringUtils.toString(e), e);
View Full Code Here

        }

        public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
                throws IOException, ServletException {
            ObjectInputStream reqStream = new ObjectInputStream(request.getInputStream());
            RemoteInvocation invocation;
            try {
                invocation = (RemoteInvocation) reqStream.readObject();
            } catch (ClassNotFoundException e) {
                throw new ServletException("Failed to load invocation class: " + e.getMessage(), e);
            } finally {
                reqStream.close();
            }

            System.out.println("Invocation: " + invocation + " - args=" + Arrays.toString(invocation.getArguments()));
            assertEquals("Mismatched target value", "/" + invocation.getMethodName(), target);

            String color = request.getHeader(Color.TOKEN_NAME);
            assertFalse("No color provided", StringUtil.isEmpty(color));

            RemoteInvocationResult result = new RemoteInvocationResult(invocation);
View Full Code Here

    }

    @Test
    public void testSuccessfulRemoteInvocation() throws Exception {
        TestInvoker invoker = new TestInvoker(Long.valueOf(System.currentTimeMillis()));
        RemoteInvocation invocation = invoker.createRemoteInvocation("testSuccessfulRemoteInvocation");
        invocation.setAttributes(Collections.singletonMap("testSuccessfulRemoteInvocation", (Serializable) Long.valueOf(System.currentTimeMillis())));

        HttpInvokerClientConfiguration config =
                createMockConfiguration(invocation.getMethodName(), "http://hello/world", "http://here/testSuccessfulRemoteInvocation");
        RemoteInvocationResult result = invoker.executeRequest(config, invocation);
        Operation op = assertRemotingOperation(config, invocation, result);
        ExternalResourceDescriptor desc = assertExternalResource(op);
        assertNull("Unexpected external descriptor: " + desc, desc);
    }
View Full Code Here

    }

    @Test
    public void testFailedRemoteInvocation() throws Exception {
        TestInvoker invoker = new TestInvoker(new UnsupportedOperationException("testFailedRemoteInvocation"));
        RemoteInvocation invocation = invoker.createRemoteInvocation("testFailedRemoteInvocation");
        invocation.setAttributes(Collections.singletonMap("testFailedRemoteInvocation", (Serializable) Long.valueOf(System.currentTimeMillis())));

        HttpInvokerClientConfiguration config =
                createMockConfiguration(invocation.getMethodName(), "http://goodbye/world", "http://there/testFailedRemoteInvocation");
        RemoteInvocationResult result = invoker.executeRequest(config, invocation);
        Operation op = assertRemotingOperation(config, invocation, result);
        ExternalResourceDescriptor desc = assertExternalResource(op);
        assertNull("Unexpected external descriptor: " + desc, desc);
        assertTraceError(op, result);
View Full Code Here

TOP

Related Classes of org.springframework.remoting.support.RemoteInvocation

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.