org.apache.commons.discovery.tools

Class ClassUtils


public class ClassUtils
extends java.lang.Object

Author:
Richard A. Sitze

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, paramClasses[] , params[] )
Instantiate a new
static void
setLog(Log _log)
static void
verifyAncestory(Class spi, Class impl)
Throws exception if impl does not implement or extend the SPI.

Method Details

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.

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.

newInstance

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

setLog

public static void setLog(Log _log)

verifyAncestory

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

Copyright (c) 2002 - Apache Software Foundation