Encapsulates a remote invocation, providing core method invocation properties
in a serializable fashion. Used for RMI and HTTP-based serialization invokers.
This is an SPI class, typically not used directly by applications.
Can be subclassed for additional invocation parameters.
| Method from org.springframework.remoting.support.RemoteInvocation Detail: |
public void addAttribute(String key,
Serializable value) throws IllegalStateException {
if (this.attributes == null) {
this.attributes = new HashMap();
}
if (this.attributes.containsKey(key)) {
throw new IllegalStateException("There is already an attribute with key '" + key + "' bound");
}
this.attributes.put(key, value);
}
Add an additional invocation attribute. Useful to add additional
invocation context without having to subclass RemoteInvocation.
Attribute keys have to be unique, and no overriding of existing
attributes is allowed.
The implementation avoids to unnecessarily create the attributes
Map, to minimize serialization size. |
public Object[] getArguments() {
return this.arguments;
}
Return the arguments for the target method call. |
public Serializable getAttribute(String key) {
if (this.attributes == null) {
return null;
}
return (Serializable) this.attributes.get(key);
}
Retrieve the attribute for the given key, if any.
The implementation avoids to unnecessarily create the attributes
Map, to minimize serialization size. |
public Map getAttributes() {
return this.attributes;
}
|
public String getMethodName() {
return this.methodName;
}
Return the name of the target method. |
public Class[] getParameterTypes() {
return this.parameterTypes;
}
Return the parameter types of the target method. |
public Object invoke(Object targetObject) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
Method method = targetObject.getClass().getMethod(this.methodName, this.parameterTypes);
return method.invoke(targetObject, this.arguments);
}
Perform this invocation on the given target object.
Typically called when a RemoteInvocation is received on the server. |
public void setArguments(Object[] arguments) {
this.arguments = arguments;
}
Set the arguments for the target method call. |
public void setAttributes(Map attributes) {
this.attributes = attributes;
}
|
public void setMethodName(String methodName) {
this.methodName = methodName;
}
Set the name of the target method. |
public void setParameterTypes(Class[] parameterTypes) {
this.parameterTypes = parameterTypes;
}
Set the parameter types of the target method. |
public String toString() {
return "RemoteInvocation: method name '" + this.methodName + "'; parameter types " +
ClassUtils.classNamesToString(this.parameterTypes);
}
|