|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tiles.reflect.ClassUtil
public final class ClassUtil
Utilities to work with dynamic class loading and instantiation.
Method Summary | ||
---|---|---|
static
|
getClass(String className,
Class<T> baseClass)
Returns the class and casts it to the correct subclass. |
|
static Method |
getForcedAccessibleMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
Gets a method and forces it to be accessible, even if it is not. |
|
static Object |
instantiate(String className)
Returns an instance of the given class name, by calling the default constructor. |
|
static Object |
instantiate(String className,
boolean returnNull)
Returns an instance of the given class name, by calling the default constructor. |
|
static Object |
invokeMethod(Object obj,
Method method,
Object... args)
Invokes a method, masking with a runtime exception all the exceptions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> Class<? extends T> getClass(String className, Class<T> baseClass) throws ClassNotFoundException
T
- The subclass to use.className
- The name of the class to load.baseClass
- The base class to subclass to.
ClassNotFoundException
- If the class has not been found.public static Object instantiate(String className)
className
- The class name to load and to instantiate.
CannotInstantiateObjectException
- If something goes wrong during
instantiation.public static Object instantiate(String className, boolean returnNull)
className
- The class name to load and to instantiate.returnNull
- If true
, if the class is not found it
returns true
, otherwise it throws a
TilesException
.
CannotInstantiateObjectException
- If something goes wrong during instantiation.public static Method getForcedAccessibleMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
clazz
- The class from which the method will be got.methodName
- The name of the method.parameterTypes
- The parameter types that the method must match.
public static Object invokeMethod(Object obj, Method method, Object... args)
obj
- The object from which a method will be called.method
- The method to call.args
- The arguments of the method.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |