Package ninja.utils

Class ImplFromPropertiesFactory<T>


  • public class ImplFromPropertiesFactory<T>
    extends Object
    An abstract provider that determines which implementation to load based on the value of key in NinjaProperties (aka application.conf). If this variable is set then the implementation class is loaded for subclasses to use in their own implementation of Provider.get().
    • Constructor Detail

      • ImplFromPropertiesFactory

        public ImplFromPropertiesFactory​(com.google.inject.Injector injector,
                                         NinjaProperties ninjaProperties,
                                         String propertyName,
                                         Class<? extends T> targetClass,
                                         String defaultClassName,
                                         boolean deferResolveUntilGet,
                                         org.slf4j.Logger logger)
        Tries to load implementation class defined as a property in NinjaProperties or will fallback to loading the default implementation class or nothing if its not set.
        Parameters:
        injector - The guice injector
        ninjaProperties - The ninja properties
        propertyName - The name of the configuration property key
        targetClass - The target implementation class (e.g. ninja.Cache)
        defaultClassName - The default implementation class or null if a default doesn't exist. A string is used here to not require an implementation class to be on the classpath.
        deferResolveUntilGet - If false then the implementation class will be resolved in the constructor. If true then the resolution will be deferred until getImplementation() or create() is called.
        logger - The logger to use for info and errors
    • Method Detail

      • create

        public T create()
      • getImplementationClass

        public Class<? extends T> getImplementationClass()