Helper class for injecting and calling lifecycle callbacks unmanaged instances for use by framework and library integrators.
Unmanaged<Foo> unmanagedFoo = new Unmanaged<Foo>(Foo.class); UnmanagedInstance<Foo> fooInstance = unmanagedFoo.newInstance(); Foo foo = fooInstance.produce().inject().postConstruct().get(); ... // Use the foo instance fooInstance.preDestroy().dispose();
An instance of this class can be safely held for the lifetime of the application.
UnmanagedInstances created by this class are not suitable for sharing between threads.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Field and Description |
|---|---|
| private final BeanManager | |
| private final InjectionTarget |
| Access | Constructor and Description |
|---|---|
| public | Unmanaged(BeanManager
the manager, Class<T> BeanManagerclass of the unmanaged instances clazz)Create an injector for the given class |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Unmanaged. |
| beanManager | back to summary |
|---|---|
| private final BeanManager beanManager | |
| injectionTarget | back to summary |
|---|---|
| private final InjectionTarget<T> injectionTarget | |
| Unmanaged | back to summary |
|---|---|
| public Unmanaged(BeanManager manager, Class<T> clazz) Create an injector for the given class
| |
| Unmanaged | back to summary |
|---|---|
| public Unmanaged(Class<T> clazz) Create an injector for the given class, using the current bean manager
| |
| newInstance | back to summary |
|---|---|
| public Unmanaged. Instantiate a new UnmanagedInstance
| |
Unmanaged
| Modifier and Type | Field and Description |
|---|---|
| private final CreationalContext | |
| private boolean | |
| private final InjectionTarget | |
| private T |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Unmanaged. | |
| public T | |
| public Unmanaged. | |
| public Unmanaged. | |
| public Unmanaged. | |
| public Unmanaged. |
| ctx | back to summary |
|---|---|
| private final CreationalContext<T> ctx | |
| disposed | back to summary |
|---|---|
| private boolean disposed | |
| injectionTarget | back to summary |
|---|---|
| private final InjectionTarget<T> injectionTarget | |
| instance | back to summary |
|---|---|
| private T instance | |
| UnmanagedInstance | back to summary |
|---|---|
| private UnmanagedInstance(BeanManager beanManager, InjectionTarget<T> injectionTarget) | |
| dispose | back to summary |
|---|---|
| public Unmanaged. Dispose of the instance, doing any necessary cleanup
| |
| get | back to summary |
|---|---|
| public T get() Get the instance
| |
| inject | back to summary |
|---|---|
| public Unmanaged. Inject the instance
| |
| postConstruct | back to summary |
|---|---|
| public Unmanaged. Call the @PostConstruct callback
| |
| preDestroy | back to summary |
|---|---|
| public Unmanaged. Call the @PreDestroy callback
| |
| produce | back to summary |
|---|---|
| public Unmanaged. Create the instance
| |