groovy.mock.interceptor
Class MockProxyMetaClass
java.lang.Object
groovy.lang.MetaClassImpl
groovy.lang.ProxyMetaClass
groovy.mock.interceptor.MockProxyMetaClass
- All Implemented Interfaces:
- AdaptingMetaClass, MetaClass, MetaObjectProtocol, MutableMetaClass
public class MockProxyMetaClass
- extends ProxyMetaClass
The ProxyMetaClass for the MockInterceptor.
Instance and class methods are intercepted, but constructors are not to allow mocking of aggregated objects.
- Author:
- Dierk Koenig
Fields inherited from class groovy.lang.MetaClassImpl |
getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass |
Method Summary |
Object |
getProperty(Class aClass,
Object object,
String property,
boolean b,
boolean b1)
Interceptors the call to getProperty if a PropertyAccessInterceptor is
available |
Object |
invokeConstructor(Object[] arguments)
Unlike general impl in superclass, ctors are not intercepted but relayed |
Object |
invokeMethod(Object object,
String methodName,
Object[] arguments)
Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
Object |
invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
Call invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
static MockProxyMetaClass |
make(Class theClass)
convenience factory method for the most usual case. |
void |
setProperty(Class aClass,
Object object,
String property,
Object newValue,
boolean b,
boolean b1)
Interceptors the call to a property setter if a PropertyAccessInterceptor
is available |
Methods inherited from class groovy.lang.MetaClassImpl |
addMetaBeanProperty, addMetaMethod, addMetaMethodToIndex, addNewInstanceMethod, addNewStaticMethod, checkIfGroovyObjectMethod, checkInitalised, chooseMethod, clearInvocationCaches, createConstructorSite, createPogoCallCurrentSite, createPogoCallSite, createPojoCallSite, createStaticSite, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getMethodWithCaching, getMethodWithoutCaching, getProperties, getProperty, getStaticMetaMethod, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, hasProperty, incVersion, invokeConstructorAt, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, pickMethod, respondsTo, respondsTo, retrieveConstructor, retrieveMethod, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setProperties, setProperty, toString |
Methods inherited from interface groovy.lang.MetaClass |
getAttribute, getClassNode, getMetaMethods, getMethods, getProperties, invokeMethod, invokeMissingMethod, invokeMissingProperty, pickMethod, selectConstructorAndTransformArguments, setAttribute |
Methods inherited from interface groovy.lang.MetaObjectProtocol |
getAttribute, getMetaMethod, getMetaProperty, getProperty, getStaticMetaMethod, getTheClass, hasProperty, invokeMethod, respondsTo, respondsTo, setAttribute, setProperty |
MockProxyMetaClass
public MockProxyMetaClass(MetaClassRegistry registry,
Class theClass,
MetaClass adaptee)
throws IntrospectionException
- Parameters:
adaptee
- the MetaClass to decorate with interceptability
- Throws:
IntrospectionException
make
public static MockProxyMetaClass make(Class theClass)
throws IntrospectionException
- convenience factory method for the most usual case.
- Throws:
IntrospectionException
invokeMethod
public Object invokeMethod(Object object,
String methodName,
Object[] arguments)
- Description copied from class:
ProxyMetaClass
- Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor.
With Interceptor the call is nested in its beforeInvoke and afterInvoke methods.
The method call is suppressed if Interceptor.doInvoke() returns false.
See Interceptor for details.
- Specified by:
invokeMethod
in interface MetaObjectProtocol
- Overrides:
invokeMethod
in class ProxyMetaClass
- Parameters:
object
- The instance which the method is invoked onmethodName
- The name of the methodarguments
- The arguments to the method
- Returns:
- The return value of the method which is null if the return type is void
- See Also:
MissingMethodException
invokeStaticMethod
public Object invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
- Description copied from class:
ProxyMetaClass
- Call invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor.
With Interceptor the call is nested in its beforeInvoke and afterInvoke methods.
The method call is suppressed if Interceptor.doInvoke() returns false.
See Interceptor for details.
- Specified by:
invokeStaticMethod
in interface MetaObjectProtocol
- Overrides:
invokeStaticMethod
in class ProxyMetaClass
- Parameters:
object
- An instance of the class returned by the getTheClass() method or the class itselfmethodName
- The name of the methodarguments
- The arguments to the method
- Returns:
- The return value of the method which is null if the return type is void
- See Also:
MissingMethodException
getProperty
public Object getProperty(Class aClass,
Object object,
String property,
boolean b,
boolean b1)
- Description copied from class:
ProxyMetaClass
- Interceptors the call to getProperty if a PropertyAccessInterceptor is
available
- Specified by:
getProperty
in interface MetaClass
- Overrides:
getProperty
in class ProxyMetaClass
- Parameters:
aClass
- The java.lang.Class instance that requested the propertyobject
- the object to invoke the getter onproperty
- the property nameb
- Whether the call is to a super class propertyb1
- ??
- Returns:
- the value of the property
setProperty
public void setProperty(Class aClass,
Object object,
String property,
Object newValue,
boolean b,
boolean b1)
- Description copied from class:
ProxyMetaClass
- Interceptors the call to a property setter if a PropertyAccessInterceptor
is available
- Specified by:
setProperty
in interface MetaClass
- Overrides:
setProperty
in class ProxyMetaClass
- Parameters:
aClass
- The java.lang.Class instance that is mutating the propertyobject
- The object to invoke the setter onproperty
- The property name to setnewValue
- The new value of the propertyb
- Whether the call is to a super class propertyb1
- ??
invokeConstructor
public Object invokeConstructor(Object[] arguments)
- Unlike general impl in superclass, ctors are not intercepted but relayed
- Specified by:
invokeConstructor
in interface MetaObjectProtocol
- Overrides:
invokeConstructor
in class ProxyMetaClass
- Parameters:
arguments
- The arguments to the constructor
- Returns:
- An instance of the java.lang.Class that this MetaObjectProtocol object applies to