Package org.glassfish.jersey.inject.hk2
Class SupplierFactoryBridge<T>
- java.lang.Object
-
- org.glassfish.jersey.inject.hk2.SupplierFactoryBridge<T>
-
- Type Parameters:
T
- type which could be handled bySupplier
and this bridge.
- All Implemented Interfaces:
org.glassfish.hk2.api.Factory<T>
public class SupplierFactoryBridge<T> extends java.lang.Object implements org.glassfish.hk2.api.Factory<T>
This class is able to find theSupplier
of the particular type and use thisSupplier
to create a new instance. If theSupplier
is not found thennull
is returned. If the foundSupplier
is a type ofDisposableSupplier
then this bridge can delegateFactory.dispose(Object)
invocation toDisposableSupplier.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.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description SupplierFactoryBridge(org.glassfish.hk2.api.ServiceLocator locator, java.lang.reflect.Type beanType, java.lang.String beanName, boolean disposable)
Constructor for a new bridge.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose(T instance)
T
provide()
-
-
-
Field Detail
-
locator
private org.glassfish.hk2.api.ServiceLocator locator
-
beanType
private java.lang.reflect.ParameterizedType beanType
-
beanName
private java.lang.String beanName
-
disposable
private boolean disposable
-
disposableSuppliers
private java.util.Map<java.lang.Object,DisposableSupplier<T>> disposableSuppliers
-
-
Constructor Detail
-
SupplierFactoryBridge
SupplierFactoryBridge(org.glassfish.hk2.api.ServiceLocator locator, java.lang.reflect.Type beanType, java.lang.String beanName, boolean disposable)
Constructor for a new bridge.- Parameters:
locator
- currently used locator, all factory invocations will be delegated to this locator.beanType
- generic type of aSupplier
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.
-
-