List of usage examples for org.springframework.remoting.support RemoteInvocation getArguments
public Object[] getArguments()
From source file:org.apache.mina.springrpc.ReturnAddressAwareRemoteInvocation.java
public ReturnAddressAwareRemoteInvocation(ReturnAddress returnAddress, RemoteInvocation decorated) { setReturnAddress(returnAddress);/*from www.j a va 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.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.jdal.remoting.ReferenceInvocationExecutor.java
/** * {@inheritDoc}/*from w w w. j a va2s .co m*/ */ public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Assert.notNull(invocation, "RemoteInvocation must not be null"); Assert.notNull(targetObject, "Target object must not be null"); // replace references with clients. Object[] arguments = invocation.getArguments(); for (int i = 0; i < arguments.length; i++) { if (arguments[i] instanceof RemoteReference) { arguments[i] = ((RemoteReference) arguments[i]).createRemoteClient(); } } return invocation.invoke(targetObject); }
From source file:org.nebulaframework.grid.cluster.manager.services.jobs.remote.RemoteJobRequestMessageConverter.java
/** * Attaches a String property to the JMS Messages which * indicates the target cluster's Cluster ID. * /*from w w w.j av a2s .c o m*/ * @param object Object to be converted * @param JMS Session * * @return JMS Message */ @Override public Message toMessage(Object object, Session session) throws JMSException, MessageConversionException { Message m = super.toMessage(object, session); if (object instanceof RemoteInvocation) { RemoteInvocation invocation = (RemoteInvocation) object; // If its a invocation of remoteJobRequest if (invocation.getMethodName().equals("remoteJobRequest")) { // Attach Target ClusterID m.setStringProperty("targetClusterId", parseClusterId((String) invocation.getArguments()[0])); } } return m; }
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 w w .j av a 2 s. 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 . j av a 2 s. c o m*/ 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 ava 2 s . com*/ * @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()); }