long time = System.currentTimeMillis();
try {
InitialContext ic = new InitialContext();
NameBasedInvocation nbi = ((NameBasedInvocation) invocationRequest.getParameter());
if (null == nbi) {
throw new IllegalArgumentException("InvocationRequest did not supply method.");
}
methodName = nbi.getMethodName();
String[] methodInfo = methodName.split(":");
Class<?> remoteClass = getClass(methodInfo[0]);
String[] signature = nbi.getSignature();
int signatureLength = signature.length;
Class<?>[] sig = new Class[signatureLength];
for (int i = 0; i < signatureLength; i++) {
sig[i] = getClass(signature[i]);
}
// make sure the remote method is defined to ensure remote clients don't access locals
String jndiName = getRemoteJNDIName(remoteClass);
Object target = ic.lookup(jndiName);
Method m = target.getClass().getMethod(methodInfo[1], sig);
// switch to the local
jndiName = getLocalJNDIName(remoteClass);
target = ic.lookup(jndiName);
m = target.getClass().getMethod(methodInfo[1], sig);
result = m.invoke(target, nbi.getParameters());
successful = true;
} catch (InvocationTargetException e) {
log.error("Failed to invoke remote request", e);
return new WrappedRemotingException(e.getTargetException());