Class MetaClassRegistryImpl
java.lang.Object
org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl
- All Implemented Interfaces:
- 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 SummaryNested classes/interfaces inherited from interface groovy.lang.MetaClassRegistryMetaClassRegistry.MetaClassCreationHandle
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionMetaClassRegistryImpl(boolean useAccessible) MetaClassRegistryImpl(int loadDefault) MetaClassRegistryImpl(int loadDefault, boolean useAccessible) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds a listener for constant metaclasses.voidAdds a listener for constant metaclasses.protected voidfireConstantMetaClassUpdate(Object obj, Class c, MetaClass oldMC, MetaClass newMc) Causes the execution of all registered listeners.static MetaClassRegistrygetInstance(int includeExtension) Singleton of MetaClassRegistry.final MetaClassgetMetaClass(Class theClass) The main function of the registry If a metaclass exists then return it otherwise create one, put it in the registry and return itgetMetaClass(Object obj) Gets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soonGets an array of all registered ConstantMetaClassListener instances.iterator()Returns an iterator to iterate over all constant metaclasses.voidregisterExtensionModuleFromProperties(Properties properties, ClassLoader classLoader, Map<CachedClass, List<MetaMethod>> map) voidremoveMetaClass(Class theClass) Removes a cached MetaClass from the registryvoidRemoves a constant metaclass listener.voidsetMetaClass(Class theClass, MetaClass theMetaClass) Adds a metaclass to the registry for the given classvoidsetMetaClass(Object obj, MetaClass theMetaClass) voidSets a handle internally used to create MetaClass implementations.boolean
- 
Field Details- 
MODULE_META_INF_FILEDeprecated.UseExtensionModuleScanner.MODULE_META_INF_FILEinstead- See Also:
 
- 
EXTENSION_DISABLE_PROPERTY- See Also:
 
- 
LOAD_DEFAULTpublic static final int LOAD_DEFAULT- See Also:
 
- 
DONT_LOAD_DEFAULTpublic static final int DONT_LOAD_DEFAULT- See Also:
 
 
- 
- 
Constructor Details- 
MetaClassRegistryImplpublic MetaClassRegistryImpl()
- 
MetaClassRegistryImplpublic MetaClassRegistryImpl(int loadDefault) 
- 
MetaClassRegistryImplpublic MetaClassRegistryImpl(boolean useAccessible) - Parameters:
- useAccessible- defines whether the- AccessibleObject.setAccessible(boolean)method will be called to enable access to all methods when using reflection
 
- 
MetaClassRegistryImplpublic MetaClassRegistryImpl(int loadDefault, boolean useAccessible) 
 
- 
- 
Method Details- 
registerExtensionModuleFromPropertiespublic void registerExtensionModuleFromProperties(Properties properties, ClassLoader classLoader, Map<CachedClass, List<MetaMethod>> map) 
- 
getModuleRegistry
- 
getMetaClassDescription copied from interface:MetaClassRegistryThe main function of the registry If a metaclass exists then return it otherwise create one, put it in the registry and return it- Specified by:
- getMetaClassin interface- MetaClassRegistry
 
- 
getMetaClass
- 
removeMetaClassDescription 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
 
- 
setMetaClassDescription copied from interface:MetaClassRegistryAdds a metaclass to the registry for the given class- Specified by:
- setMetaClassin interface- MetaClassRegistry
- Parameters:
- theClass- The class
- theMetaClass- The MetaClass for theClass
 
- 
setMetaClass
- 
useAccessiblepublic boolean useAccessible()
- 
getMetaClassCreationHandlerGets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soon- Specified by:
- getMetaClassCreationHandlerin interface- MetaClassRegistry
- Returns:
- the handle
 
- 
setMetaClassCreationHandleSets 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
 
- 
addMetaClassRegistryChangeEventListenerAdds a listener for constant metaclasses.- Specified by:
- addMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
- 
addNonRemovableMetaClassRegistryChangeEventListenerpublic void addNonRemovableMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Adds a listener for constant metaclasses. This listener cannot be removed!- Specified by:
- addNonRemovableMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
- 
removeMetaClassRegistryChangeEventListenerpublic void removeMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Removes a constant metaclass listener.- Specified by:
- removeMetaClassRegistryChangeEventListenerin interface- MetaClassRegistry
- Parameters:
- listener- the listener
 
- 
fireConstantMetaClassUpdateCauses 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
 
- 
getMetaClassRegistryChangeEventListenersGets an array of all registered ConstantMetaClassListener instances.- Specified by:
- getMetaClassRegistryChangeEventListenersin interface- MetaClassRegistry
- Returns:
- an array containing all change listener
 
- 
getInstanceSingleton of MetaClassRegistry.- Parameters:
- includeExtension-
- Returns:
- the registry
 
- 
getInstanceMethods
- 
getStaticMethods
- 
iteratorReturns an iterator to iterate over all constant metaclasses. This iterator can be seen as making a snapshot of the current state of the registry. The snapshot will include all metaclasses that has been used unless they are already collected. Collected metaclasses 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.
 
 
- 
ExtensionModuleScanner.MODULE_META_INF_FILEinstead