org.apache.shiro.util
Class ClassUtils

java.lang.Object
  extended by org.apache.shiro.util.ClassUtils

public class ClassUtils
extends Object

Utility method library used to conveniently interact with Classes, such as acquiring them from the application ClassLoaders and instantiating Objects from them.

Since:
0.1

Constructor Summary
ClassUtils()
           
 
Method Summary
static Class forName(String fqcn)
          Attempts to load the specified class name from the current thread's context class loader, then the current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order.
static Constructor getConstructor(Class clazz, Class... argTypes)
           
static InputStream getResourceAsStream(String name)
          Returns the specified resource by checking the current thread's context class loader, then the current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, using getResourceAsStream(name).
static Object instantiate(Constructor ctor, Object... args)
           
static boolean isAvailable(String fullyQualifiedClassName)
           
static Object newInstance(Class clazz)
           
static Object newInstance(Class clazz, Object... args)
           
static Object newInstance(String fqcn)
           
static Object newInstance(String fqcn, Object... args)
           
 
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

getResourceAsStream

public static InputStream getResourceAsStream(String name)
Returns the specified resource by checking the current thread's context class loader, then the current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order, using getResourceAsStream(name).

Parameters:
name - the name of the resource to acquire from the classloader(s).
Returns:
the InputStream of the resource found, or null if the resource cannot be found from any of the three mentioned ClassLoaders.
Since:
0.9

forName

public static Class forName(String fqcn)
                     throws UnknownClassException
Attempts to load the specified class name from the current thread's context class loader, then the current ClassLoader (ClassUtils.class.getClassLoader()), then the system/application ClassLoader (ClassLoader.getSystemClassLoader(), in that order. If any of them cannot locate the specified class, an UnknownClassException is thrown (our RuntimeException equivalent of the JRE's ClassNotFoundException.

Parameters:
fqcn - the fully qualified class name to load
Returns:
the located class
Throws:
UnknownClassException - if the class cannot be found.

isAvailable

public static boolean isAvailable(String fullyQualifiedClassName)

newInstance

public static Object newInstance(String fqcn)

newInstance

public static Object newInstance(String fqcn,
                                 Object... args)

newInstance

public static Object newInstance(Class clazz)

newInstance

public static Object newInstance(Class clazz,
                                 Object... args)

getConstructor

public static Constructor getConstructor(Class clazz,
                                         Class... argTypes)

instantiate

public static Object instantiate(Constructor ctor,
                                 Object... args)


Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.