org.apache.env
Class WhichClass

java.lang.Object
  |
  +--org.apache.env.WhichClass

public abstract class WhichClass
extends java.lang.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.html,v 1.4 2003/12/30 03:55:19 crossley Exp $
Author:
shane_curcuru@us.ibm.com

Constructor Summary
WhichClass()
           
 
Method Summary
static java.lang.Class findClass(java.lang.String className, java.lang.String options)
          Worker method to load a class.
protected static java.lang.ClassLoader findClassLoader(java.lang.String options)
          Worker method to figure out which ClassLoader to use.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WhichClass

public WhichClass()
Method Detail

findClass

public static java.lang.Class findClass(java.lang.String className,
                                        java.lang.String options)
                                 throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException

findClassLoader

protected static java.lang.ClassLoader findClassLoader(java.lang.String options)
                                                throws java.lang.ClassNotFoundException
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:
java.lang.ClassNotFoundException


Copyright © 2001 Apache Software Foundation. All Rights Reserved.