@java.lang.SuppressWarnings({"unchecked","rawtypes"}) public class ProxyMetaClass extends groovy.lang.MetaClassImpl
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. This is based on original code by Dierk Koenig, but uses a callback object for thread safety and supports not only method interception, but property and constructor interception too.
Modifiers | Name | Description |
---|---|---|
protected groovy.lang.MetaClass |
adaptee |
|
protected Interceptor |
interceptor |
Fields inherited from class | Fields |
---|---|
class groovy.lang.MetaClassImpl |
EMPTY_ARGUMENTS |
Constructor and description |
---|
ProxyMetaClass
(groovy.lang.MetaClassRegistry registry, java.lang.Class<?> theClass, groovy.lang.MetaClass adaptee) @param adaptee the MetaClass to decorate with interceptability |
Type | Name and description |
---|---|
groovy.lang.MetaClass |
getAdaptee() |
static ProxyMetaClass |
getInstance(java.lang.Class<?> theClass) convenience factory method for the most usual case. |
Interceptor |
getInterceptor() @return the interceptor in use or null if no interceptor is used |
java.lang.Object |
getProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, boolean b, boolean b1) Interceptors the call to getProperty if a PropertyAccessInterceptor is available. |
java.lang.Object |
invokeConstructor(java.lang.Object[] arguments) Call invokeConstructor on adaptee with logic like in MetaClass unless we have an Interceptor. |
java.lang.Object |
invokeMethod(java.lang.Class aClass, java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments, boolean b, boolean b1) Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
java.lang.Object |
invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments) Call invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
void |
setAdaptee(groovy.lang.MetaClass adaptee) @param adaptee the adaptee to set |
void |
setInterceptor(Interceptor interceptor) @param interceptor may be null to reset any interception |
void |
setProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, java.lang.Object newValue, boolean b, boolean b1) Interceptors the call to a property setter if a PropertyAccessInterceptor is available. |
void |
use(groovy.lang.Closure closure) Use the ProxyMetaClass for the given Closure. |
void |
use(groovy.lang.GroovyObject object, groovy.lang.Closure closure) Use the ProxyMetaClass for the given Closure. |
Methods inherited from class | Name |
---|---|
class groovy.lang.MetaClassImpl |
groovy.lang.MetaClassImpl#getVersion(), groovy.lang.MetaClassImpl#setAttribute(java.lang.Object, java.lang.String, java.lang.Object), groovy.lang.MetaClassImpl#setAttribute(java.lang.Class, java.lang.Object, java.lang.String, java.lang.Object, boolean, boolean), groovy.lang.MetaClassImpl#setProperty(java.lang.Class, java.lang.Object, java.lang.String, java.lang.Object, boolean, boolean), groovy.lang.MetaClassImpl#setProperty(java.lang.Object, java.lang.String, java.lang.Object), groovy.lang.MetaClassImpl#getProperty(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#getProperty(java.lang.Class, java.lang.Object, java.lang.String, boolean, boolean), groovy.lang.MetaClassImpl#toString(), groovy.lang.MetaClassImpl#initialize(), groovy.lang.MetaClassImpl#getMethods(), groovy.lang.MetaClassImpl#getProperties(), groovy.lang.MetaClassImpl#setProperties(java.lang.Object, java.util.Map), groovy.lang.MetaClassImpl#getAttribute(java.lang.Class, java.lang.Object, java.lang.String, boolean), groovy.lang.MetaClassImpl#getAttribute(java.lang.Class, java.lang.Object, java.lang.String, boolean, boolean), groovy.lang.MetaClassImpl#getAttribute(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#invokeMethod(java.lang.Object, java.lang.String, java.lang.Object), groovy.lang.MetaClassImpl#invokeMethod(java.lang.Class, java.lang.Object, java.lang.String, [Ljava.lang.Object;, boolean, boolean), groovy.lang.MetaClassImpl#invokeMethod(java.lang.Object, java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#hasProperty(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#getMetaMethods(), groovy.lang.MetaClassImpl#selectConstructorAndTransformArguments(int, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#respondsTo(java.lang.Object, java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#respondsTo(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#getClassNode(), groovy.lang.MetaClassImpl#getMetaProperty(java.lang.String), groovy.lang.MetaClassImpl#getStaticMetaMethod(java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#invokeConstructor([Ljava.lang.Object;), groovy.lang.MetaClassImpl#invokeStaticMethod(java.lang.Object, java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#pickMethod(java.lang.String, [Ljava.lang.Class;), groovy.lang.MetaClassImpl#invokeMissingMethod(java.lang.Object, java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#invokeMissingProperty(java.lang.Object, java.lang.String, java.lang.Object, boolean), groovy.lang.MetaClassImpl#getTheClass(), groovy.lang.MetaClassImpl#getMetaMethod(java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#getClassInfo(), groovy.lang.MetaClassImpl#incVersion(), groovy.lang.MetaClassImpl#getRegistry(), groovy.lang.MetaClassImpl#createPojoCallSite(org.codehaus.groovy.runtime.callsite.CallSite, java.lang.Object, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#createStaticSite(org.codehaus.groovy.runtime.callsite.CallSite, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#createPogoCallSite(org.codehaus.groovy.runtime.callsite.CallSite, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#createPogoCallCurrentSite(org.codehaus.groovy.runtime.callsite.CallSite, java.lang.Class, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#retrieveConstructor([Ljava.lang.Class;), groovy.lang.MetaClassImpl#retrieveConstructor([Ljava.lang.Object;), groovy.lang.MetaClassImpl#createConstructorSite(org.codehaus.groovy.runtime.callsite.CallSite, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#getTheCachedClass(), groovy.lang.MetaClassImpl#getMethodWithoutCaching(java.lang.Class, java.lang.String, [Ljava.lang.Class;, boolean), groovy.lang.MetaClassImpl#addMetaBeanProperty(groovy.lang.MetaBeanProperty), groovy.lang.MetaClassImpl#isModified(), groovy.lang.MetaClassImpl#isGroovyObject(), groovy.lang.MetaClassImpl#addNewInstanceMethod(java.lang.reflect.Method), groovy.lang.MetaClassImpl#addNewStaticMethod(java.lang.reflect.Method), groovy.lang.MetaClassImpl#getMethodWithCaching(java.lang.Class, java.lang.String, [Ljava.lang.Object;, boolean), groovy.lang.MetaClassImpl#retrieveStaticMethod(java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#getEffectiveGetMetaProperty(java.lang.Class, java.lang.Object, java.lang.String, boolean), groovy.lang.MetaClassImpl#addMetaMethod(groovy.lang.MetaMethod), groovy.lang.MetaClassImpl#getAdditionalMetaMethods(), groovy.lang.MetaClassImpl#hasCustomInvokeMethod(), groovy.lang.MetaClassImpl#hasCustomStaticInvokeMethod(), groovy.lang.MetaClassImpl#wait(long, int), groovy.lang.MetaClassImpl#wait(long), groovy.lang.MetaClassImpl#wait(), groovy.lang.MetaClassImpl#equals(java.lang.Object), groovy.lang.MetaClassImpl#hashCode(), groovy.lang.MetaClassImpl#getClass(), groovy.lang.MetaClassImpl#notify(), groovy.lang.MetaClassImpl#notifyAll() |
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
adaptee
- the MetaClass to decorate with interceptabilityregistry
- The MetaClassRegistry instancetheClass
- The class to apply this ProxyMetaClass toconvenience factory method for the most usual case.
theClass
- The class to create a ProxyMetaClass for
Interceptors the call to getProperty if a PropertyAccessInterceptor is available.
object
- the object to invoke the getter onproperty
- the property nameCall invokeConstructor 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.
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.
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.
adaptee
- the adaptee to set
interceptor
- may be null to reset any interceptionInterceptors the call to a property setter if a PropertyAccessInterceptor is available.
object
- The object to invoke the setter onproperty
- The property name to setnewValue
- The new value of the propertyUse the ProxyMetaClass for the given Closure. Cares for balanced register/unregister.
closure
- piece of code to be executed with registered ProxyMetaClassUse the ProxyMetaClass for the given Closure. Cares for balanced setting/unsetting ProxyMetaClass.
closure
- piece of code to be executed with ProxyMetaClassobject
- The GroovyObject to use this ProxyMetaClass with