|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groovy.lang.MetaClassImpl org.codehaus.groovy.grails.commons.metaclass.ProxyMetaClass
@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.
Field Summary | |
---|---|
protected groovy.lang.MetaClass |
adaptee
|
protected Interceptor |
interceptor
|
Constructor Summary | |
ProxyMetaClass(groovy.lang.MetaClassRegistry registry, java.lang.Class theClass, groovy.lang.MetaClass adaptee)
@param adaptee the MetaClass to decorate with interceptability |
Method Summary | |
---|---|
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 groovy.lang.MetaClassImpl | |
---|---|
groovy.lang.MetaClassImpl#setProperty(java.lang.Object, java.lang.String, java.lang.Object), groovy.lang.MetaClassImpl#setProperty(java.lang.Class, java.lang.Object, java.lang.String, java.lang.Object, boolean, boolean), 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#getMethods(), groovy.lang.MetaClassImpl#getProperties(), groovy.lang.MetaClassImpl#setProperties(java.lang.Object, java.util.Map), groovy.lang.MetaClassImpl#initialize(), groovy.lang.MetaClassImpl#getAttribute(java.lang.Class, java.lang.Object, java.lang.String, boolean, boolean), groovy.lang.MetaClassImpl#getAttribute(java.lang.Class, java.lang.Object, java.lang.String, boolean), groovy.lang.MetaClassImpl#getAttribute(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#getVersion(), groovy.lang.MetaClassImpl#getTheClass(), groovy.lang.MetaClassImpl#hasProperty(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#invokeMethod(java.lang.Object, java.lang.String, [Ljava.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, java.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#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#getClassNode(), groovy.lang.MetaClassImpl#getMetaMethods(), groovy.lang.MetaClassImpl#selectConstructorAndTransformArguments(int, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#respondsTo(java.lang.Object, java.lang.String), groovy.lang.MetaClassImpl#respondsTo(java.lang.Object, java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#getMetaProperty(java.lang.String), groovy.lang.MetaClassImpl#getStaticMetaMethod(java.lang.String, [Ljava.lang.Object;), groovy.lang.MetaClassImpl#getMetaMethod(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#getClassInfo(), groovy.lang.MetaClassImpl#incVersion(), groovy.lang.MetaClassImpl#createPojoCallSite(org.codehaus.groovy.runtime.callsite.CallSite, java.lang.Object, [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#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#createConstructorSite(org.codehaus.groovy.runtime.callsite.CallSite, [Ljava.lang.Object;), 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#retrieveConstructor([Ljava.lang.Class;), 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#getRegistry(), groovy.lang.MetaClassImpl#wait(), groovy.lang.MetaClassImpl#wait(long), groovy.lang.MetaClassImpl#wait(long, int), groovy.lang.MetaClassImpl#equals(java.lang.Object), groovy.lang.MetaClassImpl#hashCode(), groovy.lang.MetaClassImpl#getClass(), groovy.lang.MetaClassImpl#notify(), groovy.lang.MetaClassImpl#notifyAll() |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), 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() |
Field Detail |
---|
protected groovy.lang.MetaClass adaptee
protected Interceptor interceptor
Constructor Detail |
---|
public ProxyMetaClass(groovy.lang.MetaClassRegistry registry, java.lang.Class theClass, groovy.lang.MetaClass adaptee)
adaptee
- the MetaClass to decorate with interceptabilityregistry
- The MetaClassRegistry instancetheClass
- The class to apply this ProxyMetaClass to
Method Detail |
---|
public groovy.lang.MetaClass getAdaptee()
public static ProxyMetaClass getInstance(java.lang.Class theClass)
theClass
- The class to create a ProxyMetaClass for
public Interceptor getInterceptor()
public Object getProperty(Class aClass, Object object, String property, boolean b, boolean b1) { public java.lang.Object getProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, boolean b, boolean b1)
object
- the object to invoke the getter onproperty
- the property name
@Override public java.lang.Object invokeConstructor(java.lang.Object[] arguments)
@Override public java.lang.Object invokeMethod(java.lang.Class aClass, java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments, boolean b, boolean b1)
@Override public java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
public void setAdaptee(groovy.lang.MetaClass adaptee)
adaptee
- the adaptee to set
public void setInterceptor(Interceptor interceptor)
interceptor
- may be null to reset any interception
public void setProperty(Class aClass, Object object, String property, Object newValue, boolean b, boolean b1) { public void setProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, java.lang.Object newValue, boolean b, boolean b1)
object
- The object to invoke the setter onproperty
- The property name to setnewValue
- The new value of the property
public void use(groovy.lang.Closure closure)
closure
- piece of code to be executed with registered ProxyMetaClass
public void use(groovy.lang.GroovyObject object, groovy.lang.Closure closure)
closure
- piece of code to be executed with ProxyMetaClassobject
- The GroovyObject to use this ProxyMetaClass with
Groovy Documentation