Package org.hibernate.search.util
Class ClassLoaderHelper
java.lang.Object
org.hibernate.search.util.ClassLoaderHelper
Utility class to load instances of other classes by using a fully qualified name,
or from a class type.
Uses reflection and throws SearchException(s) with proper descriptions of the error,
like the target class is missing a proper constructor, is an interface, is not found...
-
Method Summary
Modifier and TypeMethodDescriptionstatic AnalyzeranalyzerInstanceFromClass(Class<?> classToInstantiate, Version luceneMatchVersion) static Enumeration<URL> getResources(String resourceName, Class<?> caller) static <T> TinstanceFromClass(Class<T> targetSuperType, Class<?> classToLoad, String componentDescription) Creates an instance of target classstatic <T> TinstanceFromName(Class<T> targetSuperType, String classNameToLoad, Class<?> caller, String componentDescription) Creates an instance of a target class designed by fully qualified name
-
Method Details
-
getResources
-
instanceFromName
public static <T> T instanceFromName(Class<T> targetSuperType, String classNameToLoad, Class<?> caller, String componentDescription) Creates an instance of a target class designed by fully qualified name- Type Parameters:
T- matches the type of targetSuperType: defines the return type- Parameters:
targetSuperType- the return type of the function, the classNameToLoad will be checked to be assignable to this type.classNameToLoad- a fully qualified class name, whose type is assignable to targetSuperTypecaller- the class of the caller, needed for classloading purposescomponentDescription- a meaningful description of the role the instance will have, used to enrich error messages to describe the context of the error- Returns:
- a new instance of classNameToLoad
- Throws:
SearchException- wrapping other error types with a proper error message for all kind of problems, like classNotFound, missing proper constructor, wrong type, security errors.
-
instanceFromClass
public static <T> T instanceFromClass(Class<T> targetSuperType, Class<?> classToLoad, String componentDescription) Creates an instance of target class- Type Parameters:
T- the type of targetSuperType: defines the return type- Parameters:
targetSuperType- the created instance will be checked to be assignable to this typeclassToLoad- the class to be instantiatedcomponentDescription- a role name/description to contextualize error messages- Returns:
- a new instance of classToLoad
- Throws:
SearchException- wrapping other error types with a proper error message for all kind of problems, like missing proper constructor, wrong type, security errors.
-
analyzerInstanceFromClass
-