return msg;
}
public Object invokeTarget(final Object payload) throws InvocationTargetException, SecurityException,
NoSuchMethodException, IllegalArgumentException, IllegalAccessException {
Remote proxy = null;
final Class<?> remote = remoteMethod.getDeclaringClass();
final ClassLoader stubClassLoader = remote.getClassLoader();
// The generated remote interface is not available for the service lookup
final ClassLoader tccl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(stubClassLoader);
return tccl;
}
});
try {
// The proxy cannot be cached as the remote services can be rebound
proxy = rmiHost.findService(uri);
} finally {
AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
ClassLoader current = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(tccl);
return current;
}
});
}
remoteMethod = proxy.getClass().getMethod(remoteMethod.getName(), remoteMethod.getParameterTypes());
if (payload != null && !payload.getClass().isArray()) {
return remoteMethod.invoke(proxy, payload);
} else {
return remoteMethod.invoke(proxy, (Object[])payload);