public class BasicComponentRegistryImpl extends Object implements BasicComponentRegistry
| Constructor and Description |
|---|
BasicComponentRegistryImpl(ModuleRepository moduleRepository,
boolean isGlobal,
BasicComponentRegistry next) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDynamicDependency(String ownerComponentName,
String dependencyComponentName)
Add a dynamic dependency between two components.
|
<T,U extends T> |
getComponent(String name,
Class<U> componentType)
Looks up a running component named
name in the registry, or registers it if necessary. |
MBeanMetadata |
getMBeanMetadata(String className) |
Collection<ComponentRef<?>> |
getRegisteredComponents()
Run
consumer for each registered component in the current scope. |
boolean |
hasComponentAccessor(String componentClassName)
Check if a component accessor has been registered for class
componentClassName |
<T> ComponentRef<T> |
lazyGetComponent(Class<T> componentType)
Looks up a component named
name in the registry, or registers it if necessary. |
void |
registerAlias(String aliasName,
String targetComponentName,
Class<?> targetComponentType)
Register an alias to another component.
|
<T> ComponentRef<T> |
registerComponent(String componentName,
T instance,
boolean manageLifecycle)
Register a component named
componentName. |
void |
replaceComponent(String componentName,
Object newInstance,
boolean manageLifecycle)
Replace an existing component.
|
void |
rewire()
Rewire all the injections after a component was replaced with
BasicComponentRegistry.replaceComponent(String, Object, boolean). |
void |
stop()
Stop the registry and all the components that have been started.
|
String |
toString() |
void |
wireDependencies(Object target,
boolean startDependencies)
Look up the dependencies of
target as if it were a component, and inject them. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetComponent, registerComponentpublic BasicComponentRegistryImpl(ModuleRepository moduleRepository, boolean isGlobal, BasicComponentRegistry next)
public <T,U extends T> ComponentRef<T> getComponent(String name, Class<U> componentType)
BasicComponentRegistryname in the registry, or registers it if necessary.
If another thread is registering the component, wait for the other thread to finish.
The component is wired (dependencies are injected) during registration.
Use ComponentRef.running() to start the component.
getComponent in interface BasicComponentRegistryname - The component name.componentType - The expected component type, not used to identify the component.public <T> ComponentRef<T> lazyGetComponent(Class<T> componentType)
BasicComponentRegistryname in the registry, or registers it if necessary.
The component isn't instantiated neither running. Invoke ComponentRef.running() to instantiate and start it.lazyGetComponent in interface BasicComponentRegistrycomponentType - The expected component type, not used to identify the component.public MBeanMetadata getMBeanMetadata(String className)
getMBeanMetadata in interface BasicComponentRegistryclassNamepublic void wireDependencies(Object target, boolean startDependencies)
BasicComponentRegistrytarget as if it were a component, and inject them.
Behaves as if every dependency was resolved with getComponent(String, Class).
wireDependencies in interface BasicComponentRegistrytarget - An instance of a class with Inject annotations.startDependencies - If true, start the dependencies before injecting them.public <T> ComponentRef<T> registerComponent(String componentName, T instance, boolean manageLifecycle)
BasicComponentRegistrycomponentName.
If the component has dependencies, look them up using BasicComponentRegistry.getComponent(String, Class)
and inject them.
registerComponent in interface BasicComponentRegistrycomponentName - The component name.instance - The component instance.manageLifecycle - false if the registry should ignore methods annotated with
Start and Stoppublic void registerAlias(String aliasName, String targetComponentName, Class<?> targetComponentType)
BasicComponentRegistryComponents that depend on the alias will behave as if they depended on the original component directly.
registerAlias in interface BasicComponentRegistrypublic void addDynamicDependency(String ownerComponentName, String dependencyComponentName)
BasicComponentRegistryaddDynamicDependency in interface BasicComponentRegistryownerComponentName - The dependent component's name.dependencyComponentName - The component depended on.
Note: doesn't have any effect if the owner component is already started. The stop order is determined exclusively by the start order.
public void replaceComponent(String componentName, Object newInstance, boolean manageLifecycle)
BasicComponentRegistryDependencies will be injected, and the start/stop methods will run if manageLifecycle is true.
The new component is stopped exactly when the replaced component would have been stopped,
IGNORING DEPENDENCY CHANGES.
Need to call BasicComponentRegistry.rewire() to inject the new component in all the components that depend on it.
If the component is global, need to call BasicComponentRegistry.rewire() on all the cache component registries as well.
replaceComponent in interface BasicComponentRegistrypublic void rewire()
BasicComponentRegistryBasicComponentRegistry.replaceComponent(String, Object, boolean).
For testing purposes only.rewire in interface BasicComponentRegistrypublic Collection<ComponentRef<?>> getRegisteredComponents()
BasicComponentRegistryconsumer for each registered component in the current scope.getRegisteredComponents in interface BasicComponentRegistrypublic void stop()
BasicComponentRegistryComponents cannot be instantiated or started after this.
stop in interface BasicComponentRegistrypublic boolean hasComponentAccessor(String componentClassName)
BasicComponentRegistrycomponentClassNamehasComponentAccessor in interface BasicComponentRegistryCopyright © 2022 JBoss by Red Hat. All rights reserved.