Class 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 java.lang.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.

    • 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 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 Detail

      • 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>