Interface Injector


  • public interface Injector
    A pluggable strategy for creating and possibly dependency injecting objects which could be implemented using straight forward reflection or using Spring or CDI to perform dependency injection.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T newInstance​(Class<T> type)
      Instantiates a new instance of the given type; possibly injecting values into the object in the process (bean post processing)
      <T> T newInstance​(Class<T> type, boolean postProcessBean)
      Instantiates a new instance of the given type; possibly injecting values into the object in the process (bean post processing if enabled)
      <T> T newInstance​(Class<T> type, String factoryMethod)
      Instantiates a new instance of the given type by using the factory method (this will not perform bean post processing)
      boolean supportsAutoWiring()
      Whether the injector supports creating new instances using auto-wiring.
    • Method Detail

      • newInstance

        <T> T newInstance​(Class<T> type)
        Instantiates a new instance of the given type; possibly injecting values into the object in the process (bean post processing)
        Parameters:
        type - the type of object to create
        Returns:
        a newly created instance
      • newInstance

        <T> T newInstance​(Class<T> type,
                          String factoryMethod)
        Instantiates a new instance of the given type by using the factory method (this will not perform bean post processing)
        Parameters:
        type - the type of object to create
        factoryMethod - to create the new instance via factory method which must be public static and return the type
        Returns:
        a newly created instance
      • newInstance

        <T> T newInstance​(Class<T> type,
                          boolean postProcessBean)
        Instantiates a new instance of the given type; possibly injecting values into the object in the process (bean post processing if enabled)
        Parameters:
        type - the type of object to create
        postProcessBean - whether to post process the bean
        Returns:
        a newly created instance
      • supportsAutoWiring

        boolean supportsAutoWiring()
        Whether the injector supports creating new instances using auto-wiring. If this is possible then bean instances is attempt first to be created this way and if not, then the bean can only be created if there is a public no-arg constructor.