Package org.infinispan.factories
Class AbstractComponentRegistry
java.lang.Object
org.infinispan.factories.AbstractComponentRegistry
- All Implemented Interfaces:
org.infinispan.commons.api.Lifecycle
- Direct Known Subclasses:
ComponentRegistry,GlobalComponentRegistry
@Deprecated
public abstract class AbstractComponentRegistry
extends Object
implements org.infinispan.commons.api.Lifecycle
Deprecated.
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
getComponent(Class).
Components can be registered using 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 getOrCreateComponent(Class), which will look up the default factory for the component type (factories annotated
with the appropriate 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 ComponentStatus
enumeration. 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.RUNNING state.
Thread Safety: instances of GlobalComponentRegistry can be concurrently updated so all
the write operations are serialized through class intrinsic lock.- Since:
- 4.0
- Author:
- Manik Surtani, Galder ZamarreƱo
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDeprecated.protected abstract CompletionStage<Void>Deprecated.protected abstract ClassLoaderDeprecated.<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.protected abstract LoggetLog()Deprecated.protected abstract StringgetName()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.Deprecated.Retrieves the state of the registryabstract org.infinispan.commons.time.TimeServiceDeprecated.protected abstract voidDeprecated.protected abstract voidpostStop()Deprecated.protected abstract voidpreStart()Deprecated.protected abstract voidpreStop()Deprecated.final voidregisterComponent(Object component, Class<?> type) Deprecated.Registers a component in the registry under the given type, and injects any dependencies needed.final voidregisterComponent(Object component, String name) Deprecated.final voidregisterComponent(Object component, String name, boolean nameIsFQCN) Deprecated.protected voidregisterComponentInternal(Object component, String name, boolean nameIsFQCN) Deprecated.protected ClassLoaderDeprecated.Since 9.4, not usedprotected final voidregisterNonVolatileComponent(Object component, String name) Deprecated.protected voidDeprecated.voidrewire()Deprecated.Rewires components.voidstart()Deprecated.This starts the components in the registry, connecting to channels, starting service threads, etc.final voidstop()Deprecated.Stops the component and sets its status toComponentStatus.TERMINATEDonce it is done.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.voidwireDependencies(Object target, boolean startDependencies) 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 Details
-
state
Deprecated.
-
-
Method Details
-
getStatus
Deprecated.Retrieves the state of the registry- Returns:
- state of the registry
-
getClassLoader
Deprecated. -
getLog
Deprecated. -
wireDependencies
public void wireDependencies(Object target) throws org.infinispan.commons.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:
org.infinispan.commons.CacheConfigurationException- if there is a problem wiring the instance
-
wireDependencies
public void wireDependencies(Object target, boolean startDependencies) throws org.infinispan.commons.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 wirestartDependencies- whether to start injected components (if not already started)- Throws:
org.infinispan.commons.CacheConfigurationException- if there is a problem wiring the instance
-
registerComponent
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:
org.infinispan.commons.CacheConfigurationException- If a component is already registered with that name, or if a dependency cannot be resolved
-
registerComponent
Deprecated. -
registerComponent
Deprecated. -
registerNonVolatileComponent
Deprecated. -
registerComponentInternal
Deprecated. -
getOrCreateComponent
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:
org.infinispan.commons.CacheConfigurationException- if there is a problem with constructing or wiring the instance.
-
getOrCreateComponent
Deprecated. -
getOrCreateComponent
Deprecated. -
getComponent
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
Deprecated. -
getComponent
Deprecated. -
getComponent
Deprecated. -
getComponent
Deprecated. -
getOptionalComponent
Deprecated. -
registerDefaultClassLoader
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. -
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.- Specified by:
startin interfaceorg.infinispan.commons.api.Lifecycle
-
getName
Deprecated. -
preStart
protected abstract void preStart()Deprecated. -
postStart
protected abstract void postStart()Deprecated. -
delayStart
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.- Specified by:
stopin interfaceorg.infinispan.commons.api.Lifecycle
-
postStop
protected abstract void postStop()Deprecated. -
preStop
protected abstract void preStop()Deprecated. -
addShutdownHook
protected void addShutdownHook()Deprecated. -
removeShutdownHook
protected void removeShutdownHook()Deprecated. -
getTimeService
public abstract org.infinispan.commons.time.TimeService getTimeService()Deprecated.
-
BasicComponentRegistryinstead.