Class BasicComponentRegistryImpl
- All Implemented Interfaces:
BasicComponentRegistry
- Since:
- 8.2
- Author:
- Dan Berindei
-
Constructor Summary
ConstructorDescriptionBasicComponentRegistryImpl
(org.infinispan.manager.ModuleRepository moduleRepository, boolean isGlobal, BasicComponentRegistry next) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDynamicDependency
(String ownerComponentName, String dependencyComponentName) Add a dynamic dependency between two components.<T,
U extends T>
ComponentRef<T> getComponent
(String name, Class<U> componentType) Looks up a running component namedname
in the registry, or registers it if necessary.getMBeanMetadata
(String className) Runconsumer
for each registered component in the current scope.boolean
hasComponentAccessor
(String componentClassName) Check if a component accessor has been registered for classcomponentClassName
<T> ComponentRef
<T> lazyGetComponent
(Class<T> componentType) Looks up a component namedname
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 namedcomponentName
.void
replaceComponent
(String componentName, Object newInstance, boolean manageLifecycle) Replace an existing component.void
rewire()
Rewire all the injections after a component was replaced withBasicComponentRegistry.replaceComponent(String, Object, boolean)
.void
stop()
Stop the registry and all the components that have been started.toString()
void
wireDependencies
(Object target, boolean startDependencies) Look up the dependencies oftarget
as if it were a component, and inject them.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.infinispan.factories.impl.BasicComponentRegistry
getComponent, registerComponent
-
Constructor Details
-
BasicComponentRegistryImpl
public BasicComponentRegistryImpl(org.infinispan.manager.ModuleRepository moduleRepository, boolean isGlobal, BasicComponentRegistry next)
-
-
Method Details
-
getComponent
Description copied from interface:BasicComponentRegistry
Looks up a running component namedname
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.- Specified by:
getComponent
in interfaceBasicComponentRegistry
- Parameters:
name
- The component name.componentType
- The expected component type, not used to identify the component.
-
lazyGetComponent
Description copied from interface:BasicComponentRegistry
Looks up a component namedname
in the registry, or registers it if necessary. The component isn't instantiated neither running. InvokeComponentRef.running()
to instantiate and start it.- Specified by:
lazyGetComponent
in interfaceBasicComponentRegistry
- Parameters:
componentType
- The expected component type, not used to identify the component.
-
getMBeanMetadata
- Specified by:
getMBeanMetadata
in interfaceBasicComponentRegistry
- Returns:
- The MBean metadata for class
className
-
wireDependencies
Description copied from interface:BasicComponentRegistry
Look up the dependencies oftarget
as if it were a component, and inject them.Behaves as if every dependency was resolved with
getComponent(String, Class)
.- Specified by:
wireDependencies
in interfaceBasicComponentRegistry
- Parameters:
target
- An instance of a class withInject
annotations.startDependencies
- Iftrue
, start the dependencies before injecting them.
-
registerComponent
public <T> ComponentRef<T> registerComponent(String componentName, T instance, boolean manageLifecycle) Description copied from interface:BasicComponentRegistry
Register a component namedcomponentName
.If the component has dependencies, look them up using
BasicComponentRegistry.getComponent(String, Class)
and inject them.- Specified by:
registerComponent
in interfaceBasicComponentRegistry
- Parameters:
componentName
- The component name.instance
- The component instance.manageLifecycle
-false
if the registry should ignore methods annotated with Start and Stop
-
registerAlias
public void registerAlias(String aliasName, String targetComponentName, Class<?> targetComponentType) Description copied from interface:BasicComponentRegistry
Register an alias to another component.Components that depend on the alias will behave as if they depended on the original component directly.
- Specified by:
registerAlias
in interfaceBasicComponentRegistry
-
addDynamicDependency
Description copied from interface:BasicComponentRegistry
Add a dynamic dependency between two components.- Specified by:
addDynamicDependency
in interfaceBasicComponentRegistry
- Parameters:
ownerComponentName
- 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.
-
replaceComponent
Description copied from interface:BasicComponentRegistry
Replace an existing component. For testing purposes only, NOT THREAD-SAFE.Dependencies will be injected, and the start/stop methods will run if
manageLifecycle
istrue
. The new component is stopped exactly when the replaced component would have been stopped, IGNORING DEPENDENCY CHANGES. Need to callBasicComponentRegistry.rewire()
to inject the new component in all the components that depend on it. If the component is global, need to callBasicComponentRegistry.rewire()
on all the cache component registries as well.- Specified by:
replaceComponent
in interfaceBasicComponentRegistry
-
rewire
public void rewire()Description copied from interface:BasicComponentRegistry
Rewire all the injections after a component was replaced withBasicComponentRegistry.replaceComponent(String, Object, boolean)
. For testing purposes only.- Specified by:
rewire
in interfaceBasicComponentRegistry
-
getRegisteredComponents
Description copied from interface:BasicComponentRegistry
Runconsumer
for each registered component in the current scope.- Specified by:
getRegisteredComponents
in interfaceBasicComponentRegistry
-
stop
public void stop()Description copied from interface:BasicComponentRegistry
Stop the registry and all the components that have been started.Components cannot be instantiated or started after this.
- Specified by:
stop
in interfaceBasicComponentRegistry
-
hasComponentAccessor
Description copied from interface:BasicComponentRegistry
Check if a component accessor has been registered for classcomponentClassName
- Specified by:
hasComponentAccessor
in interfaceBasicComponentRegistry
-
toString
-