public class ClassUtils
extends org.apache.commons.lang3.ClassUtils
ClassUtils contains useful methods for loading resources and classes
This is based on the mule core class so we can have control over it| Constructor and Description |
|---|
ClassUtils() |
| Modifier and Type | Method and Description |
|---|---|
static URL |
getResource(String resourceName,
Class<?> callingClass)
Load a given resource.
|
static Enumeration<URL> |
getResources(String resourceName,
ClassLoader fallbackClassLoader)
Find resources with a given name.
|
static Object |
instantiateClass(String name,
Object[] constructorArgs,
Class<?> callingClass)
Instantiates a class with a given name and arguments
|
static boolean |
isClassOnPath(String className,
Class currentClass)
Can be used by service endpoints to select which service to use based on what's loaded on the classpath
|
static Class |
loadClass(String className,
Class<?> callingClass)
Load a class with a given name.
|
static <T extends Class> |
loadClass(String className,
Class<?> callingClass,
T type)
Load a class with a given name.
|
convertClassesToClassNames, convertClassNamesToClasses, getAbbreviatedName, getAbbreviatedName, getAllInterfaces, getAllSuperclasses, getClass, getClass, getClass, getClass, getPackageCanonicalName, getPackageCanonicalName, getPackageCanonicalName, getPackageName, getPackageName, getPackageName, getPublicMethod, getShortCanonicalName, getShortCanonicalName, getShortCanonicalName, getShortClassName, getShortClassName, getShortClassName, getSimpleName, getSimpleName, hierarchy, hierarchy, isAssignable, isAssignable, isAssignable, isAssignable, isInnerClass, isPrimitiveOrWrapper, isPrimitiveWrapper, primitivesToWrappers, primitiveToWrapper, toClass, wrappersToPrimitives, wrapperToPrimitivepublic static final Object[] NO_ARGS
public static URL getResource(String resourceName, Class<?> callingClass)
resourceName - The name of the resource to loadcallingClass - The Class object of the calling objectpublic static Enumeration<URL> getResources(String resourceName, ClassLoader fallbackClassLoader)
ClassUtilss class classLoaderresourceName - resource being searched. Non empty.fallbackClassLoader - classloader used to fallback the search. Non null.Enumeration containing the found resources. Can be empty.public static boolean isClassOnPath(String className, Class currentClass)
className - The class name to look forcurrentClass - the calling classpublic static Class loadClass(String className, Class<?> callingClass) throws ClassNotFoundException
Thread.currentThread().getContextClassLoader()
Class.forName(java.lang.String)
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
className - The name of the class to loadcallingClass - The Class object of the calling objectClassNotFoundException - If the class cannot be found anywhere.public static <T extends Class> T loadClass(String className, Class<?> callingClass, T type) throws ClassNotFoundException
Thread.currentThread().getContextClassLoader()
Class.forName(java.lang.String)
ClassLoaderUtil.class.getClassLoader()
callingClass.getClassLoader()
className - The name of the class to loadcallingClass - The Class object of the calling objecttype - the class type to expect to loadClassNotFoundException - If the class cannot be found anywhere.public static Object instantiateClass(String name, Object[] constructorArgs, Class<?> callingClass) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException
name - The name of the class to loadcallingClass - The Class object of the calling objectconstructorArgs - The arguments for the class constructorClassNotFoundException - If the class cannot be found anywhere.SecurityExceptionNoSuchMethodExceptionIllegalArgumentExceptionInstantiationExceptionIllegalAccessExceptionInvocationTargetExceptionCopyright © 2018. All rights reserved.