public class InjectorBuilder extends Object
InjectorFactory
using
ServiceLoader
and for obtaining a SimpleInjector
.
The builder takes care that the factory and simple injector are built only
once. For test code, make sure to call
setInjectorFactory(InjectorFactory)
before each test case to force
the retrieval of a new factory and injector. This is important because if the
simple injector is not created again it will use cached Injector
instances from other tests.Constructor and Description |
---|
InjectorBuilder() |
Modifier and Type | Method and Description |
---|---|
static Injector |
getInjector()
Gets an injector that support injection into any type of object and
performs caching of the injectors obtained from the
InjectorFactory . |
static InjectorFactory |
getInjectorFactory()
Gets the injector factory by using the first one found using
ServiceLoader . |
static void |
setInjectorFactory(InjectorFactory aFactory)
Sets the injector factory.
|
public static void setInjectorFactory(InjectorFactory aFactory)
aFactory
- Factory to use.public static InjectorFactory getInjectorFactory()
ServiceLoader
.public static Injector getInjector()
InjectorFactory
.Copyright © 2022. All rights reserved.