com.agical.rmock.extension.cglib
Class CglibProxyFactory

java.lang.Object
  extended by com.agical.rmock.extension.cglib.CglibProxyFactory
All Implemented Interfaces:
RMockSingletonService, TestCaseListener, ProxyFactory, ObjectReferenceRetriever

public class CglibProxyFactory
extends java.lang.Object
implements ProxyFactory, ObjectReferenceRetriever, TestCaseListener

(c) Agical AB 2005

Author:
joakim.ohlrogge This factory uses cglib to create proxys for classes.

Constructor Summary
CglibProxyFactory()
           
 
Method Summary
 void afterTestCase()
           
 void beforeTestCase(java.lang.Object testCase, java.lang.String method)
           
 void clear()
          Clear the state of the proxy factory
 java.lang.Object createInterfaceInterceptionProxy(java.lang.Class itf, java.lang.String id)
           
 java.lang.Object createInterfaceProxy(java.lang.Class clazz, java.lang.String id)
          Implementations must create a proxy to an interface of the specified class.
 java.lang.Object createObjectInterceptionProxy(java.lang.Class clazz, java.lang.Class[] parameterTypes, java.lang.Object[] parameters, java.lang.String id)
          Implementations must create an intercepting proxy to an object of the specified class using the specified signature providing the specified arguments
 java.lang.Object createObjectInterceptionProxy(java.lang.Class clazz, java.lang.Object[] parameters, java.lang.String id)
          Implementations creates an intercepting proxy to an object of the specified type if there is one and only one constructor assignable from the provided arguments
 java.lang.Object createObjectMockProxy(java.lang.Class clazz, java.lang.Class[] parameterTypes, java.lang.Object[] parameters, java.lang.String id)
          Implementations must create a mocking proxy to an object of the specified class using the specified signature providing the specified arguments
 java.lang.Object createObjectMockProxy(java.lang.Class clazz, java.lang.Object[] parameters, java.lang.String id)
          Implementations creates a mocking proxy to an object of the specified type if there is one and only one constructor assignable from the provided arguments
 java.lang.Object createObjectMonitorProxy(java.lang.Class clazz, java.lang.Class[] parameterTypes, java.lang.Object[] parameters, java.lang.String id)
          Implementation must create an intercepting proxy of the given class with the given arguments by using the constructor taking the parameter types provided.
 java.lang.Object createObjectMonitorProxy(java.lang.Class clazz, java.lang.Object[] parameters, java.lang.String string)
          Implementation must create an intercepting proxy of the given class by finding the most suitable constructor.
 ObjectReference getObjectReferenceFromProxy(java.lang.Object object)
           
 ObjectReference getObjectReferenceFromStackTrace(java.lang.String stacktrace, int lineToUse)
           
 void setExpectationState(ExpectationsState expectationsState)
           
 void setInvocationHandler(InvocationHandler invocationHandler)
           
 void setInvocationListener(InvocationListener invocationListener)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CglibProxyFactory

public CglibProxyFactory()
Method Detail

createInterfaceProxy

public java.lang.Object createInterfaceProxy(java.lang.Class clazz,
                                             java.lang.String id)
Description copied from interface: ProxyFactory
Implementations must create a proxy to an interface of the specified class.

Specified by:
createInterfaceProxy in interface ProxyFactory
id - Unique id for the proxy
Returns:
proxy
See Also:
com.agical.rmock.core.ProxyFactory#create(java.lang.Class)

createObjectMockProxy

public java.lang.Object createObjectMockProxy(java.lang.Class clazz,
                                              java.lang.Object[] parameters,
                                              java.lang.String id)
Description copied from interface: ProxyFactory
Implementations creates a mocking proxy to an object of the specified type if there is one and only one constructor assignable from the provided arguments

Specified by:
createObjectMockProxy in interface ProxyFactory
id - Unique id for the proxy
Returns:
proxy

createObjectMockProxy

public java.lang.Object createObjectMockProxy(java.lang.Class clazz,
                                              java.lang.Class[] parameterTypes,
                                              java.lang.Object[] parameters,
                                              java.lang.String id)
Description copied from interface: ProxyFactory
Implementations must create a mocking proxy to an object of the specified class using the specified signature providing the specified arguments

Specified by:
createObjectMockProxy in interface ProxyFactory
id - Unique id for the proxy
Returns:
proxy

createObjectInterceptionProxy

public java.lang.Object createObjectInterceptionProxy(java.lang.Class clazz,
                                                      java.lang.Object[] parameters,
                                                      java.lang.String id)
Description copied from interface: ProxyFactory
Implementations creates an intercepting proxy to an object of the specified type if there is one and only one constructor assignable from the provided arguments

Specified by:
createObjectInterceptionProxy in interface ProxyFactory
id - Unique id for the proxy
Returns:
proxy

createObjectInterceptionProxy

public java.lang.Object createObjectInterceptionProxy(java.lang.Class clazz,
                                                      java.lang.Class[] parameterTypes,
                                                      java.lang.Object[] parameters,
                                                      java.lang.String id)
Description copied from interface: ProxyFactory
Implementations must create an intercepting proxy to an object of the specified class using the specified signature providing the specified arguments

Specified by:
createObjectInterceptionProxy in interface ProxyFactory
id - Unique id for the proxy
Returns:
proxy

clear

public void clear()
Description copied from interface: ProxyFactory
Clear the state of the proxy factory

Specified by:
clear in interface ProxyFactory

setInvocationHandler

public void setInvocationHandler(InvocationHandler invocationHandler)

setExpectationState

public void setExpectationState(ExpectationsState expectationsState)

setInvocationListener

public void setInvocationListener(InvocationListener invocationListener)

createObjectMonitorProxy

public java.lang.Object createObjectMonitorProxy(java.lang.Class clazz,
                                                 java.lang.Object[] parameters,
                                                 java.lang.String string)
Description copied from interface: ProxyFactory
Implementation must create an intercepting proxy of the given class by finding the most suitable constructor.

Specified by:
createObjectMonitorProxy in interface ProxyFactory
Returns:

createObjectMonitorProxy

public java.lang.Object createObjectMonitorProxy(java.lang.Class clazz,
                                                 java.lang.Class[] parameterTypes,
                                                 java.lang.Object[] parameters,
                                                 java.lang.String id)
Description copied from interface: ProxyFactory
Implementation must create an intercepting proxy of the given class with the given arguments by using the constructor taking the parameter types provided.

Specified by:
createObjectMonitorProxy in interface ProxyFactory
Returns:

getObjectReferenceFromStackTrace

public ObjectReference getObjectReferenceFromStackTrace(java.lang.String stacktrace,
                                                        int lineToUse)
Specified by:
getObjectReferenceFromStackTrace in interface ObjectReferenceRetriever

getObjectReferenceFromProxy

public ObjectReference getObjectReferenceFromProxy(java.lang.Object object)
Specified by:
getObjectReferenceFromProxy in interface ObjectReferenceRetriever

beforeTestCase

public void beforeTestCase(java.lang.Object testCase,
                           java.lang.String method)
Specified by:
beforeTestCase in interface TestCaseListener

afterTestCase

public void afterTestCase()
Specified by:
afterTestCase in interface TestCaseListener

createInterfaceInterceptionProxy

public java.lang.Object createInterfaceInterceptionProxy(java.lang.Class itf,
                                                         java.lang.String id)
Specified by:
createInterfaceInterceptionProxy in interface ProxyFactory
Returns:


Copyright © 2005-2009 Agical AB. All Rights Reserved.