public class Injections
extends java.lang.Object
Constructor and Description |
---|
Injections() |
Modifier and Type | Method and Description |
---|---|
static InjectionManager |
createInjectionManager()
Creates a
InjectionManager without parent and initial binder. |
static InjectionManager |
createInjectionManager(Binder binder)
Creates a
InjectionManager with initial binder that is immediately registered. |
static InjectionManager |
createInjectionManager(java.lang.Object parent)
Creates an unnamed, parented
InjectionManager . |
static <T> T |
getOrCreate(InjectionManager injectionManager,
java.lang.Class<T> clazz)
Get the class by contract or create and inject a new instance.
|
private static InjectionManagerFactory |
lookupInjectionManagerFactory() |
private static <T> java.util.Optional<T> |
lookupService(java.lang.Class<T> clazz)
Look for a service of given type.
|
public static InjectionManager createInjectionManager()
InjectionManager
without parent and initial binder.public static InjectionManager createInjectionManager(Binder binder)
InjectionManager
with initial binder that is immediately registered.binder
- custom the binder
.public static InjectionManager createInjectionManager(java.lang.Object parent)
InjectionManager
. In case the parent
injection manager is not specified, the
locator will not be parented.parent
- The parent of this injection manager. Services can be found in the parent (and all grand-parents). May be
null
. An underlying DI provider checks whether the parent is in a proper type.private static InjectionManagerFactory lookupInjectionManagerFactory()
private static <T> java.util.Optional<T> lookupService(java.lang.Class<T> clazz)
T
- type of service to look for.clazz
- type of service to look for.null
if service of given type cannot be found.Priority
public static <T> T getOrCreate(InjectionManager injectionManager, java.lang.Class<T> clazz)
T
- instance type.injectionManager
- DI injection manager.clazz
- class of the instance to be provider.