public class ClassUtils extends Object
Class
types.Constructor and Description |
---|
ClassUtils() |
Modifier and Type | Method and Description |
---|---|
static Method |
findPublicStaticMethod(Class<?> clazz,
Class<?> returnType,
String methodName,
Class<?>[] paramTypes)
Looks for
public static returnType methodName(paramTypes) . |
static String |
getPackageName(Class<?> clazz)
Get package name.
|
static <T> T |
newInstance(Class<T> impl,
Class<?>[] paramClasses,
Object[] params)
Creates a new instance of the input class using the following policy:
if
paramClasses or params is null,
the default constructor will be used;
the public constructor with paramClasses arguments type,
with params as arguments value, will be used.
|
static void |
setLog(org.apache.commons.logging.Log _log)
Deprecated.
This method is not thread-safe
|
static void |
verifyAncestory(Class<?> spi,
Class<?> impl)
Throws exception if
impl does not
implement or extend the SPI. |
@Deprecated public static void setLog(org.apache.commons.logging.Log _log)
Log
for this class._log
- This class Log
public static String getPackageName(Class<?> clazz)
clazz
- The class from which the package has to be extractedpublic static Method findPublicStaticMethod(Class<?> clazz, Class<?> returnType, String methodName, Class<?>[] paramTypes)
public static returnType methodName(paramTypes)
.clazz
- The class where looking for the methodreturnType
- The method return typemethodName
- The method nameparamTypes
- The method arguments typespublic static returnType methodName(paramTypes)
,
if found to be directly implemented by clazz.public static <T> T newInstance(Class<T> impl, Class<?>[] paramClasses, Object[] params) throws DiscoveryException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException
paramClasses
or params
is null,
the default constructor will be used;paramClasses
arguments type,
with params
as arguments value, will be used.T
- The class type has to be instantiatedimpl
- The class has to be instantiatedparamClasses
- The constructor arguments types (can be null
)params
- The constructor arguments values (can be null
)DiscoveryException
- if the class implementing
the SPI cannot be found, cannot be loaded and
instantiated, or if the resulting class does not implement
(or extend) the SPIInstantiationException
- see Class.newInstance()
IllegalAccessException
- see Class.newInstance()
NoSuchMethodException
- see Class.newInstance()
InvocationTargetException
- see Class.newInstance()
public static void verifyAncestory(Class<?> spi, Class<?> impl) throws DiscoveryException
impl
does not
implement or extend the SPI.spi
- The SPI typeimpl
- The class has to be verified is a SPI implementation/extensionDiscoveryException
- if the input implementation class is not an SPI implementationCopyright © 2002-2012 Apache Software Foundation. All Rights Reserved.