Class 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 Detail

      • 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