Package groovy.lang
Interface MetaClassRegistry
- All Known Implementing Classes:
- MetaClassRegistryImpl
public interface MetaClassRegistry
A MetaClassRegistry is an object that is responsible for managing a cache of MetaClass instances. Each
 java.lang.Class instance has an associated MetaClass and client code can query this interface for the MetaClass for
 a given associated java.lang.Class
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic classClass used as base for the creation of MetaClass implementations.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdds a metaclass change listener for constant metaclassesvoidAdds a metaclass change listener for constant metaclasses.getMetaClass(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 itRetrieves the MetaClassCreationHandle that is responsible for constructing MetaClass instancesReturns all registered class change listener for constant metaclasses.iterator()Gets a snapshot of the current constant metaclasses and returns it as Iterator.voidremoveMetaClass(Class theClass) Removes a cached MetaClass from the registryvoidRemoves a metaclass change listener for constant metaclassesvoidsetMetaClass(Class theClass, MetaClass theMetaClass) Adds a metaclass to the registry for the given classvoidSets the MetaClassCreationHandle instance that is responsible for constructing instances
- 
Method Details- 
getMetaClassThe main function of the registry If a metaclass exists then return it otherwise create one, put it in the registry and return it
- 
setMetaClassAdds a metaclass to the registry for the given class- Parameters:
- theClass- The class
- theMetaClass- The MetaClass for theClass
 
- 
removeMetaClassRemoves a cached MetaClass from the registry- Parameters:
- theClass- The Java class of the MetaClass to remove
 
- 
getMetaClassCreationHandlerMetaClassRegistry.MetaClassCreationHandle getMetaClassCreationHandler()Retrieves the MetaClassCreationHandle that is responsible for constructing MetaClass instances- Returns:
- The MetaClassCreationHandle instance
 
- 
setMetaClassCreationHandleSets the MetaClassCreationHandle instance that is responsible for constructing instances- Parameters:
- handle- The handle instance
 
- 
addMetaClassRegistryChangeEventListenerAdds a metaclass change listener for constant metaclasses- Parameters:
- listener- - the update listener
 
- 
addNonRemovableMetaClassRegistryChangeEventListenervoid addNonRemovableMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener) Adds a metaclass change listener for constant metaclasses. This listener cannot be removed!- Parameters:
- listener- - the update listener
 
- 
removeMetaClassRegistryChangeEventListenerRemoves a metaclass change listener for constant metaclasses- Parameters:
- listener- - the update listener
 
- 
getMetaClassRegistryChangeEventListenersMetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners()Returns all registered class change listener for constant metaclasses.- Returns:
- an array containing all change listener
 
- 
iteratorIterator iterator()Gets a snapshot of the current constant metaclasses and returns it as Iterator. Modifications done using this Iterator will not cause a ConcurrentModificationException. If a MetaClass is removed using this Iterator, then the MetaClass will only be removed if the MetaClass was not replaced by another MetaClass in the meantime. If a MetaClass is added while using this Iterator, then it will be part of the Iteration. If a MetaClass replaces another constant metaclass, then the Iteration might show two metaclasses for the same class.Note: This Iterator may not be used with multiple threads. - Returns:
- Iterator for the constant metaclasses
 
 
-