Alachisoft.NCache.Common.RPCFramework.RPCService Maven / Gradle / Ivy
package Alachisoft.NCache.Common.RPCFramework;
import java.lang.reflect.InvocationTargetException;
public class RPCService {
private RPCMethodCache _rpcCache;
public RPCService(IRPCTargetObject targetObject) {
_rpcCache = new RPCMethodCache(targetObject);
}
public final Object InvokeMethodOnTarget(String methodName, int overload, Object[] arguments) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
ITargetMethod targetMethod = _rpcCache.GetTargetMethod(methodName, overload);
if (targetMethod == null) {
throw new InstantiationException("Target method not found (Method: " + methodName + " , overload : " + overload + ")");
}
if (targetMethod.GetNumberOfArguments() != arguments.length) {
throw new IllegalAccessException();
}
Object returnVal = targetMethod.Invoke(arguments);
return returnVal;
}
}