org.unitils.mock.core.proxy
Class CglibProxyMethodInterceptor<T>

java.lang.Object
  extended by org.unitils.mock.core.proxy.CglibProxyMethodInterceptor<T>
All Implemented Interfaces:
net.sf.cglib.proxy.Callback, net.sf.cglib.proxy.MethodInterceptor

public class CglibProxyMethodInterceptor<T>
extends Object
implements net.sf.cglib.proxy.MethodInterceptor

A cglib method intercepter that will delegate the invocations to the given invocation hanlder.


Nested Class Summary
static class CglibProxyMethodInterceptor.CglibProxyInvocation
          An invocation implementation that uses the cglib method proxy to be able to invoke the original behavior.
 
Constructor Summary
CglibProxyMethodInterceptor(String mockName, Class<T> proxiedType, ProxyInvocationHandler invocationHandler)
          Creates an interceptor.
 
Method Summary
 String getMockName()
           
 Class<?> getProxiedType()
           
 Object intercept(Object proxy, Method method, Object[] arguments, net.sf.cglib.proxy.MethodProxy methodProxy)
          Intercepts the method call by wrapping the invocation in a CglibProxyMethodInterceptor.CglibProxyInvocation and delegating the handling to the invocation handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CglibProxyMethodInterceptor

public CglibProxyMethodInterceptor(String mockName,
                                   Class<T> proxiedType,
                                   ProxyInvocationHandler invocationHandler)
Creates an interceptor.

Parameters:
mockName - The name of the mock, not null
proxiedType - The proxied type, not null
invocationHandler - The handler to delegate the invocations to, not null
Method Detail

intercept

public Object intercept(Object proxy,
                        Method method,
                        Object[] arguments,
                        net.sf.cglib.proxy.MethodProxy methodProxy)
                 throws Throwable
Intercepts the method call by wrapping the invocation in a CglibProxyMethodInterceptor.CglibProxyInvocation and delegating the handling to the invocation handler.

Specified by:
intercept in interface net.sf.cglib.proxy.MethodInterceptor
Parameters:
proxy - The proxy, not null
method - The method that was called, not null
arguments - The arguments that were used, not null
methodProxy - The cglib method proxy, not null
Returns:
The value to return for the method call, ignored for void methods
Throws:
Throwable

getMockName

public String getMockName()

getProxiedType

public Class<?> getProxiedType()
Returns:
The proxied type, not null


Copyright © 2011. All Rights Reserved.