Package com.axelor.inject
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
All Methods Static Methods Concrete Methods 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 ofbean
.
-
-
-
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 typequalifier
- 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 ofbean
.- Type Parameters:
T
- type of the bean- Parameters:
bean
- to inject members on- Returns:
- the bean itself
-
-