public class ProxyMetaClass extends MetaClassImpl implements AdaptingMetaClass
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
MetaClassRegistry
MetaClassImpl.Index, MetaClassImpl.MetaConstructor
Modifier and Type | Field and Description |
---|---|
protected MetaClass |
adaptee |
protected Interceptor |
interceptor |
EMPTY_ARGUMENTS, getPropertyMethod, INVOKE_METHOD_METHOD, invokeMethodMethod, isGroovyObject, isMap, metaMethodIndex, METHOD_MISSING, PROPERTY_MISSING, registry, setPropertyMethod, STATIC_METHOD_MISSING, STATIC_PROPERTY_MISSING, theCachedClass, theClass
Constructor and Description |
---|
ProxyMetaClass(MetaClassRegistry registry,
java.lang.Class theClass,
MetaClass adaptee) |
Modifier and Type | Method and Description |
---|---|
MetaClass |
getAdaptee()
Returns the MetaClass that this adapter adapts
|
static ProxyMetaClass |
getInstance(java.lang.Class theClass)
convenience factory method for the most usual case.
|
Interceptor |
getInterceptor() |
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
|
void |
initialize()
complete the initialisation process.
|
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.Object object,
java.lang.String methodName,
java.lang.Object[] arguments)
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(MetaClass metaClass)
Sets the MetaClass adapted by this MetaClass
|
void |
setInterceptor(Interceptor interceptor) |
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
|
java.lang.Object |
use(Closure closure)
Use the ProxyMetaClass for the given Closure.
|
java.lang.Object |
use(GroovyObject object,
Closure closure)
Use the ProxyMetaClass for the given Closure.
|
addMetaBeanProperty, addMetaMethod, addMetaMethodToIndex, addNewInstanceMethod, addNewStaticMethod, applyPropertyDescriptors, checkIfGroovyObjectMethod, checkInitalised, chooseMethod, clearInvocationCaches, createConstructorSite, createPogoCallCurrentSite, createPogoCallSite, createPojoCallSite, createStaticSite, dropMethodCache, dropStaticMethodCache, findMethodInClassHierarchy, findMixinMethod, findOwnMethod, findPropertyInClassHierarchy, getAdditionalMetaMethods, getAttribute, getAttribute, getAttribute, getClassInfo, getClassNode, getEffectiveGetMetaProperty, getMetaMethod, getMetaMethods, getMetaProperty, getMethods, getMethodWithCaching, getMethodWithoutCaching, getProperties, getProperty, getRegistry, getStaticMetaMethod, getSubclassMetaMethods, getSuperClasses, getTheCachedClass, getTheClass, getVersion, hasProperty, incVersion, invokeMethod, invokeMethod, invokeMissingMethod, invokeMissingProperty, invokeStaticMissingProperty, isGroovyObject, isInitialized, isModified, onGetPropertyFoundInHierarchy, onInvokeMethodFoundInHierarchy, onMixinMethodFound, onSetPropertyFoundInHierarchy, onSuperMethodFoundInHierarchy, onSuperPropertyFoundInHierarchy, pickMethod, respondsTo, respondsTo, retrieveConstructor, retrieveConstructor, retrieveStaticMethod, selectConstructorAndTransformArguments, setAttribute, setAttribute, setProperties, setProperty, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAttribute, getClassNode, getMetaMethods, getMethods, getProperties, invokeMethod, invokeMissingMethod, invokeMissingProperty, pickMethod, selectConstructorAndTransformArguments, setAttribute
getAttribute, getMetaMethod, getMetaProperty, getProperty, getStaticMetaMethod, getTheClass, hasProperty, invokeMethod, respondsTo, respondsTo, setAttribute, setProperty
protected MetaClass adaptee
protected Interceptor interceptor
public ProxyMetaClass(MetaClassRegistry registry, java.lang.Class theClass, MetaClass adaptee) throws java.beans.IntrospectionException
adaptee
- the MetaClass to decorate with interceptabilityjava.beans.IntrospectionException
public static ProxyMetaClass getInstance(java.lang.Class theClass) throws java.beans.IntrospectionException
java.beans.IntrospectionException
public void initialize()
MetaClass
initialize
in interface MetaClass
initialize
in class MetaClassImpl
public java.lang.Object use(Closure closure)
closure
- piece of code to be executed with registered ProxyMetaClasspublic java.lang.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 interceptionpublic java.lang.Object invokeMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
invokeMethod
in interface MetaObjectProtocol
invokeMethod
in class MetaClassImpl
object
- The instance which the method is invoked onmethodName
- The name of the methodarguments
- The arguments to the methodMissingMethodException
public java.lang.Object invokeStaticMethod(java.lang.Object object, java.lang.String methodName, java.lang.Object[] arguments)
invokeStaticMethod
in interface MetaObjectProtocol
invokeStaticMethod
in class MetaClassImpl
object
- An instance of the class returned by the getTheClass() method or the class itselfmethodName
- The name of the methodarguments
- The arguments to the methodMissingMethodException
public java.lang.Object invokeConstructor(java.lang.Object[] arguments)
invokeConstructor
in interface MetaObjectProtocol
invokeConstructor
in class MetaClassImpl
arguments
- The arguments to the constructorpublic java.lang.Object getProperty(java.lang.Class aClass, java.lang.Object object, java.lang.String property, boolean b, boolean b1)
getProperty
in interface MetaClass
getProperty
in class MetaClassImpl
object
- 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(java.lang.Class aClass, java.lang.Object object, java.lang.String property, java.lang.Object newValue, boolean b, boolean b1)
setProperty
in interface MetaClass
setProperty
in class MetaClassImpl
object
- 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 AdaptingMetaClass
public void setAdaptee(MetaClass metaClass)
AdaptingMetaClass
setAdaptee
in interface AdaptingMetaClass
metaClass
- The MetaClass to adapt