This project has retired. For details please refer to its Attic page.
ClassUtil (Tiles 2 2.0.7 API)

org.apache.tiles.reflect
Class ClassUtil

Package class diagram package ClassUtil
java.lang.Object
  extended by org.apache.tiles.reflect.ClassUtil

public final class ClassUtil
extends Object

Utilities to work with dynamic class loading and instantiation.

Since:
2.0.7
Version:
$Rev: 637434 $ $Date: 2008-03-15 16:48:38 +0100 (sab, 15 mar 2008) $

Method Summary
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

instantiate

public static Object instantiate(String className)
                          throws TilesException
Returns an instance of the given class name, by calling the default constructor.

Parameters:
className - The class name to load and to instantiate.
Returns:
The new instance of the class name.
Throws:
TilesException - If something goes wrong during instantiation.
Since:
2.0.7

instantiate

public static Object instantiate(String className,
                                 boolean returnNull)
                          throws TilesException
Returns an instance of the given class name, by calling the default constructor.

Parameters:
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.
Returns:
The new instance of the class name.
Throws:
TilesException - If something goes wrong during instantiation.
Since:
2.0.7

getForcedAccessibleMethod

public static Method getForcedAccessibleMethod(Class<?> clazz,
                                               String methodName,
                                               Class<?>... parameterTypes)
                                        throws TilesException
Gets a method and forces it to be accessible, even if it is not.

Parameters:
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.
Returns:
The method, if it is found.
Throws:
TilesException - If something goes when getting the method.
Since:
2.0.7

invokeMethod

public static Object invokeMethod(Object obj,
                                  Method method,
                                  Object... args)
                           throws TilesException
Invokes a method, masking with a runtime exception all the exceptions.

Parameters:
obj - The object from which a method will be called.
method - The method to call.
args - The arguments of the method.
Returns:
The object returned, if the method is not "void".
Throws:
TilesException - If something goes when invoking the method.
Since:
2.0.7


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.