A registry where components which have been created are stored. Components are stored as singletons, registered under a specific name.
Components can be retrieved from the registry using {@link #getComponent(Class)}.
Components can be registered using {@link #registerComponent(Object,Class)}, which will cause any dependencies to be wired in as well. Components that need to be created as a result of wiring will be done using {@link #getOrCreateComponent(Class)}, which will look up the default factory for the component type (factories annotated with the appropriate {@link DefaultFactoryFor} annotation.
Default factories are treated as components too and will need to be wired before being used.
The registry can exist in one of several states, as defined by the {@link CacheStatus} enumeration. In terms of the cache,state changes in the following manner:
- INSTANTIATED - when first constructed
- CONSTRUCTED - when created using the DefaultCacheFactory
- When {@link org.jboss.cache.Cache#create()} is called, the components are rewired.
- STARTED - when {@link org.jboss.cache.Cache#start()} is called
- STOPPED - when {@link org.jboss.cache.Cache#stop()} is called
- DESTROYED - when {@link org.jboss.cache.Cache#destroy()} is called.
Cache configuration can only be changed and will only be reinjected if the cache is not in the {@link org.jboss.cache.CacheStatus#STARTED} state.
@author Manik Surtani (
manik AT jboss DOT org)
@since 2.1.0