Clover coverage report - Cactus 1.4 for J2EE API 13
Coverage timestamp: Sun Aug 25 2002 18:02:10 BST
file stats: LOC: 98   Methods: 5
NCLOC: 38   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ClassLoaderUtils.java - 30.8% 20% 27.8%
 1   
 /*   Generated by AspectJ version 1.0.5 */
 2   
 package org.apache.cactus.util;
 3   
 import java.util.ResourceBundle;
 4   
 import java.util.PropertyResourceBundle;
 5   
 import java.util.MissingResourceException;
 6   
 import java.util.Locale;
 7   
 
 8   
 /** 
 9   
  * Utiliy methods related to class loading in a webapp environment. 
 10   
  * 
 11   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 12   
  * 
 13   
  * @version $Id: ClassLoaderUtils.java,v 1.2 2002/05/12 19:41:14 vmassol Exp $ 
 14   
  */
 15   
 public class ClassLoaderUtils {
 16   
   /** 
 17   
        * Try loading a class first by using the context class loader or by using 
 18   
        * the classloader of the referrer class if the context classloader failed 
 19   
        * to load the class. 
 20   
        * 
 21   
        * @param theClassName the name of the test class 
 22   
        * @param theReferrer the class will be loaded using the classloader which 
 23   
        *        has loaded this referrer class 
 24   
        * @return the class object the test class to call 
 25   
        * @exception ClassNotFoundException if the class cannot be loaded through 
 26   
        *            either classloader 
 27   
        */
 28  0
   public static Class loadClass(String theClassName, 
 29   
       Class theReferrer) throws ClassNotFoundException {
 30  0
     Class clazz = null;
 31  0
     try {
 32  0
       clazz = ClassLoaderUtils.loadClassFromWebappClassLoader(theClassName, theReferrer);
 33   
     } catch (Exception internalException) {
 34  0
       clazz = ClassLoaderUtils.loadClassFromContextClassLoader(theClassName);
 35   
     } 
 36  0
     return clazz;
 37   
   } 
 38   
 
 39   
   /** 
 40   
        * Try loading class using the Context class loader. 
 41   
        * 
 42   
        * @param theClassName the class to load 
 43   
        * @return the <code>Class</code> object for the class to load 
 44   
        * @exception ClassNotFoundException if the class cannot be loaded through 
 45   
        *            this class loader 
 46   
        */
 47  0
   public static Class loadClassFromContextClassLoader(String theClassName) throws 
 48   
       ClassNotFoundException {
 49  0
     return Class.forName(theClassName, true, Thread.currentThread().getContextClassLoader());
 50   
   } 
 51   
 
 52   
   /** 
 53   
        * Try loading class using the Webapp class loader. 
 54   
        * 
 55   
        * @param theClassName the class to load 
 56   
        * @param theReferrer the class will be loaded using the classloader which 
 57   
        *        has loaded this referrer class 
 58   
        * @return the <code>Class</code> object for the class to load 
 59   
        * @exception ClassNotFoundException if the class cannot be loaded through 
 60   
        *            this class loader 
 61   
        */
 62  0
   public static Class loadClassFromWebappClassLoader(String theClassName, 
 63   
       Class theReferrer) throws ClassNotFoundException {
 64  0
     return Class.forName(theClassName, true, theReferrer.getClassLoader());
 65   
   } 
 66   
 
 67   
   /** 
 68   
        * Try loading a resource bundle from either the context class loader or 
 69   
        * the 
 70   
        * 
 71   
        * @param theName the resource bundle name 
 72   
        * @param theReferrer the resource bundle will be loaded using the 
 73   
        *        classloader which has loaded this referrer class 
 74   
        * @return the loaded resource bundle 
 75   
        */
 76  2
   public static ResourceBundle loadPropertyResourceBundle(String theName, Class theReferrer) {
 77  2
     ResourceBundle bundle;
 78  2
     try {
 79  2
       bundle = PropertyResourceBundle.getBundle(theName, Locale.getDefault(), 
 80   
           theReferrer.getClassLoader());
 81   
     } catch (MissingResourceException e) {
 82  0
       bundle = PropertyResourceBundle.getBundle(theName, Locale.getDefault(), 
 83   
           Thread.currentThread().getContextClassLoader());
 84   
     } 
 85  2
     return bundle;
 86   
   } 
 87   
 
 88   
   /** 
 89   
    * Utiliy methods related to class loading in a webapp environment. 
 90   
    * 
 91   
    * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 92   
    * 
 93   
    * @version $Id: ClassLoaderUtils.java,v 1.2 2002/05/12 19:41:14 vmassol Exp $ 
 94   
    */
 95  0
   public ClassLoaderUtils() {
 96  0
     super();
 97   
   } 
 98   
 }