T
- type which could be handled by Supplier
and this bridge.public class SupplierFactoryBridge<T>
extends java.lang.Object
implements org.glassfish.hk2.api.Factory<T>
Supplier
of the particular type and use this Supplier
to create a new
instance. If the Supplier
is not found then null
is returned.
If the found Supplier
is a type of DisposableSupplier
then this bridge can delegate
Factory.dispose(Object)
invocation to DisposableSupplier.dispose(Object)
.
It's recommended to register the instance of this class as a singleton and then the provide()
is called according to
a provided scope (for the created instance) during the binding process.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
beanName |
private java.lang.reflect.ParameterizedType |
beanType |
private boolean |
disposable |
private java.util.Map<java.lang.Object,DisposableSupplier<T>> |
disposableSuppliers |
private org.glassfish.hk2.api.ServiceLocator |
locator |
Constructor and Description |
---|
SupplierFactoryBridge(org.glassfish.hk2.api.ServiceLocator locator,
java.lang.reflect.Type beanType,
java.lang.String beanName,
boolean disposable)
Constructor for a new bridge.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose(T instance) |
T |
provide() |
private org.glassfish.hk2.api.ServiceLocator locator
private java.lang.reflect.ParameterizedType beanType
private java.lang.String beanName
private boolean disposable
private java.util.Map<java.lang.Object,DisposableSupplier<T>> disposableSuppliers
SupplierFactoryBridge(org.glassfish.hk2.api.ServiceLocator locator, java.lang.reflect.Type beanType, java.lang.String beanName, boolean disposable)
locator
- currently used locator, all factory invocations will be delegated to this locator.beanType
- generic type of a Supplier
which is looked for in locator and on which the creation of
the new instance is delegated.beanName
- name of the bean that is provided by supplier.disposable
- flag whether the bridge is set up for disposing the created object.