Class MetaClassRegistryImpl
- java.lang.Object
- 
- org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl
 
- 
- All Implemented Interfaces:
- MetaClassRegistry
 
 public class MetaClassRegistryImpl extends java.lang.Object implements MetaClassRegistry A registry of MetaClass instances which caches introspection and reflection information and allows methods to be dynamically added to existing classes at runtime
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface groovy.lang.MetaClassRegistryMetaClassRegistry.MetaClassCreationHandle
 
- 
 - 
Field SummaryFields Modifier and Type Field Description static intDONT_LOAD_DEFAULTstatic intLOAD_DEFAULTstatic java.lang.StringMODULE_META_INF_FILEDeprecated.Useinstead
 - 
Constructor SummaryConstructors Constructor Description MetaClassRegistryImpl()MetaClassRegistryImpl(boolean useAccessible)MetaClassRegistryImpl(int loadDefault)MetaClassRegistryImpl(int loadDefault, boolean useAccessible)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)Adds a listener for constant meta classes.voidaddNonRemovableMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)Adds a listener for constant meta classes.protected voidfireConstantMetaClassUpdate(java.lang.Object obj, java.lang.Class c, MetaClass oldMC, MetaClass newMc)Causes the execution of all registered listeners.static MetaClassRegistrygetInstance(int includeExtension)Singleton of MetaClassRegistry.FastArraygetInstanceMethods()MetaClassgetMetaClass(java.lang.Class theClass)The main function of the registry If a meta class exists then return it otherwise create one, put it in the registry and return itMetaClassgetMetaClass(java.lang.Object obj)MetaClassRegistry.MetaClassCreationHandlegetMetaClassCreationHandler()Gets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soonMetaClassRegistryChangeEventListener[]getMetaClassRegistryChangeEventListeners()Gets an array of all registered ConstantMetaClassListener instances.ExtensionModuleRegistrygetModuleRegistry()FastArraygetStaticMethods()java.util.Iteratoriterator()Returns an iterator to iterate over all constant meta classes.voidregisterExtensionModuleFromProperties(java.util.Properties properties, java.lang.ClassLoader classLoader, java.util.Map<CachedClass,java.util.List<MetaMethod>> map)voidremoveMetaClass(java.lang.Class theClass)Removes a cached MetaClass from the registryvoidremoveMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)Removes a constant meta class listener.voidsetMetaClass(java.lang.Class theClass, MetaClass theMetaClass)Registers a new MetaClass in the registry to customize the typevoidsetMetaClass(java.lang.Object obj, MetaClass theMetaClass)voidsetMetaClassCreationHandle(MetaClassRegistry.MetaClassCreationHandle handle)Sets a handle internally used to create MetaClass implementations.booleanuseAccessible()
 
- 
- 
- 
Field Detail- 
MODULE_META_INF_FILE@Deprecated public static final java.lang.String MODULE_META_INF_FILE Deprecated.Useinstead- See Also:
- Constant Field Values
 
 - 
LOAD_DEFAULTpublic static final int LOAD_DEFAULT - See Also:
- Constant Field Values
 
 - 
DONT_LOAD_DEFAULTpublic static final int DONT_LOAD_DEFAULT - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
MetaClassRegistryImplpublic MetaClassRegistryImpl() 
 - 
MetaClassRegistryImplpublic MetaClassRegistryImpl(int loadDefault) 
 - 
MetaClassRegistryImplpublic MetaClassRegistryImpl(boolean useAccessible) - Parameters:
- useAccessible- defines whether or not the- AccessibleObject.setAccessible(boolean)method will be called to enable access to all methods when using reflection
 
 - 
MetaClassRegistryImplpublic MetaClassRegistryImpl(int loadDefault, boolean useAccessible)
 
- 
 - 
Method Detail- 
registerExtensionModuleFromPropertiespublic void registerExtensionModuleFromProperties(java.util.Properties properties, java.lang.ClassLoader classLoader, java.util.Map<CachedClass,java.util.List<MetaMethod>> map)
 - 
getModuleRegistrypublic ExtensionModuleRegistry getModuleRegistry() 
 - 
getMetaClasspublic final MetaClass getMetaClass(java.lang.Class theClass) Description copied from interface:MetaClassRegistryThe main function of the registry If a meta class exists then return it otherwise create one, put it in the registry and return it- Specified by:
- getMetaClassin interface- MetaClassRegistry
 
 - 
getMetaClasspublic MetaClass getMetaClass(java.lang.Object obj) 
 - 
removeMetaClasspublic void removeMetaClass(java.lang.Class theClass) Description copied from interface:MetaClassRegistryRemoves a cached MetaClass from the registry- Specified by:
- removeMetaClassin interface- MetaClassRegistry
- Parameters:
- theClass- The Java class of the MetaClass to remove
 
 - 
setMetaClasspublic void setMetaClass(java.lang.Class theClass, MetaClass theMetaClass)Registers a new MetaClass in the registry to customize the type- Specified by:
- setMetaClassin interface- MetaClassRegistry
- Parameters:
- theClass-
- theMetaClass-
 
 - 
setMetaClasspublic void setMetaClass(java.lang.Object obj, MetaClass theMetaClass)
 - 
useAccessiblepublic boolean useAccessible() 
 - 
getMetaClassCreationHandlerpublic MetaClassRegistry.MetaClassCreationHandle getMetaClassCreationHandler() Gets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soon- Specified by:
- getMetaClassCreationHandlerin interface- MetaClassRegistry
- Returns:
- the handle
 
 - 
setMetaClassCreationHandlepublic void setMetaClassCreationHandle(MetaClassRegistry.MetaClassCreationHandle handle) Sets a handle internally used to create MetaClass implementations. When replacing the handle with a custom version, you should reuse the old handle to keep custom logic and to use the default logic as fall back. WARNING: experimental code, likely to change soon- Specified by:
- setMetaClassCreationHandlein interface- MetaClassRegistry
- Parameters:
- handle- the handle
 
 - 
addMetaClassRegistryChangeEventListenerpublic void addMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Adds a listener for constant meta classes.- Specified by:
- addMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
 - 
addNonRemovableMetaClassRegistryChangeEventListenerpublic void addNonRemovableMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Adds a listener for constant meta classes. This listener cannot be removed!- Specified by:
- addNonRemovableMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
 - 
removeMetaClassRegistryChangeEventListenerpublic void removeMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Removes a constant meta class listener.- Specified by:
- removeMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
 - 
fireConstantMetaClassUpdateprotected void fireConstantMetaClassUpdate(java.lang.Object obj, java.lang.Class c, MetaClass oldMC, MetaClass newMc)Causes the execution of all registered listeners. This method is used mostly internal to kick of the listener notification. It can also be used by subclasses to achieve the same.- Parameters:
- obj- object instance if the MetaClass change is on a per-instance metaclass (or null if global)
- c- the class
- oldMC- the old MetaClass
- newMc- the new MetaClass
 
 - 
getMetaClassRegistryChangeEventListenerspublic MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners() Gets an array of all registered ConstantMetaClassListener instances.- Specified by:
- getMetaClassRegistryChangeEventListenersin interface- MetaClassRegistry
- Returns:
- an array containing all change listener
 
 - 
getInstancepublic static MetaClassRegistry getInstance(int includeExtension) Singleton of MetaClassRegistry.- Parameters:
- includeExtension-
- Returns:
- the registry
 
 - 
getInstanceMethodspublic FastArray getInstanceMethods() 
 - 
getStaticMethodspublic FastArray getStaticMethods() 
 - 
iteratorpublic java.util.Iterator iterator() Returns an iterator to iterate over all constant meta classes. This iterator can be seen as making a snapshot of the current state of the registry. The snapshot will include all meta classes that has been used unless they are already collected. Collected meta classes will be skipped automatically, so you can expect that each element of the iteration is not null. Calling this method is thread safe, the usage of the iterator is not.- Specified by:
- iteratorin interface- MetaClassRegistry
- Returns:
- the iterator.
 
 
- 
 
-