|
||||||||||
PREV CLASS NEXT CLASS | 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
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. 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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class groovy.lang.MetaClassImpl |
---|
groovy.lang.MetaClassImpl.Index |
Field Summary | |
---|---|
protected groovy.lang.MetaClass |
adaptee
|
protected Interceptor |
interceptor
|
Fields inherited from class groovy.lang.MetaClassImpl |
---|
EMPTY_CLASS_ARRAY, isGroovyObject, isMap, LOG, METHOD_MISSING, PROPERTY_MISSING, registry, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass |
Constructor Summary | |
---|---|
ProxyMetaClass(groovy.lang.MetaClassRegistry registry,
Class theClass,
groovy.lang.MetaClass adaptee)
|
Method Summary | |
---|---|
groovy.lang.MetaClass |
getAdaptee()
|
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 |
Object |
invokeConstructor(Object[] arguments)
Call invokeConstructor on adaptee with logic like in MetaClass unless we have an Interceptor. |
Object |
invokeMethod(Class aClass,
Object object,
String methodName,
Object[] arguments,
boolean b,
boolean b1)
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(groovy.lang.MetaClass adaptee)
|
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 |
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 |
---|
addMetaBeanProperty, addMetaMethod, addNewInstanceMethod, addNewStaticMethod, checkInitalised, clearInvocationCaches, dropMethodCache, dropStaticMethodCache, getAttribute, getAttribute, getAttribute, getClassNode, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getMethodWithCaching, getMethodWithoutCaching, getProperties, getProperty, getStaticMetaMethod, getTheClass, hasProperty, initialize, invokeConstructorAt, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, pickMethod, respondsTo, respondsTo, retrieveConstructor, retrieveMethod, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setProperties, setProperty, toString |
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, initialize, invokeMissingMethod, invokeMissingProperty, pickMethod, selectConstructorAndTransformArguments, setAttribute |
Methods inherited from interface groovy.lang.MetaObjectProtocol |
---|
getAttribute, getMetaMethod, getMetaProperty, getProperty, getStaticMetaMethod, getTheClass, hasProperty, invokeMethod, invokeMethod, respondsTo, respondsTo, setAttribute, setProperty |
Field Detail |
---|
protected groovy.lang.MetaClass adaptee
protected Interceptor interceptor
Constructor Detail |
---|
public ProxyMetaClass(groovy.lang.MetaClassRegistry registry, Class theClass, groovy.lang.MetaClass adaptee) throws IntrospectionException
adaptee
- the MetaClass to decorate with interceptabilityregistry
- The MetaClassRegistry instancetheClass
- The class to apply this ProxyMetaClass to
IntrospectionException
- Thrown when the class cannot be introspectedMethod Detail |
---|
public groovy.lang.MetaClass getAdaptee()
getAdaptee
in interface groovy.lang.AdaptingMetaClass
public void setAdaptee(groovy.lang.MetaClass adaptee)
setAdaptee
in interface groovy.lang.AdaptingMetaClass
adaptee
- the adaptee to setpublic static ProxyMetaClass getInstance(Class theClass) throws IntrospectionException
theClass
- The class to create a ProxyMetaClass for
IntrospectionException
- When the class canot be introspectedpublic void use(groovy.lang.Closure closure)
closure
- piece of code to be executed with registered ProxyMetaClasspublic 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 withpublic Interceptor getInterceptor()
public void setInterceptor(Interceptor interceptor)
interceptor
- may be null to reset any interceptionpublic Object invokeMethod(Class aClass, Object object, String methodName, Object[] arguments, boolean b, boolean b1)
invokeMethod
in interface groovy.lang.MetaClass
invokeMethod
in class groovy.lang.MetaClassImpl
public Object invokeStaticMethod(Object object, String methodName, Object[] arguments)
invokeStaticMethod
in interface groovy.lang.MetaObjectProtocol
invokeStaticMethod
in class groovy.lang.MetaClassImpl
public Object invokeConstructor(Object[] arguments)
invokeConstructor
in interface groovy.lang.MetaObjectProtocol
invokeConstructor
in class groovy.lang.MetaClassImpl
public Object getProperty(Class aClass, Object object, String property, boolean b, boolean b1)
getProperty
in interface groovy.lang.MetaClass
getProperty
in class groovy.lang.MetaClassImpl
object
- the object to invoke the getter onproperty
- the property name
public void setProperty(Class aClass, Object object, String property, Object newValue, boolean b, boolean b1)
setProperty
in interface groovy.lang.MetaClass
setProperty
in class groovy.lang.MetaClassImpl
object
- The object to invoke the setter onproperty
- The property name to setnewValue
- The new value of the property
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |