public class ClassLoaderHelper extends Object
Modifier and Type | Method and Description |
---|---|
static Analyzer |
analyzerInstanceFromClass(Class<?> classToInstantiate,
Version luceneMatchVersion) |
static <T> Class<? extends T> |
classForName(Class<T> targetSuperType,
String classNameToLoad,
String componentDescription,
ServiceManager serviceManager) |
static Class |
classForName(String classNameToLoad,
ServiceManager serviceManager)
Perform resolution of a class name.
|
static Class<?> |
classForName(String classNameToLoad,
String componentDescription,
ServiceManager serviceManager) |
static <T> T |
instanceFromClass(Class<T> targetSuperType,
Class<?> classToLoad,
String componentDescription)
Creates an instance of target class
|
static <T> T |
instanceFromClass(Class<T> targetSuperType,
Class<?> classToLoad,
String componentDescription,
Map<String,String> constructorParameter)
Creates an instance of target class having a Map of strings as constructor parameter.
|
static <T> T |
instanceFromName(Class<T> targetSuperType,
String classNameToLoad,
String componentDescription,
ServiceManager serviceManager)
Creates an instance of a target class specified by the fully qualified class name using a
ClassLoader
as fallback when the class cannot be found in the context one. |
public static <T> T instanceFromName(Class<T> targetSuperType, String classNameToLoad, String componentDescription, ServiceManager serviceManager)
ClassLoader
as fallback when the class cannot be found in the context one.T
- matches the type of targetSuperType: defines the return typetargetSuperType
- 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 targetSuperTypecomponentDescription
- a meaningful description of the role the instance will have,
used to enrich error messages to describe the context of the errorserviceManager
- Service manager allowing access to the class loading serviceclassNameToLoad
SearchException
- wrapping other error types with a proper error message for all kind of problems, like
classNotFound, missing proper constructor, wrong type, security errors.public static <T> T instanceFromClass(Class<T> targetSuperType, Class<?> classToLoad, String componentDescription)
T
- the type of targetSuperType: defines the return typetargetSuperType
- the created instance will be checked to be assignable to this typeclassToLoad
- the class to be instantiatedcomponentDescription
- a role name/description to contextualize error messagesSearchException
- wrapping other error types with a proper error message for all kind of problems, like
missing proper constructor, wrong type, security errors.public static <T> T instanceFromClass(Class<T> targetSuperType, Class<?> classToLoad, String componentDescription, Map<String,String> constructorParameter)
T
- the type of targetSuperType: defines the return typetargetSuperType
- the created instance will be checked to be assignable to this typeclassToLoad
- the class to be instantiatedcomponentDescription
- a role name/description to contextualize error messagesconstructorParameter
- a Map to be passed to the constructor. The loaded type must have such a constructor.SearchException
- wrapping other error types with a proper error message for all kind of problems, like
missing proper constructor, wrong type, security errors.public static Analyzer analyzerInstanceFromClass(Class<?> classToInstantiate, Version luceneMatchVersion)
public static Class<?> classForName(String classNameToLoad, String componentDescription, ServiceManager serviceManager)
public static <T> Class<? extends T> classForName(Class<T> targetSuperType, String classNameToLoad, String componentDescription, ServiceManager serviceManager)
public static Class classForName(String classNameToLoad, ServiceManager serviceManager)
Here we first check the context classloader, if one, before delegating to
Class.forName(String, boolean, ClassLoader)
using the caller's classloader
classNameToLoad
- The class nameserviceManager
- The service manager from which to retrieve the class loader serviceClassLoadingException
- From Class.forName(String, boolean, ClassLoader)
.Copyright © 2006-2017 Red Hat, Inc. All Rights Reserved