Interface ContainerAccessor


public interface ContainerAccessor
The ContainerAccessor allows access to the underlying plugin container (e.g. spring).
Since:
2.5.0
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    createBean(Class<T> clazz)
    Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies.
    <T> T
    getBean(Class<T> requiredType)
    Gets single bean of given type
    <T> T
    Retrieves a bean by name from the container.
    <T> Collection<T>
    getBeansOfType(Class<T> interfaceClass)
    Gets all the beans that implement a given interface
    <T> T
    injectBean(T bean)
    Injects an existing bean instance with any dependencies via setters or private field injection
  • Method Details

    • createBean

      <T> T createBean(Class<T> clazz)
      Will ask the container to instantiate a bean of the given class and does inject all constructor defined dependencies. Currently we have only spring as a container that will autowire this bean.
      Parameters:
      clazz - the Class to instantiate. Cannot be null.
      Returns:
      an instantiated bean.
    • injectBean

      <T> T injectBean(T bean)
      Injects an existing bean instance with any dependencies via setters or private field injection
      Type Parameters:
      T - The bean type
      Parameters:
      bean - The instantiated bean to inject
      Since:
      3.0
    • getBean

      <T> T getBean(String id)
      Retrieves a bean by name from the container.
      Parameters:
      id - the id of the container bean, cannot be null
      Returns:
      the bean object, or null if cannot be found
      Since:
      3.0
    • getBean

      <T> T getBean(Class<T> requiredType)
      Gets single bean of given type
      Type Parameters:
      T - The bean type
      Parameters:
      requiredType - The expected bean type
      Returns:
      The bean object, or null if cannot be found
      Since:
      8.0
    • getBeansOfType

      <T> Collection<T> getBeansOfType(Class<T> interfaceClass)
      Gets all the beans that implement a given interface
      Type Parameters:
      T - The target interface type
      Parameters:
      interfaceClass - The interface class
      Returns:
      A collection of implementations from the plugin's container