org.apache.commons.discovery.tools
Class ClassUtils

java.lang.Object
  extended by org.apache.commons.discovery.tools.ClassUtils

public class ClassUtils
extends Object

Author:
Richard A. Sitze

Constructor Summary
ClassUtils()
           
 
Method Summary
static Method findPublicStaticMethod(Class clazz, Class returnType, String methodName, Class[] paramTypes)
           
static String getPackageName(Class clazz)
          Get package name.
static Object newInstance(Class impl, Class[] paramClasses, Object[] params)
          Instantiate a new
static void setLog(org.apache.commons.logging.Log _log)
           
static void verifyAncestory(Class spi, Class impl)
          Throws exception if impl does not implement or extend the SPI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassUtils

public ClassUtils()
Method Detail

setLog

public static void setLog(org.apache.commons.logging.Log _log)

getPackageName

public static String getPackageName(Class clazz)
Get package name. Not all class loaders 'keep' package information, in which case Class.getPackage() returns null. This means that calling Class.getPackage().getName() is unreliable at best.


findPublicStaticMethod

public static Method findPublicStaticMethod(Class clazz,
                                            Class returnType,
                                            String methodName,
                                            Class[] paramTypes)
Returns:
Method 'public static returnType methodName(paramTypes)', if found to be directly implemented by clazz.

newInstance

public static Object newInstance(Class impl,
                                 Class[] paramClasses,
                                 Object[] params)
                          throws DiscoveryException,
                                 InstantiationException,
                                 IllegalAccessException,
                                 NoSuchMethodException,
                                 InvocationTargetException
Instantiate a new

Throws:
DiscoveryException
InstantiationException
IllegalAccessException
NoSuchMethodException
InvocationTargetException

verifyAncestory

public static void verifyAncestory(Class spi,
                                   Class impl)
                            throws DiscoveryException
Throws exception if impl does not implement or extend the SPI.

Throws:
DiscoveryException


Copyright © 2002-2009 Apache Software Foundation. All Rights Reserved.