java.lang.Object
provided.utils.loader.impl.ObjectLoaderPath<ReturnT>
- Type Parameters:
ReturnT
- The type of object loaded by this IObjectLoader
- All Implemented Interfaces:
IObjectLoader<ReturnT>
An IObjectLoader implementation that will walk through multiple locations, defined by multiple classname prefixes, to load an object of
the specified type.
- Author:
- swong
-
Field Summary
FieldsModifier and TypeFieldDescriptionList of of the given classname prefixes, which is effectively a path listThe error factory to use in case the class is never foundprivate ILogger
Logger to use -
Constructor Summary
ConstructorsConstructorDescriptionObjectLoaderPath(Function<Object[],ReturnT> errorFac, String... classnamePrefixes)
Constructor for the class. -
Method Summary
Modifier and TypeMethodDescription(package private) ReturnT
exceptionHandler(Exception ex, String fullClassName, Object... params)
Handler for exceptions or running out of places to search.loadInstance(String className, Object... args)
Instantiates and then delegates to a recursive IObjectLoader instance that goes through the saved list of classname prefixes searching for the partial name, className.
-
Field Details
-
logger
Logger to use -
classnamePrefixes
List of of the given classname prefixes, which is effectively a path list -
errorFac
The error factory to use in case the class is never found
-
-
Constructor Details
-
ObjectLoaderPath
Constructor for the class. The given errorFac is used to generate instances when the loadInstance() method is otherwise unable to do so because of a processing error.- Parameters:
errorFac
- A factory method that takes the same array of input parameters that loadInstance() takes and returns an instance of ReturnT.classnamePrefixes
- Vararg of the prefixes to search for the given classnames. The prefixes should complete the fully qualified pathname when pre=pended to the className given to loadInstance(). The prefixes are searched in the order given.
-
-
Method Details
-
exceptionHandler
Handler for exceptions or running out of places to search.- Parameters:
ex
- The Exception to be handledfullClassName
- The fully qualified class name being searched forparams
- Intended class constructor parameters- Returns:
- The error object generated by the stored errorFac.
-
loadInstance
Instantiates and then delegates to a recursive IObjectLoader instance that goes through the saved list of classname prefixes searching for the partial name, className. If the class is never found, the exception printed and the saved errorFac will be invoked to generate an error object result.- Specified by:
loadInstance
in interfaceIObjectLoader<ReturnT>
- Parameters:
className
- The fully-qualified name of the desired class which must be assignable to the ReturnT type.args
- a varargs of input parameter values for the constructor of className- Returns:
- An instance of the desired class, as ReturnT
-