Package io.gitbub.devlibx.easy.helper
Class ApplicationContext
java.lang.Object
io.gitbub.devlibx.easy.helper.ApplicationContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TgetInstance(com.google.inject.Key<T> key) static <T> TgetInstance(Class<T> cls) static <T> Optional<T>getOptionalInstance(Class<T> cls) static voidsetInjector(com.google.inject.Injector injector)
-
Constructor Details
-
ApplicationContext
public ApplicationContext()
-
-
Method Details
-
setInjector
public static void setInjector(com.google.inject.Injector injector) - Parameters:
injector- singleton injector to be used for objects
-
getInstance
- Type Parameters:
T- type of class to request- Parameters:
cls- type of class to request- Returns:
- instance of request type
-
getInstance
public static <T> T getInstance(com.google.inject.Key<T> key) - Type Parameters:
T- type of class to request with help of key- Parameters:
key- type of class to request with help of key- Returns:
- instance of request type
-
getOptionalInstance
- Type Parameters:
T- type of class to request- Parameters:
cls- type of class to request- Returns:
- instance of request type or Optional.empty() otherwise
-