Class BasicComponentRegistryImpl
- All Implemented Interfaces:
BasicComponentRegistry
- Since:
- 8.2
- Author:
- Dan Berindei
-
Constructor Summary
ConstructorsConstructorDescriptionBasicComponentRegistryImpl(org.infinispan.manager.ModuleRepository moduleRepository, boolean isGlobal, BasicComponentRegistry next) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDynamicDependency(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 namednamein the registry, or registers it if necessary.getMBeanMetadata(String className) Runconsumerfor each registered component in the current scope.booleanhasComponentAccessor(String componentClassName) Check if a component accessor has been registered for classcomponentClassName<T> ComponentRef<T> lazyGetComponent(Class<T> componentType) Looks up a component namednamein the registry, or registers it if necessary.voidregisterAlias(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.voidreplaceComponent(String componentName, Object newInstance, boolean manageLifecycle) Replace an existing component.voidrewire()Rewire all the injections after a component was replaced withBasicComponentRegistry.replaceComponent(String, Object, boolean).voidstop()Stop the registry and all the components that have been started.toString()voidwireDependencies(Object target, boolean startDependencies) Look up the dependencies oftargetas if it were a component, and inject them.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:BasicComponentRegistryLooks up a running component namednamein 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:
getComponentin interfaceBasicComponentRegistry- Parameters:
name- The component name.componentType- The expected component type, not used to identify the component.
-
lazyGetComponent
Description copied from interface:BasicComponentRegistryLooks up a component namednamein the registry, or registers it if necessary. The component isn't instantiated neither running. InvokeComponentRef.running()to instantiate and start it.- Specified by:
lazyGetComponentin interfaceBasicComponentRegistry- Parameters:
componentType- The expected component type, not used to identify the component.
-
getMBeanMetadata
- Specified by:
getMBeanMetadatain interfaceBasicComponentRegistry- Returns:
- The MBean metadata for class
className
-
wireDependencies
Description copied from interface:BasicComponentRegistryLook up the dependencies oftargetas if it were a component, and inject them.Behaves as if every dependency was resolved with
getComponent(String, Class).- Specified by:
wireDependenciesin interfaceBasicComponentRegistry- Parameters:
target- An instance of a class withInjectannotations.startDependencies- Iftrue, start the dependencies before injecting them.
-
registerComponent
public <T> ComponentRef<T> registerComponent(String componentName, T instance, boolean manageLifecycle) Description copied from interface:BasicComponentRegistryRegister a component namedcomponentName.If the component has dependencies, look them up using
BasicComponentRegistry.getComponent(String, Class)and inject them.- Specified by:
registerComponentin interfaceBasicComponentRegistry- Parameters:
componentName- The component name.instance- The component instance.manageLifecycle-falseif the registry should ignore methods annotated with Start and Stop
-
registerAlias
public void registerAlias(String aliasName, String targetComponentName, Class<?> targetComponentType) Description copied from interface:BasicComponentRegistryRegister an alias to another component.Components that depend on the alias will behave as if they depended on the original component directly.
- Specified by:
registerAliasin interfaceBasicComponentRegistry
-
addDynamicDependency
Description copied from interface:BasicComponentRegistryAdd a dynamic dependency between two components.- Specified by:
addDynamicDependencyin 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:BasicComponentRegistryReplace an existing component. For testing purposes only, NOT THREAD-SAFE.Dependencies will be injected, and the start/stop methods will run if
manageLifecycleistrue. 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:
replaceComponentin interfaceBasicComponentRegistry
-
rewire
public void rewire()Description copied from interface:BasicComponentRegistryRewire all the injections after a component was replaced withBasicComponentRegistry.replaceComponent(String, Object, boolean). For testing purposes only.- Specified by:
rewirein interfaceBasicComponentRegistry
-
getRegisteredComponents
Description copied from interface:BasicComponentRegistryRunconsumerfor each registered component in the current scope.- Specified by:
getRegisteredComponentsin interfaceBasicComponentRegistry
-
stop
public void stop()Description copied from interface:BasicComponentRegistryStop the registry and all the components that have been started.Components cannot be instantiated or started after this.
- Specified by:
stopin interfaceBasicComponentRegistry
-
hasComponentAccessor
Description copied from interface:BasicComponentRegistryCheck if a component accessor has been registered for classcomponentClassName- Specified by:
hasComponentAccessorin interfaceBasicComponentRegistry
-
toString
-