Clover coverage report - Cactus 1.4b1 for J2EE API 12
Coverage timestamp: Mon Jul 29 2002 00:33:16 BST
file stats: LOC: 145   Methods: 4
NCLOC: 66   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Configuration.java 0% 0% 0% 0%
 1   
 /*   Generated by AspectJ version 1.0.5 */
 2   
 package org.apache.cactus.util;
 3   
 import org.apache.cactus.client.HttpClientConnectionHelper;
 4   
 import java.io.FileInputStream;
 5   
 import java.io.IOException;
 6   
 import java.util.PropertyResourceBundle;
 7   
 import java.util.ResourceBundle;
 8   
 import java.util.Enumeration;
 9   
 import java.util.MissingResourceException;
 10   
 
 11   
 /** 
 12   
  * Provides access to the Cactus configuration parameters that are independent 
 13   
  * of any redirector. All Cactus configuration are defined as Java System 
 14   
  * Properties. However, a Cactus configuration can also be used, in which case 
 15   
  * all properties defined withint it will be exported as Java System Properties. 
 16   
  * 
 17   
  * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 18   
  * 
 19   
  * @version $Id: Configuration.java,v 1.11 2002/07/28 13:36:55 vmassol Exp $ 
 20   
  */
 21   
 public class Configuration {
 22   
   /** 
 23   
        * Name of the Cactus configuration file if cactus is to look for it in 
 24   
        * the classpath. 
 25   
        */
 26   
   private static final String DEFAULT_CONFIG_NAME = "cactus";
 27   
   /** 
 28   
        * Name of the java property for specifying the location of the cactus 
 29   
        * configuration file. This overrides any cactus configuration file that is 
 30   
        * put in the classpath. 
 31   
        */
 32   
   private static final String CACTUS_CONFIG_PROPERTY = "cactus.config";
 33   
   /** 
 34   
        * Name of Cactus property that specify the URL up to the webapp context. 
 35   
        * This is the base URL to call for the redirectors. It is made up of : 
 36   
        * "http://" + serverName + port + "/" + contextName. 
 37   
        */
 38   
   public static final String CACTUS_CONTEXT_URL_PROPERTY = "cactus.contextURL";
 39   
   /** 
 40   
        * Name of the Cactus property for overriding the default 
 41   
        * {@link org.apache.cactus.client.ConnectionHelper}. Defaults to 
 42   
        * {@link org.apache.cactus.client.HttpClientConnectionHelper} 
 43   
        */
 44   
   private static final String CACTUS_CONNECTION_HELPER_CLASSNAME_PROPERTY = 
 45   
       "cactus.connectionHelper.classname";
 46   
   /** 
 47   
        * Default {@link org.apache.cactus.client.ConnectionHelper} to use. 
 48   
        */
 49   
   public static String DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME;
 50   
   /** 
 51   
        * True if the Cactus configuration file has already been read. 
 52   
        * @see #initialize() 
 53   
        */
 54   
   private static boolean isInitialized;
 55   
   /** 
 56   
        * Read the cactus configuration file from the java property defined 
 57   
        * on the command line (named CACTUS_CONFIG_PROPERTY) and if none has been 
 58   
        * defined tries to read the DEFAULT_CONFIG_NAME file from the classpath. 
 59   
        * All properties found are exported as java system properties. 
 60   
        */
 61  0
   public static final void initialize() {
 62  0
     if (!Configuration.isInitialized) {
 63  0
       ResourceBundle config;
 64  0
       String configOverride = System.getProperty("cactus.config");
 65  0
       if (configOverride == null) {
 66  0
         try {
 67  0
           config = ClassLoaderUtils.loadPropertyResourceBundle("cactus", Configuration.class);
 68   
         } catch (MissingResourceException e) {
 69  0
           return;
 70   
         } 
 71   
       } else {
 72  0
         try {
 73  0
           config = new PropertyResourceBundle(new FileInputStream(configOverride));
 74   
         } catch (IOException e) {
 75  0
           throw new ChainedRuntimeException("Cannot read cactus configuration file [" + 
 76   
               configOverride + "]", e);
 77   
         } 
 78   
       } 
 79  0
       Enumeration keys = config.getKeys();
 80  0
       while (keys.hasMoreElements()){
 81  0
         String key = (String)keys.nextElement();
 82  0
         if (System.getProperty(key) == null) {
 83  0
           System.setProperty(key, config.getString(key));
 84   
         } 
 85   
       } 
 86  0
       Configuration.isInitialized = true;
 87   
     } 
 88   
   } 
 89   
 
 90   
   /** 
 91   
        * @return the context URL under which our application to test runs. 
 92   
        */
 93  0
   public static String getContextURL() {
 94  0
     Configuration.initialize();
 95  0
     String contextURL = System.getProperty("cactus.contextURL");
 96  0
     if (contextURL == null) {
 97  0
       throw new ChainedRuntimeException("Missing Cactus property [cactus.contextURL]");
 98   
     } 
 99  0
     return contextURL;
 100   
   } 
 101   
 
 102   
   /** 
 103   
        * @return the {@link org.apache.cactus.client.ConnectionHelper} classname 
 104   
        *         to use for opening the HTTP connection 
 105   
        */
 106  0
   public static String getConnectionHelper() {
 107  0
     String connectionHelperClassname = System.getProperty("cactus.connectionHelper.classname");
 108  0
     if (connectionHelperClassname == null) {
 109  0
       connectionHelperClassname = Configuration.DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME;
 110   
     } 
 111  0
     return connectionHelperClassname;
 112   
   } 
 113   
 
 114   
   /** 
 115   
    * Provides access to the Cactus configuration parameters that are independent 
 116   
    * of any redirector. All Cactus configuration are defined as Java System 
 117   
    * Properties. However, a Cactus configuration can also be used, in which case 
 118   
    * all properties defined withint it will be exported as Java System Properties. 
 119   
    * 
 120   
    * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 121   
    * 
 122   
    * @version $Id: Configuration.java,v 1.11 2002/07/28 13:36:55 vmassol Exp $ 
 123   
    */
 124  0
   public Configuration() {
 125  0
     super();
 126   
   } 
 127   
   /** 
 128   
    * Provides access to the Cactus configuration parameters that are independent 
 129   
    * of any redirector. All Cactus configuration are defined as Java System 
 130   
    * Properties. However, a Cactus configuration can also be used, in which case 
 131   
    * all properties defined withint it will be exported as Java System Properties. 
 132   
    * 
 133   
    * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a> 
 134   
    * 
 135   
    * @version $Id: Configuration.java,v 1.11 2002/07/28 13:36:55 vmassol Exp $ 
 136   
    */
 137   
   static {
 138   
     /** 
 139   
          * Default {@link org.apache.cactus.client.ConnectionHelper} to use. 
 140   
          */
 141  0
     Configuration.DEFAULT_CACTUS_CONNECTION_HELPER_CLASSNAME = 
 142   
         HttpClientConnectionHelper.class.getName();
 143   
   } 
 144   
 
 145   
 }