Class BasicComponentRegistryImpl

java.lang.Object
org.infinispan.factories.impl.BasicComponentRegistryImpl
All Implemented Interfaces:
BasicComponentRegistry

public class BasicComponentRegistryImpl extends Object implements BasicComponentRegistry
Since:
8.2
Author:
Dan Berindei
  • Constructor Details

    • BasicComponentRegistryImpl

      public BasicComponentRegistryImpl(org.infinispan.manager.ModuleRepository moduleRepository, boolean isGlobal, BasicComponentRegistry next)
  • Method Details

    • getComponent

      public <T, U extends T> ComponentRef<T> getComponent(String name, Class<U> componentType)
      Description copied from interface: BasicComponentRegistry
      Looks up a running component named name 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 interface BasicComponentRegistry
      Parameters:
      name - The component name.
      componentType - The expected component type, not used to identify the component.
    • lazyGetComponent

      public <T> ComponentRef<T> lazyGetComponent(Class<T> componentType)
      Description copied from interface: BasicComponentRegistry
      Looks up a component named name in the registry, or registers it if necessary. The component isn't instantiated neither running. Invoke ComponentRef.running() to instantiate and start it.
      Specified by:
      lazyGetComponent in interface BasicComponentRegistry
      Parameters:
      componentType - The expected component type, not used to identify the component.
    • blameInitialization

      public void blameInitialization()
      Description copied from interface: BasicComponentRegistry
      Display the time components took to initialize.

      Display the time each component took between the different status until reaching a running state. It does not verify any time after the component has started. The output is only available when trace level log is enabled.

      Specified by:
      blameInitialization in interface BasicComponentRegistry
    • getMBeanMetadata

      public MBeanMetadata getMBeanMetadata(String className)
      Specified by:
      getMBeanMetadata in interface BasicComponentRegistry
      Returns:
      The MBean metadata for class className
    • wireDependencies

      public void wireDependencies(Object target, boolean startDependencies)
      Description copied from interface: BasicComponentRegistry
      Look up the dependencies of target as if it were a component, and inject them.

      Behaves as if every dependency was resolved with getComponent(String, Class).

      Specified by:
      wireDependencies in interface BasicComponentRegistry
      Parameters:
      target - An instance of a class with Inject annotations.
      startDependencies - If true, 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 named componentName.

      If the component has dependencies, look them up using BasicComponentRegistry.getComponent(String, Class) and inject them.

      Specified by:
      registerComponent in interface BasicComponentRegistry
      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 interface BasicComponentRegistry
    • addDynamicDependency

      public void addDynamicDependency(String ownerComponentName, String dependencyComponentName)
      Description copied from interface: BasicComponentRegistry
      Add a dynamic dependency between two components.
      Specified by:
      addDynamicDependency in interface BasicComponentRegistry
      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

      public void replaceComponent(String componentName, Object newInstance, boolean manageLifecycle)
      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 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.

      Specified by:
      replaceComponent in interface BasicComponentRegistry
    • rewire

      public void rewire()
      Description copied from interface: BasicComponentRegistry
      Rewire all the injections after a component was replaced with BasicComponentRegistry.replaceComponent(String, Object, boolean). For testing purposes only.
      Specified by:
      rewire in interface BasicComponentRegistry
    • getRegisteredComponents

      public Collection<ComponentRef<?>> getRegisteredComponents()
      Description copied from interface: BasicComponentRegistry
      Run consumer for each registered component in the current scope.
      Specified by:
      getRegisteredComponents in interface BasicComponentRegistry
    • 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 interface BasicComponentRegistry
    • hasComponentAccessor

      public boolean hasComponentAccessor(String componentClassName)
      Description copied from interface: BasicComponentRegistry
      Check if a component accessor has been registered for class componentClassName
      Specified by:
      hasComponentAccessor in interface BasicComponentRegistry
    • toString

      public String toString()
      Overrides:
      toString in class Object