Example usage for org.springframework.remoting.support RemoteInvocation getParameterTypes

List of usage examples for org.springframework.remoting.support RemoteInvocation getParameterTypes

Introduction

In this page you can find the example usage for org.springframework.remoting.support RemoteInvocation getParameterTypes.

Prototype

public Class<?>[] getParameterTypes() 

Source Link

Document

Return the parameter types of the target method.

Usage

From source file:org.logicblaze.lingo.jms.impl.AsyncReplyHandler.java

protected boolean isEndSessionMethod(RemoteInvocation invocation) {
    Method method;//from w w w. ja v  a 2  s  .  c  o m
    try {
        method = getProxy().getClass().getMethod(invocation.getMethodName(), invocation.getParameterTypes());
    } catch (Exception e) {
        onException(invocation, e);
        return false;
    }
    return metadataStrategy.getMethodMetadata(method).isEndSession();
}

From source file:com.seajas.search.utilities.remoting.JsonHttpSupport.java

@Test
public void invocation() throws Exception {
    String method = "testMethodName";
    Class[] types = new Class[] { Boolean.class, String.class, Number.class };
    Object[] arguments = new Object[] { Boolean.TRUE, null, new Integer(2) };
    RemoteInvocation invocation = new RemoteInvocation(method, types, arguments);

    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    executor.writeRemoteInvocation(invocation, buffer);
    ByteArrayInputStream stream = new ByteArrayInputStream(buffer.toByteArray());
    RemoteInvocation deserialized = exporter.readRemoteInvocation(null, stream);
    assertEquals("method", method, deserialized.getMethodName());
    assertArrayEquals("types", types, deserialized.getParameterTypes());
    assertArrayEquals("arguments", arguments, deserialized.getArguments());
}

From source file:org.apache.mina.springrpc.ReturnAddressAwareRemoteInvocation.java

public ReturnAddressAwareRemoteInvocation(ReturnAddress returnAddress, RemoteInvocation decorated) {
    setReturnAddress(returnAddress);/*w w w.  j  a  v a 2 s. c  o m*/
    setArguments(decorated.getArguments());
    setAttributes(decorated.getAttributes());
    setMethodName(decorated.getMethodName());
    setParameterTypes(decorated.getParameterTypes());
}

From source file:com.seajas.search.utilities.remoting.JsonInvokerRequestExecutor.java

@Override
protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException {
    JsonGenerator generator = factory.createJsonGenerator(os);
    generator.writeStartObject();/*from   w ww  . j  a v a2s  .  c o m*/

    generator.writeFieldName("method");
    generator.writeString(invocation.getMethodName());

    generator.writeArrayFieldStart("types");
    for (Class type : invocation.getParameterTypes())
        generator.writeString(type.getName());
    generator.writeEndArray();

    generator.writeArrayFieldStart("arguments");
    for (Object argument : invocation.getArguments())
        generator.writeObject(argument);
    generator.writeEndArray();

    generator.writeEndObject();
    generator.close();
}

From source file:com.springsource.insight.plugin.springweb.remoting.SimpleHttpInvokerRequestExecutorAspectTest.java

@Test
public void testSimpleHttpInvokerRequestExecutor() throws Exception {
    RemoteInvocation invocation = new RemoteInvocation("testSimpleHttpInvokerRequestExecutor",
            new Class[] { Long.class }, new Object[] { Long.valueOf(System.nanoTime()) });
    TestingSimpleHttpInvokerRequestExecutor executor = new TestingSimpleHttpInvokerRequestExecutor(
            invocation.getMethodName());
    HttpInvokerClientConfiguration config = createMockConfiguration(executor.getColor(),
            ArrayUtil.EMPTY_STRINGS);/*w w  w  .ja  va  2  s. c  om*/
    RemoteInvocationResult result = executor.executeRequest(config, invocation);
    Object value = result.getValue();
    assertNotNull("No result value", value);
    assertTrue("Bad result value type: " + value.getClass().getSimpleName(), value instanceof RemoteInvocation);

    RemoteInvocation resultValue = (RemoteInvocation) value;
    assertEquals("Mismatched result method", invocation.getMethodName(), resultValue.getMethodName());
    assertArrayEquals("Mismatched result signature", invocation.getParameterTypes(),
            resultValue.getParameterTypes());
    assertArrayEquals("Mismatched result arguments", invocation.getArguments(), resultValue.getArguments());

    Operation op = assertRemotingOperation(config);
    assertEquals("Mismatched request method", executor.getMethod(), op.get("method", String.class));

    ExternalResourceDescriptor desc = assertExternalResource(op);
    assertNotNull("No external resource generated", desc);
}

From source file:org.springframework.remoting.rmi.RmiServiceExporter.java

/**
 * Apply the given remote invocation to the given target object.
 * The default implementation performs a plain method invocation.
 * <p>Can be overridden in subclasses for custom invocation behavior,
 * possibly for applying additional invocation parameters from a
 * custom RemoteInvocation subclass. Will typically match a corresponding
 * custom invoke implementation in RmiClientInterceptor/RmiProxyFactoryBean.
 * @param invocation the remote invocation
 * @param targetObject the target object to apply the invocation to
 * @return the invocation result// w w  w.  j  a  v  a2 s .  co m
 * @throws NoSuchMethodException if the method name could not be resolved
 * @throws IllegalAccessException if the method could not be accessed
 * @throws InvocationTargetException if the method invocation resulted in an exception
 * @see RmiClientInterceptor#invoke
 */
protected Object invoke(RemoteInvocation invocation, Object targetObject)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
    Method method = targetObject.getClass().getMethod(invocation.getMethodName(),
            invocation.getParameterTypes());
    return method.invoke(targetObject, invocation.getArguments());
}