|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgroovy.lang.MetaClassImpl
groovy.lang.ProxyMetaClass
public class ProxyMetaClass
As subclass of MetaClass, ProxyMetaClass manages calls from Groovy Objects to POJOs. It enriches MetaClass with the feature of making method invokations interceptable by an Interceptor. To this end, it acts as a decorator (decorator pattern) allowing to add or withdraw this feature at runtime. See groovy/lang/InterceptorTest.groovy for details.
WARNING: This implementation of ProxyMetaClass is NOT threadsafe and hence should only be used for as a per-instance MetaClass running in a single thread. Do not place this MetaClass in the MetaClassRegistry as it will result in unpredictable behaviour
MetaClassRegistry| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl |
|---|
MetaClassImpl.Index |
| Field Summary | |
|---|---|
protected MetaClass |
adaptee
|
protected Interceptor |
interceptor
|
| 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 |
| Constructor Summary | |
|---|---|
ProxyMetaClass(MetaClassRegistry registry,
Class theClass,
MetaClass adaptee)
|
|
| Method Summary | |
|---|---|
MetaClass |
getAdaptee()
Returns the MetaClass that this adapter adapts |
static ProxyMetaClass |
getInstance(Class theClass)
convenience factory method for the most usual case. |
Interceptor |
getInterceptor()
|
Object |
getProperty(Class aClass,
Object object,
String property,
boolean b,
boolean b1)
Interceptors the call to getProperty if a PropertyAccessInterceptor is available |
void |
initialize()
complete the initlialisation process. |
Object |
invokeConstructor(Object[] arguments)
Call invokeConstructor on adaptee with logic like in MetaClass unless we have an Interceptor. |
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. |
void |
setAdaptee(MetaClass metaClass)
Sets the MetaClass adapted by this MetaClass |
void |
setInterceptor(Interceptor interceptor)
|
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 |
Object |
use(Closure closure)
Use the ProxyMetaClass for the given Closure. |
Object |
use(GroovyObject object,
Closure closure)
Use the ProxyMetaClass for the given Closure. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 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 |
| Field Detail |
|---|
protected MetaClass adaptee
protected Interceptor interceptor
| Constructor Detail |
|---|
public ProxyMetaClass(MetaClassRegistry registry,
Class theClass,
MetaClass adaptee)
throws IntrospectionException
adaptee - the MetaClass to decorate with interceptability
IntrospectionException| Method Detail |
|---|
public static ProxyMetaClass getInstance(Class theClass)
throws IntrospectionException
IntrospectionExceptionpublic void initialize()
MetaClass
initialize in interface MetaClassinitialize in class MetaClassImplpublic Object use(Closure closure)
closure - piece of code to be executed with registered ProxyMetaClass
public Object use(GroovyObject object,
Closure closure)
closure - piece of code to be executed with ProxyMetaClasspublic Interceptor getInterceptor()
public void setInterceptor(Interceptor interceptor)
interceptor - may be null to reset any interception
public Object invokeMethod(Object object,
String methodName,
Object[] arguments)
invokeMethod in interface MetaObjectProtocolinvokeMethod in class MetaClassImplobject - The instance which the method is invoked onmethodName - The name of the methodarguments - The arguments to the method
MissingMethodException
public Object invokeStaticMethod(Object object,
String methodName,
Object[] arguments)
invokeStaticMethod in interface MetaObjectProtocolinvokeStaticMethod in class MetaClassImplobject - An instance of the class returned by the getTheClass() method or the class itselfmethodName - The name of the methodarguments - The arguments to the method
MissingMethodExceptionpublic Object invokeConstructor(Object[] arguments)
invokeConstructor in interface MetaObjectProtocolinvokeConstructor in class MetaClassImplarguments - The arguments to the constructor
public Object getProperty(Class aClass,
Object object,
String property,
boolean b,
boolean b1)
getProperty in interface MetaClassgetProperty in class MetaClassImplobject - the object to invoke the getter onproperty - the property nameaClass - The java.lang.Class instance that requested the propertyb - Whether the call is to a super class propertyb1 - ??
public void setProperty(Class aClass,
Object object,
String property,
Object newValue,
boolean b,
boolean b1)
setProperty in interface MetaClasssetProperty in class MetaClassImplobject - The object to invoke the setter onproperty - The property name to setnewValue - The new value of the propertyaClass - The java.lang.Class instance that is mutating the propertyb - Whether the call is to a super class propertyb1 - ??public MetaClass getAdaptee()
AdaptingMetaClass
getAdaptee in interface AdaptingMetaClasspublic void setAdaptee(MetaClass metaClass)
AdaptingMetaClass
setAdaptee in interface AdaptingMetaClassmetaClass - The MetaClass to adapt
|
Copyright © 2003-2009 The Codehaus. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||