com.sun.faces.util
Class ReflectionUtils

java.lang.Object
  extended by com.sun.faces.util.ReflectionUtils

public final class ReflectionUtils
extends java.lang.Object

A set of utility methods to make working with Classes and Reflection a little easier.


Nested Class Summary
static class ReflectionUtils.ReflectionUtilsListener
          A SerlvetContextListener to ensure that the ReflectionUtils cache is intialized and cleanup when the application starts and finishes.
 
Method Summary
static void clearCache(java.lang.ClassLoader loader)
          Clears the cache for the specified ClassLoader.
static void initCache(java.lang.ClassLoader loader)
           
static java.lang.Class<?> lookupClass(java.lang.String className)
          Obtain a Class instance based on the provided String name.
static java.lang.reflect.Constructor lookupConstructor(java.lang.Class<?> clazz, java.lang.Class<?>... params)
          Returns the Constructor appropriate to the specified Class and parameters.
static java.lang.reflect.Method lookupMethod(java.lang.Class<?> clazz, java.lang.String methodName, java.lang.Class<?>... params)
          Returns the Method appropriate to the specified Class, method name, and parameters.
static java.lang.Object newInstance(java.lang.String className)
          Constructs a new object instance based off the provided class name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

clearCache

public static void clearCache(java.lang.ClassLoader loader)

Clears the cache for the specified ClassLoader.

This method MUST be called when ConfigureListener .contextDestroyed() is called.

Parameters:
loader - the ClassLoader whose associated cache should be cleared

initCache

public static void initCache(java.lang.ClassLoader loader)

lookupConstructor

public static java.lang.reflect.Constructor lookupConstructor(java.lang.Class<?> clazz,
                                                              java.lang.Class<?>... params)

Returns the Constructor appropriate to the specified Class and parameters.

Parameters:
clazz - the Class of interest
params - the parameters for the constructor of the provided Class
Returns:
a Constructor that can be invoked with the specified parameters

lookupMethod

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

Returns the Method appropriate to the specified Class, method name, and parameters.

Parameters:
clazz - the Class of interest
methodName - the name of the method
params - the parameters for the specified method
Returns:
a Method that can be invoked with the specified parameters

newInstance

public static java.lang.Object newInstance(java.lang.String className)
                                    throws java.lang.InstantiationException,
                                           java.lang.IllegalAccessException

Constructs a new object instance based off the provided class name.

Parameters:
className - the class of the object to instantiate
Returns:
a new instances of said class
Throws:
java.lang.InstantiationException - if the class cannot be instantiated
java.lang.IllegalAccessException - if there is a security violation

lookupClass

public static java.lang.Class<?> lookupClass(java.lang.String className)

Obtain a Class instance based on the provided String name.

Parameters:
className - the class to look up
Returns:
the Class corresponding to className


Copyright ? 2002-2006 Sun Microsystems, Inc. All Rights Reserved.