Class ClassObjectFactory<T>

  • Type Parameters:
    T - the type of the instances produced
    All Implemented Interfaces:
    Constructable<T>

    public class ClassObjectFactory<T>
    extends java.lang.Object
    implements Constructable<T>
    Object factory for concrete classes. This factory use the given Constructor to construct the associated class, inject it using the given Injections and do life cycle callbacks using the provided LifeCycleCallbacks instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      ClassObjectFactory​(java.lang.reflect.Constructor<T> constructor, LifeCycleCallbacks lifeCycleCallbacks)
      Constructs a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T create​(java.util.List<Injection> injections)
      Creates an instance.
      void destroy​(T instance)
      Destroys an instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ClassObjectFactory

        public ClassObjectFactory​(java.lang.reflect.Constructor<T> constructor,
                                  LifeCycleCallbacks lifeCycleCallbacks)
        Constructs a new instance.
        Parameters:
        constructor - a Constructor which produces the required class, cannot be null
        lifeCycleCallbacks - a LifeCycleCallbacks instance, cannot be null
    • Method Detail

      • create

        public T create​(java.util.List<Injection> injections)
                 throws org.int4.dirk.api.instantiation.CreationException
        Description copied from interface: Constructable
        Creates an instance.
        Specified by:
        create in interface Constructable<T>
        Parameters:
        injections - a list of Injection containing values to be injected, never null or contains nulls but can be empty
        Returns:
        an instance, or null if it could not be provided
        Throws:
        org.int4.dirk.api.instantiation.CreationException - when instantiation fails
      • destroy

        public void destroy​(T instance)
        Description copied from interface: Constructable
        Destroys an instance.
        Specified by:
        destroy in interface Constructable<T>
        Parameters:
        instance - an instance to destroy, cannot be null