List of usage examples for org.springframework.remoting.support RemoteInvocation getMethodName
public String getMethodName()
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.logicblaze.lingo.jms.impl.AsyncReplyHandler.java
protected boolean isEndSessionMethod(RemoteInvocation invocation) { Method method;//ww w . j a va 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: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. * /*w w w .j a va 2s. co 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:org.apache.mina.springrpc.ReturnAddressAwareRemoteInvocation.java
public ReturnAddressAwareRemoteInvocation(ReturnAddress returnAddress, RemoteInvocation decorated) { setReturnAddress(returnAddress);/* ww w . j a v a 2 s . c om*/ setArguments(decorated.getArguments()); setAttributes(decorated.getAttributes()); setMethodName(decorated.getMethodName()); setParameterTypes(decorated.getParameterTypes()); }
From source file:org.piraso.replacer.spring.remoting.PirasoSimpleHttpInvokerRequestExecutor.java
@Override protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException { if (context.isMonitored()) { context.addProperty(PirasoSimpleHttpInvokerRequestExecutor.class, METHOD_NAME_HEADER, invocation.getMethodName()); }//from ww w. j a v a 2s.com super.writeRemoteInvocation(invocation, os); }
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 .java 2s . 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 2s. 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 a v a2 s .c om * @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()); }