|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.myfaces.extensions.cdi.core.api.util.ClassUtils
@Typed public abstract class ClassUtils
Util methods for classes, ClassLoader
and Manifest
handling
Method Summary | ||
---|---|---|
static ClassLoader |
getClassLoader(Object o)
Detect the right ClassLoader. |
|
static String |
getJarVersion(Class targetClass)
Reads the version of the jar which contains the given class |
|
static String |
getRevision(Class targetClass)
Reads the VCS revision which was used for creating the jar |
|
static Object |
instantiateClassForName(String className)
Creates an instance for the given class-name |
|
static Class |
loadClassForName(String name)
Loads class for the given name |
|
static
|
tryToInstantiateClass(Class<T> targetClass)
Instantiates a given class via the default constructor |
|
static Object |
tryToInstantiateClassForName(String className)
Tries to instantiate a class for the given name via the default constructor |
|
static
|
tryToInstantiateClassForName(String className,
Class<T> targetType)
Tries to instantiate a class for the given name and type via the default constructor |
|
static Class |
tryToLoadClassForName(String name)
Tries to load a class based on the given name |
|
static
|
tryToLoadClassForName(String name,
Class<T> targetType)
Tries to load a class based on the given name and interface or abstract class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static ClassLoader getClassLoader(Object o)
o
- if not null
it may get used to detect the classloader.
ClassLoader
which should get used to create new instancespublic static <T> Class<T> tryToLoadClassForName(String name, Class<T> targetType)
T
- current typename
- name of the concrete classtargetType
- target type (interface or abstract class)
public static Class tryToLoadClassForName(String name)
name
- name of the class
public static Class loadClassForName(String name) throws ClassNotFoundException
name
- name of the class
ClassNotFoundException
- if the class can't be loadedpublic static <T> T tryToInstantiateClass(Class<T> targetClass)
T
- current typetargetClass
- class which should be instantiated
public static <T> T tryToInstantiateClassForName(String className, Class<T> targetType)
T
- current typeclassName
- name of the classtargetType
- target type
public static Object tryToInstantiateClassForName(String className)
className
- name of the class
public static Object instantiateClassForName(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException
className
- name of the class which should be instantiated
ClassNotFoundException
- if the instantiation failed
IllegalAccessException
- if the instantiation failed
InstantiationException
- if the instantiation failedpublic static String getJarVersion(Class targetClass)
targetClass
- class within the jar
public static String getRevision(Class targetClass)
targetClass
- class within the jar
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |