org.mockejb.interceptor
Class InterceptableProxy

java.lang.Object
  extended byorg.mockejb.interceptor.InterceptableProxy
All Implemented Interfaces:
net.sf.cglib.proxy.Callback, net.sf.cglib.proxy.MethodInterceptor

public class InterceptableProxy
extends java.lang.Object
implements net.sf.cglib.proxy.MethodInterceptor

Creates dynamic proxy and acts as an InvocationHandler for this proxy. During invocation, obtains relevant interceptors from AspectSystem and makes them part of the invocation chain. Uses Cglib internally. Use this class when you have an interface/class and a single implementation class for this interface. Usage example: (Context) InterceptableProxy.create( Context.class, new MockContext() ); You can also create proxies for classes (including using the same class as the intercepted and target class) : InterceptableTestClass proxy = (InterceptableTestClass) InterceptableProxy.create( TestImpl.class, new TestImpl() ); Note that implementation classes don't have to be public (cglib feature).

Author:
Alexander Ananiev

Method Summary
static java.lang.Object create(java.lang.Class ifaceClass, java.lang.Object implObj)
           
 java.lang.Object intercept(java.lang.Object obj, java.lang.reflect.Method proxyMethod, java.lang.Object[] paramVals, net.sf.cglib.proxy.MethodProxy proxy)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static java.lang.Object create(java.lang.Class ifaceClass,
                                      java.lang.Object implObj)

intercept

public java.lang.Object intercept(java.lang.Object obj,
                                  java.lang.reflect.Method proxyMethod,
                                  java.lang.Object[] paramVals,
                                  net.sf.cglib.proxy.MethodProxy proxy)
                           throws java.lang.Throwable
Specified by:
intercept in interface net.sf.cglib.proxy.MethodInterceptor
Throws:
java.lang.Throwable