Alachisoft.NCache.Common.RPCFramework.DotNetRPC.TargetObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-common Show documentation
Show all versions of nc-common Show documentation
Internal package of Alachisoft.
package Alachisoft.NCache.Common.RPCFramework.DotNetRPC;
import Alachisoft.NCache.Common.RPCFramework.IRPCTargetObject;
import Alachisoft.NCache.Common.RPCFramework.ITargetMethod;
import Alachisoft.NCache.Common.RPCFramework.TargetMethodAttribute;
import java.lang.annotation.Annotation;
public class TargetObject implements IRPCTargetObject {
private Target _target;
public TargetObject(Target targetObject) {
_target = targetObject;
}
public final Target GetTargetObject() {
return _target;
}
public final ITargetMethod GetMethod(String methodName, int overload) {
ITargetMethod targetMethod = null;
if (_target != null) {
java.lang.reflect.Method[] members = _target.getClass().getMethods();//GetMethods(BindingFlags.Instance | BindingFlags.Public);
for (int i = 0; i < members.length; i++) {
java.lang.reflect.Method member = members[i];
Annotation[] customAttributes = member.getDeclaredAnnotations();
;//member.GetCustomAttributes(TargetMethodAttribute.class, true);
if (customAttributes != null && customAttributes.length > 0) {
TargetMethodAttribute targetMethodAttribute = (TargetMethodAttribute) ((customAttributes[0] instanceof TargetMethodAttribute) ? customAttributes[0] : null);
if (targetMethodAttribute.privateMethod().equals(methodName) && targetMethodAttribute.privateOverload() == overload) {
targetMethod = new TargetMethod(_target, member, targetMethodAttribute.privateMethod(), targetMethodAttribute.privateOverload());
}
}
}
}
return targetMethod;
}
public final ITargetMethod[] GetAllMethods() {
java.util.ArrayList methods = new java.util.ArrayList();
if (_target != null) {
java.lang.reflect.Method[] members = _target.getClass().getMethods(/*BindingFlags.Instance | BindingFlags.Public*/);
for (int i = 0; i < members.length; i++) {
java.lang.reflect.Method member = members[i];
Annotation[] customAttributes = member.getDeclaredAnnotations();//member.GetCustomAttributes(TargetMethodAttribute.class, true);
if (customAttributes != null && customAttributes.length > 0) {
TargetMethodAttribute targetMethodAttribute = (TargetMethodAttribute) ((customAttributes[0] instanceof TargetMethodAttribute) ? customAttributes[0] : null);
if (targetMethodAttribute != null) {
TargetMethod targetMethod = new TargetMethod(_target, member, targetMethodAttribute.privateMethod(), targetMethodAttribute.privateOverload());
methods.add(targetMethod);
}
}
}
}
return methods.toArray(new ITargetMethod[0]);
}
}