public class ClassLoaderUtilities extends Object
| Constructor and Description |
|---|
ClassLoaderUtilities() |
| Modifier and Type | Method and Description |
|---|---|
static List<String> |
allResourceLines(ClassLoader classLoader,
String resourceName)
Find all the resources with the given path, load them, and return their
contents as a list of Strings.
|
static <T> List<Class<? extends T>> |
loadRegisteredImplementations(String resourceName,
Class<T> cls)
Equivalent to
loadRegisteredImplementations(resourceName,
cls, cls.getClassLoader()). |
static <T> List<Class<? extends T>> |
loadRegisteredImplementations(String resourceName,
Class<T> cls,
ClassLoader classLoader)
Simple mechanism for dynamically specified implementations.
|
static List<Class<?>> |
loadRegisteredImplementations(String resourceName,
ClassLoader classLoader)
Equivalent to
loadRegisteredImplementations(resourceName,
Object.class, classLoader). |
public static List<String> allResourceLines(ClassLoader classLoader, String resourceName) throws IOException
Property file style comments can be added using "#".
Lines are processed as follows:
classLoader - Starting class loader to search. The parent class loaders will be
searched first - see ClassLoader.getResources(java.lang.String).resourceName - The name of the resources. Multiple resources may have the same
name if they are loaded from different class loaders.IOException - If there was a problem parsing the resources.public static List<Class<?>> loadRegisteredImplementations(String resourceName, ClassLoader classLoader) throws EngineException
Equivalent to loadRegisteredImplementations(resourceName,
Object.class, classLoader).
resourceName - The name of the resources to find.classLoader - Classloader to use to load implementations.EngineException - If a class could not be loaded.loadRegisteredImplementations(String, Class, ClassLoader)public static <T> List<Class<? extends T>> loadRegisteredImplementations(String resourceName, Class<T> cls) throws EngineException
Equivalent to loadRegisteredImplementations(resourceName,
cls, cls.getClassLoader()).
T - Constrains type of cls.resourceName - The name of the resources to find.cls - Implementation classes must be assignable to this class.EngineException - If a class could not be loaded.loadRegisteredImplementations(String, Class, ClassLoader)public static <T> List<Class<? extends T>> loadRegisteredImplementations(String resourceName, Class<T> cls, ClassLoader classLoader) throws EngineException
The classpath is searched for all resources called resourceName.
Matching resources are then parsed with allResourceLines(java.lang.ClassLoader, java.lang.String) to obtain
a list of implementation class names. These classes are dynamically loaded,
and returned.
T - Constrains type of cls.resourceName - The name of the resources to find.cls - Implementation classes must be assignable to this class.classLoader - Classloader to use to load implementations.EngineException - If a class could not be loaded.Copyright © 2000-2014. All Rights Reserved.