org.apache.env

Class WhichClass

public abstract class WhichClass extends Object

Class finding service.

This effectively replaces all Class.forName() calls in this package. Similar to code in javax.xml.*.FactoryFinder. Options included for future use; they could specify something like LOCAL_CLASSLOADER_ONLY for servlet environments, etc.

This class detects JDKs 1.1.x versus 1.2+ and may attempt to either use the current classLoader or may use a contextClassLoader. Note that in some servlet environments or in IDE environments like Eclipse that the difference between classloaders is very important! Changes in the JAXP FactoryFinder classes should be actively evaluated for inclusion/copying here.

Version: $Id: WhichClass.java 226032 2003-01-10 21:29:08Z curcuru $

Author: shane_curcuru@us.ibm.com

Method Summary
static ClassfindClass(String className, String options)
Worker method to load a class.
protected static ClassLoaderfindClassLoader(String options)
Worker method to figure out which ClassLoader to use.

Method Detail

findClass

public static Class findClass(String className, String options)
Worker method to load a class. Factor out loading classes for future use and JDK differences. Similar to javax.xml.*.FactoryFinder

Parameters: className name of class to load from an appropriate classLoader options currently unused

Returns: the class asked for

Throws: ClassNotFoundException

findClassLoader

protected static ClassLoader findClassLoader(String options)
Worker method to figure out which ClassLoader to use. For JDK 1.2 and later use the context ClassLoader. Similar to javax.xml.*.FactoryFinder

Parameters: options currently unused

Returns: the appropriate ClassLoader

Throws: ClassNotFoundException

Copyright B) 2001 Apache Software Foundation. All Rights Reserved.