Package ninja.utils
Class ImplFromPropertiesFactory<T>
- java.lang.Object
-
- ninja.utils.ImplFromPropertiesFactory<T>
-
public class ImplFromPropertiesFactory<T> extends Object
An abstract provider that determines which implementation to load based on the value of key inNinjaProperties
(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 Summary
Constructors Constructor Description 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.
-
-
-
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 injectorninjaProperties
- The ninja propertiespropertyName
- The name of the configuration property keytargetClass
- 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
-
-