Package net.sf.cglib.proxy
Class MethodProxy
- java.lang.Object
-
- net.sf.cglib.proxy.MethodProxy
-
public class MethodProxy extends java.lang.ObjectClasses generated byEnhancerpass this object to the registeredMethodInterceptorobjects 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.- Version:
- $Id: MethodProxy.java,v 1.16 2009/01/11 20:09:48 herbyderby Exp $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMethodProxy.CreateInfoprivate static classMethodProxy.FastClassInfo
-
Field Summary
Fields Modifier and Type Field Description private MethodProxy.CreateInfocreateInfoprivate MethodProxy.FastClassInfofastClassInfoprivate java.lang.ObjectinitLockprivate Signaturesig1private Signaturesig2
-
Constructor Summary
Constructors Modifier Constructor Description privateMethodProxy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MethodProxycreate(java.lang.Class c1, java.lang.Class c2, java.lang.String desc, java.lang.String name1, java.lang.String name2)For internal use byEnhanceronly; see theFastMethodclass for similar functionality.static MethodProxyfind(java.lang.Class type, Signature sig)Return theMethodProxyused when intercepting the method matching the given signature.(package private) FastClassgetFastClass()SignaturegetSignature()Return the signature of the proxied method.(package private) FastClassgetSuperFastClass()intgetSuperIndex()Return theFastClassmethod index for the method used byinvokeSuper(java.lang.Object, java.lang.Object[]).java.lang.StringgetSuperName()Return the name of the synthetic method created by CGLIB which is used byinvokeSuper(java.lang.Object, java.lang.Object[])to invoke the superclass (non-intercepted) method implementation.private static FastClasshelper(MethodProxy.CreateInfo ci, java.lang.Class type)private voidinit()java.lang.Objectinvoke(java.lang.Object obj, java.lang.Object[] args)Invoke the original method, on a different object of the same type.java.lang.ObjectinvokeSuper(java.lang.Object obj, java.lang.Object[] args)Invoke the original (super) method on the specified object.
-
-
-
Field Detail
-
sig1
private Signature sig1
-
sig2
private Signature sig2
-
createInfo
private MethodProxy.CreateInfo createInfo
-
initLock
private final java.lang.Object initLock
-
fastClassInfo
private volatile MethodProxy.FastClassInfo fastClassInfo
-
-
Method Detail
-
create
public static MethodProxy create(java.lang.Class c1, java.lang.Class c2, java.lang.String desc, java.lang.String name1, java.lang.String name2)
For internal use byEnhanceronly; see theFastMethodclass for similar functionality.
-
init
private void init()
-
helper
private static FastClass helper(MethodProxy.CreateInfo ci, java.lang.Class type)
-
getSignature
public Signature getSignature()
Return the signature of the proxied method.
-
getSuperName
public java.lang.String getSuperName()
Return the name of the synthetic method created by CGLIB which is used byinvokeSuper(java.lang.Object, java.lang.Object[])to invoke the superclass (non-intercepted) method implementation. The parameter types are the same as the proxied method.
-
getSuperIndex
public int getSuperIndex()
Return theFastClassmethod index for the method used byinvokeSuper(java.lang.Object, java.lang.Object[]). This index uniquely identifies the method within the generated proxy, and therefore can be useful to reference external metadata.- See Also:
getSuperName()
-
getFastClass
FastClass getFastClass()
-
getSuperFastClass
FastClass getSuperFastClass()
-
find
public static MethodProxy find(java.lang.Class type, Signature sig)
Return theMethodProxyused when intercepting the method matching the given signature.- Parameters:
type- the class generated by Enhancersig- the signature to match- Returns:
- the MethodProxy instance, or null if no applicable matching method is found
- Throws:
java.lang.IllegalArgumentException- if the Class was not created by Enhancer or does not use a MethodInterceptor
-
invoke
public java.lang.Object invoke(java.lang.Object obj, java.lang.Object[] args) throws java.lang.ThrowableInvoke the original method, on a different object of the same type.- Parameters:
obj- the compatible object; recursion will result if you use the object passed as the first argument to the MethodInterceptor (usually not what you want)args- the arguments passed to the intercepted method; you may substitute a different argument array as long as the types are compatible- Throws:
java.lang.Throwable- the bare exceptions thrown by the called method are passed through without wrapping in anInvocationTargetException- See Also:
MethodInterceptor.intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy)
-
invokeSuper
public java.lang.Object invokeSuper(java.lang.Object obj, java.lang.Object[] args) throws java.lang.ThrowableInvoke the original (super) method on the specified object.- Parameters:
obj- the enhanced object, must be the object passed as the first argument to the MethodInterceptorargs- the arguments passed to the intercepted method; you may substitute a different argument array as long as the types are compatible- Throws:
java.lang.Throwable- the bare exceptions thrown by the called method are passed through without wrapping in anInvocationTargetException- See Also:
MethodInterceptor.intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy)
-
-