Package org.infinispan.factories
Class AbstractComponentRegistry
- java.lang.Object
-
- org.infinispan.factories.AbstractComponentRegistry
-
- Direct Known Subclasses:
ComponentRegistry,GlobalComponentRegistry
@Deprecated public abstract class AbstractComponentRegistry extends Object implements Lifecycle, Cloneable
Deprecated.Since 9.4, please useBasicComponentRegistryinstead.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 usinggetComponent(Class). Components can be registered usingregisterComponent(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 usinggetOrCreateComponent(Class), which will look up the default factory for the component type (factories annotated with the appropriateDefaultFactoryForannotation. 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 theComponentStatusenumeration. In terms of the cache, state changes in the following manner:- INSTANTIATED - when first constructed
- CONSTRUCTED - when created using the DefaultCacheFactory
- STARTED - when
Lifecycle.start()is called - STOPPED - when
Cache.stop()is called
ComponentStatus.RUNNINGstate. Thread Safety: instances ofGlobalComponentRegistrycan be concurrently updated so all the write operations are serialized through class intrinsic lock.- Since:
- 4.0
- Author:
- Manik Surtani, Galder ZamarreƱo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classAbstractComponentRegistry.ComponentDeprecated.A wrapper representing a component in the registry
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG_DEPENDENCIESDeprecated.protected ComponentStatusstateDeprecated.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractComponentRegistry(ComponentMetadataRepo componentMetadataRepo, ClassLoader classLoader, Scopes scope, org.infinispan.factories.impl.BasicComponentRegistry nextBasicComponentRegistry)Deprecated.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddShutdownHook()Deprecated.AbstractComponentRegistryclone()Deprecated.protected AbstractComponentFactorycreateComponentFactoryInternal(Class<?> componentClass, String cfClass)Deprecated.protected abstract ClassLoadergetClassLoader()Deprecated.<T> TgetComponent(Class<T> type)Deprecated.Retrieves a component of a specified type from the registry, or null if it cannot be found.<T> TgetComponent(Class<T> componentClass, String name)Deprecated.<T> TgetComponent(String componentClassName)Deprecated.<T> TgetComponent(String componentClassName, String name)Deprecated.<T> TgetComponent(String componentClassName, String name, boolean nameIsFQCN)Deprecated.abstract ComponentMetadataRepogetComponentMetadataRepo()Deprecated.protected ConfigurationgetConfiguration()Deprecated.Retrieves the configuration component.protected AbstractComponentFactorygetFactory(Class<?> componentClass)Deprecated.Retrieves a component factory instance capable of constructing components of a specified type.protected abstract org.infinispan.util.logging.LoggetLog()Deprecated.<T> Optional<T>getOptionalComponent(Class<T> type)Deprecated.protected <T> TgetOrCreateComponent(Class<T> componentClass)Deprecated.Retrieves a component if one exists, and if not, attempts to find a factory capable of constructing the component (factories annotated with theDefaultFactoryForannotation that is capable of creating the component class).protected <T> TgetOrCreateComponent(Class<T> componentClass, String name)Deprecated.protected <T> TgetOrCreateComponent(Class<T> componentClass, String name, boolean nameIsFQCN)Deprecated.Set<AbstractComponentRegistry.Component>getRegisteredComponents()Deprecated.Returns an immutable set containing all the components that exists in the repository at this moment.ComponentStatusgetStatus()Deprecated.Retrieves the state of the registryabstract TimeServicegetTimeService()Deprecated.protected AbstractComponentRegistry.ComponentlookupComponent(String componentClassName, String componentName, boolean nameIsFQCN)Deprecated.protected abstract voidpostStart()Deprecated.protected abstract voidpostStop()Deprecated.protected abstract voidpreStart()Deprecated.protected abstract voidpreStop()Deprecated.voidregisterComponent(Object component, Class<?> type)Deprecated.Registers a component in the registry under the given type, and injects any dependencies needed.voidregisterComponent(Object component, String name)Deprecated.voidregisterComponent(Object component, String name, boolean nameIsFQCN)Deprecated.protected voidregisterComponentInternal(Object component, String name, boolean nameIsFQCN)Deprecated.protected ClassLoaderregisterDefaultClassLoader(ClassLoader loader)Deprecated.Since 9.4, not usedprotected voidregisterNonVolatileComponent(Object component, Class<?> type)Deprecated.protected voidregisterNonVolatileComponent(Object component, String name)Deprecated.protected voidregisterNullComponent(String name)Deprecated.registers a special "null" component that has no dependencies.protected voidremoveShutdownHook()Deprecated.voidresetVolatileComponents()Deprecated.Removes any components not annotated as @SurvivesRestarts.voidrewire()Deprecated.Rewires components.voidstart()Deprecated.This starts the components in the registry, connecting to channels, starting service threads, etc.voidstop()Deprecated.Stops the component and sets its status toComponentStatus.TERMINATEDonce it is done.protected voidthrowStackAwareConfigurationException(String message)Deprecated.voidwireDependencies(Object target)Deprecated.Wires an object instance with dependencies annotated with theInjectannotation, creating more components as needed based on the Configuration passed in if these additional components don't exist in theComponentRegistry.
-
-
-
Field Detail
-
DEBUG_DEPENDENCIES
public static final boolean DEBUG_DEPENDENCIES
Deprecated.- See Also:
- Constant Field Values
-
state
protected volatile ComponentStatus state
Deprecated.
-
-
Constructor Detail
-
AbstractComponentRegistry
protected AbstractComponentRegistry(ComponentMetadataRepo componentMetadataRepo, ClassLoader classLoader, Scopes scope, org.infinispan.factories.impl.BasicComponentRegistry nextBasicComponentRegistry)
Deprecated.
-
-
Method Detail
-
getStatus
public ComponentStatus getStatus()
Deprecated.Retrieves the state of the registry- Returns:
- state of the registry
-
getClassLoader
protected abstract ClassLoader getClassLoader()
Deprecated.
-
getLog
protected abstract org.infinispan.util.logging.Log getLog()
Deprecated.
-
getComponentMetadataRepo
public abstract ComponentMetadataRepo getComponentMetadataRepo()
Deprecated.
-
wireDependencies
public void wireDependencies(Object target) throws CacheConfigurationException
Deprecated.Wires an object instance with dependencies annotated with theInjectannotation, creating more components as needed based on the Configuration passed in if these additional components don't exist in theComponentRegistry. Strictly for components that don't otherwise live in the registry and have a lifecycle, such as Commands.- Parameters:
target- object to wire- Throws:
CacheConfigurationException- if there is a problem wiring the instance
-
registerComponent
public final void registerComponent(Object component, Class<?> type)
Deprecated.Registers a component in the registry under the given type, and injects any dependencies needed. Note: Until 9.4, if a component of this type already existed, it was overwritten.- Parameters:
component- component to registertype- type of component- Throws:
CacheConfigurationException- If a component is already registered with that name, or if a dependency cannot be resolved
-
registerComponent
public final void registerComponent(Object component, String name, boolean nameIsFQCN)
Deprecated.
-
registerNonVolatileComponent
protected final void registerNonVolatileComponent(Object component, String name)
Deprecated.
-
registerNonVolatileComponent
protected final void registerNonVolatileComponent(Object component, Class<?> type)
Deprecated.
-
registerComponentInternal
protected void registerComponentInternal(Object component, String name, boolean nameIsFQCN)
Deprecated.
-
getOrCreateComponent
protected <T> T getOrCreateComponent(Class<T> componentClass)
Deprecated.Retrieves a component if one exists, and if not, attempts to find a factory capable of constructing the component (factories annotated with theDefaultFactoryForannotation that is capable of creating the component class). If an instance needs to be constructed, dependencies are then automatically wired into the instance, based on methods on the component type annotated withInject. Summing it up, component retrieval happens in the following order:
1. Look for a component that has already been created and registered. 2. Look for an appropriate component that exists in theConfigurationthat may be injected from an external system. 3. Look for a class definition passed in to theConfiguration- such as an EvictionPolicy implementation 4. Attempt to create it by looking for an appropriate factory (annotated withDefaultFactoryFor)- Parameters:
componentClass- type of component to be retrieved. Should not be null.- Returns:
- a fully wired component instance, or null if one cannot be found or constructed.
- Throws:
CacheConfigurationException- if there is a problem with constructing or wiring the instance.
-
getOrCreateComponent
protected <T> T getOrCreateComponent(Class<T> componentClass, String name)
Deprecated.
-
getOrCreateComponent
protected <T> T getOrCreateComponent(Class<T> componentClass, String name, boolean nameIsFQCN)
Deprecated.
-
getFactory
protected AbstractComponentFactory getFactory(Class<?> componentClass)
Deprecated.Retrieves a component factory instance capable of constructing components of a specified type. If the factory doesn't exist in the registry, one is created.- Parameters:
componentClass- type of component to construct- Returns:
- component factory capable of constructing such components
-
createComponentFactoryInternal
protected AbstractComponentFactory createComponentFactoryInternal(Class<?> componentClass, String cfClass)
Deprecated.
-
lookupComponent
protected AbstractComponentRegistry.Component lookupComponent(String componentClassName, String componentName, boolean nameIsFQCN)
Deprecated.
-
registerNullComponent
protected final void registerNullComponent(String name)
Deprecated.registers a special "null" component that has no dependencies.- Parameters:
name- name of component to register as a null
-
getConfiguration
protected Configuration getConfiguration()
Deprecated.Retrieves the configuration component.- Returns:
- a Configuration object
-
getComponent
public <T> T getComponent(Class<T> type)
Deprecated.Retrieves a component of a specified type from the registry, or null if it cannot be found.- Parameters:
type- type to find- Returns:
- component, or null
-
getComponent
public <T> T getComponent(String componentClassName)
Deprecated.
-
getComponent
public <T> T getComponent(String componentClassName, String name, boolean nameIsFQCN)
Deprecated.
-
registerDefaultClassLoader
protected ClassLoader registerDefaultClassLoader(ClassLoader loader)
Deprecated.Since 9.4, not used
-
rewire
public void rewire()
Deprecated.Rewires components. Used to rewire components in the CR if a cache has been stopped (moved to state TERMINATED), which would (almost) empty the registry of components. Rewiring will re-inject all dependencies so that the cache can be started again.
-
resetVolatileComponents
public void resetVolatileComponents()
Deprecated.Removes any components not annotated as @SurvivesRestarts.
-
start
public void start()
Deprecated.This starts the components in the registry, connecting to channels, starting service threads, etc. If the component is not in theComponentStatus.INITIALIZINGstate, it will be initialized first.
-
preStart
protected abstract void preStart()
Deprecated.
-
postStart
protected abstract void postStart()
Deprecated.
-
stop
public final void stop()
Deprecated.Stops the component and sets its status toComponentStatus.TERMINATEDonce it is done. If the component is not in theComponentStatus.RUNNINGstate, this is a no-op.
-
postStop
protected abstract void postStop()
Deprecated.
-
preStop
protected abstract void preStop()
Deprecated.
-
addShutdownHook
protected void addShutdownHook()
Deprecated.
-
removeShutdownHook
protected void removeShutdownHook()
Deprecated.
-
getRegisteredComponents
public Set<AbstractComponentRegistry.Component> getRegisteredComponents()
Deprecated.Returns an immutable set containing all the components that exists in the repository at this moment.- Returns:
- a set of components
-
clone
public AbstractComponentRegistry clone() throws CloneNotSupportedException
Deprecated.- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
getTimeService
public abstract TimeService getTimeService()
Deprecated.
-
throwStackAwareConfigurationException
protected void throwStackAwareConfigurationException(String message)
Deprecated.
-
-