org.apache.cocoon.util
Class ClassUtils

java.lang.Object
  extended byorg.apache.cocoon.util.ClassUtils

public class ClassUtils
extends Object

A collection of class management utility methods.

Version:
$Id: ClassUtils.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Constructor Summary
ClassUtils()
           
 
Method Summary
static ClassLoader getClassLoader()
          Return the context classloader.
static URL getResource(String resource)
          Return a resource URL.
static Class loadClass(String className)
          Load a class given its name.
static Object newInstance(String className)
          Create a new instance given a class name
 
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

newInstance

public static Object newInstance(String className)
                          throws Exception
Create a new instance given a class name

Parameters:
className - A class name
Returns:
A new instance
Throws:
Exception - If an instantiation error occurs

loadClass

public static Class loadClass(String className)
                       throws ClassNotFoundException
Load a class given its name. BL: We wan't to use a known ClassLoader--hopefully the heirarchy is set correctly.

Parameters:
className - A class name
Returns:
The class pointed to by className
Throws:
ClassNotFoundException - If a loading error occurs

getResource

public static URL getResource(String resource)
                       throws MalformedURLException
Return a resource URL. BL: if this is command line operation, the classloading issues are more sane. During servlet execution, we explicitly set the ClassLoader.

Returns:
The context classloader.
Throws:
MalformedURLException - If a loading error occurs

getClassLoader

public static ClassLoader getClassLoader()
Return the context classloader. BL: if this is command line operation, the classloading issues are more sane. During servlet execution, we explicitly set the ClassLoader.

Returns:
The context classloader.


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.