Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.tiles.reflect
Class ClassUtil

    java.lang.Object
      org.apache.tiles.reflect.ClassUtil

    public final class ClassUtil

extends java.lang.Object

Utilities to work with dynamic class loading and instantiation.

Since:
  2.0.7
Version:
  $Rev: 791161 $ $Date: 2009-07-04 20:53:36 +0200 (sab, 04 lug 2009) $

Method Summary
`static void` | `collectBeanInfo(java.lang.Class<?> clazz, java.util.Map<java.lang.String,java.beans.PropertyDescriptor> name2descriptor)` Collects bean infos from a class and filling a list.
`static
`<T> java.lang.Class<? extends T>`
` | `getClass(java.lang.String className, java.lang.Class<T> baseClass)` Returns the class and casts it to the correct subclass.
`static java.lang.reflect.Method` | `getForcedAccessibleMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>... parameterTypes)` Gets a method and forces it to be accessible, even if it is not.
`static java.lang.Object` | `instantiate(java.lang.String className)` Returns an instance of the given class name, by calling the default constructor.
`static java.lang.Object` | `instantiate(java.lang.String className, boolean returnNull)` Returns an instance of the given class name, by calling the default constructor.
`static java.lang.Object` | `invokeMethod(java.lang.Object obj, java.lang.reflect.Method method, java.lang.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

### getClass

    public static <T> java.lang.Class<? extends T> getClass(java.lang.String className,
                                                            java.lang.Class<T> baseClass)
                                                 throws java.lang.ClassNotFoundException

  Returns the class and casts it to the correct subclass.
  It tries to use the thread's current classloader first and, if it does not succeed, uses the classloader of ClassUtil.

  Type Parameters:
    `T` - The subclass to use.
  Parameters:
    `className` - The name of the class to load.
    `baseClass` - The base class to subclass to.
  Returns:
    The loaded class.
  Throws:
    `java.lang.ClassNotFoundException` - If the class has not been found.
  Since:
    2.1.3

### instantiate

    public static java.lang.Object instantiate(java.lang.String className)

  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:
    `CannotInstantiateObjectException` - If something goes wrong during instantiation.
  Since:
    2.0.7

### instantiate

    public static java.lang.Object instantiate(java.lang.String className,
                                               boolean returnNull)

  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:
    `CannotInstantiateObjectException` - If something goes wrong during instantiation.
  Since:
    2.0.7

### getForcedAccessibleMethod

    public static java.lang.reflect.Method getForcedAccessibleMethod(java.lang.Class<?> clazz,
                                                                     java.lang.String methodName,
                                                                     java.lang.Class<?>... parameterTypes)

  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.
  Since:
    2.0.7

### invokeMethod

    public static java.lang.Object invokeMethod(java.lang.Object obj,
                                                java.lang.reflect.Method method,
                                                java.lang.Object... args)

  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".
  Since:
    2.0.7

### collectBeanInfo

    public static void collectBeanInfo(java.lang.Class<?> clazz,
                                       java.util.Map<java.lang.String,java.beans.PropertyDescriptor> name2descriptor)

  Collects bean infos from a class and filling a list.

  Parameters:
    `clazz` - The class to be inspected.
    `name2descriptor` - The map in the form: name of the property -> descriptor.
  Since:
    2.2.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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