Class Beans

java.lang.Object
com.axelor.inject.Beans

@Singleton public final class Beans extends Object
A singleton class that can be used to get instances of injetable services where injection is not possible.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    get(Class<T> type)
    Returns the appropriate instance for the given injection type.
    static <T> T
    get(Class<T> type, Annotation qualifier)
    Returns the appropriate instance for the given injection type qualified by the given annotation.
    static <T> T
    inject(T bean)
    Injects dependencies into the fields and methods of bean.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • get

      public static <T> T get(Class<T> type)
      Returns the appropriate instance for the given injection type.
      Type Parameters:
      T - type of the requested bean
      Parameters:
      type - the requested type
      Returns:
      an appropriate instance of the given type
    • get

      public static <T> T get(Class<T> type, Annotation qualifier)
      Returns the appropriate instance for the given injection type qualified by the given annotation.
      Type Parameters:
      T - type of the requested bean
      Parameters:
      type - the requested type
      qualifier - the qualifier annotation
      Returns:
      an appropriate instance of the given type
    • inject

      public static <T> T inject(T bean)
      Injects dependencies into the fields and methods of bean.
      Type Parameters:
      T - type of the bean
      Parameters:
      bean - to inject members on
      Returns:
      the bean itself