public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass
As subclass of MetaClass, ProxyMetaClass manages calls from Groovy Objects to POJOs. It enriches MetaClass with the feature of making method invocations 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 thread-safe 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
Fields inherited from class | Fields |
---|---|
class MetaClassImpl |
EMPTY_ARGUMENTS |
Constructor and description |
---|
ProxyMetaClass(MetaClassRegistry registry, Class theClass, MetaClass adaptee)
|
Type Params | Return Type | Name and description |
---|---|---|
|
public MetaClass |
getAdaptee() |
|
public static ProxyMetaClass |
getInstance(Class theClass) convenience factory method for the most usual case. |
|
public Interceptor |
getInterceptor()
|
|
public Object |
getProperty(Class aClass, Object object, String property, boolean useSuper, boolean fromInsideClass) Interceptors the call to getProperty if a PropertyAccessInterceptor is available |
|
public void |
initialize() |
|
public Object |
invokeConstructor(Object[] arguments) Call invokeConstructor on adaptee with logic like in MetaClass unless we have an Interceptor. |
|
public Object |
invokeMethod(Object object, String methodName, Object[] arguments) Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
|
public Object |
invokeMethod(Class sender, Object object, String methodName, Object[] arguments, boolean isCallToSuper, boolean fromInsideClass) Call invokeMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
|
public Object |
invokeStaticMethod(Object object, String methodName, Object[] arguments) Call invokeStaticMethod on adaptee with logic like in MetaClass unless we have an Interceptor. |
|
public void |
setAdaptee(MetaClass metaClass) |
|
public void |
setInterceptor(Interceptor interceptor)
|
|
public void |
setProperty(Class aClass, Object object, String property, Object newValue, boolean useSuper, boolean fromInsideClass) Interceptors the call to a property setter if a PropertyAccessInterceptor is available |
|
public Object |
use(Closure closure) Use the ProxyMetaClass for the given Closure. |
|
public Object |
use(GroovyObject object, Closure closure) Use the ProxyMetaClass for the given Closure. |
Methods inherited from class | Name |
---|---|
class MetaClassImpl |
getMetaMethod, getMetaProperty, getRegistry, getStaticMetaMethod, getTheCachedClass, getTheClass, hasProperty, isGroovyObject, methodNameAction, respondsTo, respondsTo, skipClass |
adaptee
- the MetaClass to decorate with interceptabilityconvenience factory method for the most usual case.
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 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.
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 ProxyMetaClassCopyright © 2003-2022 The Apache Software Foundation. All rights reserved.