org.logicalcobwebs.cglib.proxy
Class MethodProxy

java.lang.Object
  extended by org.logicalcobwebs.cglib.proxy.MethodProxy

public class MethodProxy
extends java.lang.Object

Classes generated by Enhancer pass this object to the registered MethodInterceptor 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.

Version:
$Id: MethodProxy.java,v 1.3 2004/06/02 20:41:54 billhorsman Exp $

Field Summary
private  FastClass f1
           
private  FastClass f2
           
private  int i1
           
private  int i2
           
private  Signature sig
           
private  java.lang.String superName
           
 
Constructor Summary
private MethodProxy()
           
 
Method Summary
static MethodProxy create(java.lang.ClassLoader loader, java.lang.Class c1, java.lang.Class c2, java.lang.String desc, java.lang.String name1, java.lang.String name2)
          For internal use by Enhancer only; see the net.sf.cglib.reflect.FastMethod class for similar functionality.
static MethodProxy find(java.lang.Class type, Signature sig)
          Return the MethodProxy used when intercepting the method matching the given signature.
 Signature getSignature()
          Return the signature of the proxied method.
 int getSuperIndex()
          Return the FastClass method index for the method used by invokeSuper(java.lang.Object, java.lang.Object[]).
 java.lang.String getSuperName()
          Return the name of the synthetic method created by CGLIB which is used by invokeSuper(java.lang.Object, java.lang.Object[]) to invoke the superclass (non-intercepted) method implementation.
private static FastClass helper(java.lang.ClassLoader loader, java.lang.Class type)
           
 java.lang.Object invoke(java.lang.Object obj, java.lang.Object[] args)
          Invoke the original method, on a different object of the same type.
 java.lang.Object invokeSuper(java.lang.Object obj, java.lang.Object[] args)
          Invoke the original (super) method on the specified object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sig

private Signature sig

superName

private java.lang.String superName

f1

private FastClass f1

f2

private FastClass f2

i1

private int i1

i2

private int i2
Constructor Detail

MethodProxy

private MethodProxy()
Method Detail

create

public static MethodProxy create(java.lang.ClassLoader loader,
                                 java.lang.Class c1,
                                 java.lang.Class c2,
                                 java.lang.String desc,
                                 java.lang.String name1,
                                 java.lang.String name2)
For internal use by Enhancer only; see the net.sf.cglib.reflect.FastMethod class for similar functionality.


helper

private static FastClass helper(java.lang.ClassLoader loader,
                                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 by invokeSuper(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 the FastClass method index for the method used by invokeSuper(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()

find

public static MethodProxy find(java.lang.Class type,
                               Signature sig)
Return the MethodProxy used when intercepting the method matching the given signature.

Parameters:
type - the class generated by Enhancer
sig - 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.Throwable
Invoke 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 an InvocationTargetException
See Also:
MethodInterceptor.intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], org.logicalcobwebs.cglib.proxy.MethodProxy)

invokeSuper

public java.lang.Object invokeSuper(java.lang.Object obj,
                                    java.lang.Object[] args)
                             throws java.lang.Throwable
Invoke the original (super) method on the specified object.

Parameters:
obj - the enhanced object, must be the object passed as the first argument to the MethodInterceptor
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 an InvocationTargetException
See Also:
MethodInterceptor.intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], org.logicalcobwebs.cglib.proxy.MethodProxy)