Class SupplierFactoryBridge<T>

java.lang.Object
org.glassfish.jersey.inject.hk2.SupplierFactoryBridge<T>
Type Parameters:
T - type which could be handled by Supplier and this bridge.
All Implemented Interfaces:
org.glassfish.hk2.api.Factory<T>

public class SupplierFactoryBridge<T> extends Object implements org.glassfish.hk2.api.Factory<T>
This class is able to find the 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.

  • Field Details

    • locator

      private org.glassfish.hk2.api.ServiceLocator locator
    • beanType

      private ParameterizedType beanType
    • beanName

      private String beanName
    • disposable

      private boolean disposable
    • disposableSuppliers

      private Map<Object,DisposableSupplier<T>> disposableSuppliers
  • Constructor Details

    • SupplierFactoryBridge

      SupplierFactoryBridge(org.glassfish.hk2.api.ServiceLocator locator, Type beanType, 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 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.
  • Method Details

    • provide

      public T provide()
      Specified by:
      provide in interface org.glassfish.hk2.api.Factory<T>
    • dispose

      public void dispose(T instance)
      Specified by:
      dispose in interface org.glassfish.hk2.api.Factory<T>