BasicComponentRegistry
instead.@Deprecated public abstract class AbstractComponentRegistry extends Object implements Lifecycle
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: Lifecycle.start()
is calledCache.stop()
is calledComponentStatus.RUNNING
state.
Thread Safety: instances of GlobalComponentRegistry
can be concurrently updated so all
the write operations are serialized through class intrinsic lock.Modifier and Type | Field and Description |
---|---|
protected ComponentStatus |
state
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addShutdownHook()
Deprecated.
|
protected abstract ClassLoader |
getClassLoader()
Deprecated.
|
<T> T |
getComponent(Class<T> type)
Deprecated.
Retrieves a component of a specified type from the registry, or null if it cannot be found.
|
<T> T |
getComponent(Class<T> componentClass,
String name)
Deprecated.
|
<T> T |
getComponent(String componentClassName)
Deprecated.
|
<T> T |
getComponent(String componentClassName,
String name)
Deprecated.
|
<T> T |
getComponent(String componentClassName,
String name,
boolean nameIsFQCN)
Deprecated.
|
protected abstract Log |
getLog()
Deprecated.
|
<T> Optional<T> |
getOptionalComponent(Class<T> type)
Deprecated.
|
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 the
DefaultFactoryFor annotation that is capable of creating the component
class). |
protected <T> T |
getOrCreateComponent(Class<T> componentClass,
String name)
Deprecated.
|
protected <T> T |
getOrCreateComponent(Class<T> componentClass,
String name,
boolean nameIsFQCN)
Deprecated.
|
ComponentStatus |
getStatus()
Deprecated.
Retrieves the state of the registry
|
abstract TimeService |
getTimeService()
Deprecated.
|
protected abstract void |
postStart()
Deprecated.
|
protected abstract void |
postStop()
Deprecated.
|
protected abstract void |
preStart()
Deprecated.
|
protected abstract void |
preStop()
Deprecated.
|
void |
registerComponent(Object component,
Class<?> type)
Deprecated.
Registers a component in the registry under the given type, and injects any dependencies needed.
|
void |
registerComponent(Object component,
String name)
Deprecated.
|
void |
registerComponent(Object component,
String name,
boolean nameIsFQCN)
Deprecated.
|
protected void |
registerComponentInternal(Object component,
String name,
boolean nameIsFQCN)
Deprecated.
|
protected ClassLoader |
registerDefaultClassLoader(ClassLoader loader)
Deprecated.
Since 9.4, not used
|
protected void |
registerNonVolatileComponent(Object component,
String name)
Deprecated.
|
protected void |
removeShutdownHook()
Deprecated.
|
void |
rewire()
Deprecated.
Rewires components.
|
void |
start()
Deprecated.
This starts the components in the registry, connecting to channels, starting service threads, etc.
|
void |
stop()
Deprecated.
Stops the component and sets its status to
ComponentStatus.TERMINATED once it
is done. |
void |
wireDependencies(Object target)
Deprecated.
Wires an object instance with dependencies annotated with the
Inject annotation, creating more components
as needed based on the Configuration passed in if these additional components don't exist in the ComponentRegistry . |
protected volatile ComponentStatus state
public ComponentStatus getStatus()
protected abstract ClassLoader getClassLoader()
protected abstract Log getLog()
public void wireDependencies(Object target) throws CacheConfigurationException
Inject
annotation, creating more components
as needed based on the Configuration passed in if these additional components don't exist in the ComponentRegistry
. Strictly for components that don't otherwise live in the registry and have a lifecycle, such
as Commands.target
- object to wireCacheConfigurationException
- if there is a problem wiring the instancepublic final void registerComponent(Object component, Class<?> type)
component
- component to registertype
- type of componentCacheConfigurationException
- If a component is already registered with that
name, or if a dependency cannot be resolvedpublic final void registerComponent(Object component, String name, boolean nameIsFQCN)
protected final void registerNonVolatileComponent(Object component, String name)
protected void registerComponentInternal(Object component, String name, boolean nameIsFQCN)
protected <T> T getOrCreateComponent(Class<T> componentClass)
DefaultFactoryFor
annotation 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 with Inject
.
Summing it up, component retrieval happens in the following order:Configuration
that
may be injected from an external system. 3. Look for a class definition passed in to the Configuration
-
such as an EvictionPolicy implementation 4. Attempt to create it by looking for an appropriate factory (annotated
with DefaultFactoryFor
)
componentClass
- type of component to be retrieved. Should not be null.CacheConfigurationException
- if there is a problem with constructing or wiring the instance.protected <T> T getOrCreateComponent(Class<T> componentClass, String name)
protected <T> T getOrCreateComponent(Class<T> componentClass, String name, boolean nameIsFQCN)
public <T> T getComponent(Class<T> type)
type
- type to findpublic <T> T getComponent(String componentClassName)
public <T> T getComponent(String componentClassName, String name, boolean nameIsFQCN)
protected ClassLoader registerDefaultClassLoader(ClassLoader loader)
public void rewire()
public void start()
ComponentStatus.INITIALIZING
state, it will be initialized first.protected abstract void preStart()
protected abstract void postStart()
public final void stop()
ComponentStatus.TERMINATED
once it
is done. If the component is not in the ComponentStatus.RUNNING
state, this is a
no-op.protected abstract void postStop()
protected abstract void preStop()
protected void addShutdownHook()
protected void removeShutdownHook()
public abstract TimeService getTimeService()
Copyright © 2021 JBoss by Red Hat. All rights reserved.