objects when an intercepted method is invoked. It can
be used to either invoke the original method, or call the same method on a different
object of the same type.
| Method from net.sf.cglib.proxy.MethodProxy Detail: |
public static MethodProxy create(Class c1,
Class c2,
String desc,
String name1,
String name2) {
MethodProxy proxy = new MethodProxy();
proxy.sig1 = new Signature(name1, desc);
proxy.sig2 = new Signature(name2, desc);
proxy.createInfo = new CreateInfo(c1, c2);
return proxy;
}
|
public static MethodProxy find(Class type,
Signature sig) {
try {
Method m = type.getDeclaredMethod(MethodInterceptorGenerator.FIND_PROXY_NAME,
MethodInterceptorGenerator.FIND_PROXY_TYPES);
return (MethodProxy)m.invoke(null, new Object[]{ sig });
} catch (NoSuchMethodException e) {
throw new IllegalArgumentException("Class " + type + " does not use a MethodInterceptor");
} catch (IllegalAccessException e) {
throw new CodeGenerationException(e);
} catch (InvocationTargetException e) {
throw new CodeGenerationException(e);
}
}
Return the MethodProxy used when intercepting the method
matching the given signature. |
public Signature getSignature() {
return sig1;
}
Return the signature of the proxied method. |
public int getSuperIndex() {
init();
return fastClassInfo.i2;
}
Return the net.sf.cglib.reflect.FastClass method index
for the method used by #invokeSuper . This index uniquely
identifies the method within the generated proxy, and therefore
can be useful to reference external metadata. |
public String getSuperName() {
return sig2.getName();
}
Return the name of the synthetic method created by CGLIB which is
used by #invokeSuper to invoke the superclass
(non-intercepted) method implementation. The parameter types are
the same as the proxied method. |
public Object invoke(Object obj,
Object[] args) throws Throwable {
try {
init();
FastClassInfo fci = fastClassInfo;
return fci.f1.invoke(fci.i1, obj, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
} catch (IllegalArgumentException e) {
if (fastClassInfo.i1 < 0)
throw new IllegalArgumentException("Protected method: " + sig1);
throw e;
}
}
Invoke the original method, on a different object of the same type. |
public Object invokeSuper(Object obj,
Object[] args) throws Throwable {
try {
init();
FastClassInfo fci = fastClassInfo;
return fci.f2.invoke(fci.i2, obj, args);
} catch (InvocationTargetException e) {
throw e.getTargetException();
}
}
Invoke the original (super) method on the specified object. |