KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > internal > configuration > BaseConfiguration


1 /*
2  * ========================================================================
3  *
4  * Copyright 2001-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * ========================================================================
19  */

20 package org.apache.cactus.internal.configuration;
21
22 import org.apache.cactus.util.ChainedRuntimeException;
23
24 /**
25  * Provides access to the Cactus configuration parameters that are independent
26  * of any redirector. All Cactus configuration are defined as Java System
27  * Properties.
28  *
29  * @version $Id: BaseConfiguration.java,v 1.1 2004/05/22 11:34:46 vmassol Exp $
30  */

31 public class BaseConfiguration implements Configuration
32 {
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 JavaDoc CACTUS_CONTEXT_URL_PROPERTY =
39         "cactus.contextURL";
40
41     /**
42      * Name of the Cactus property for defining an initializer (i.e. a class
43      * that is executed before the Cactus tests start on the client side).
44      */

45     private static final String JavaDoc CACTUS_INITIALIZER_PROPERTY =
46         "cactus.initializer";
47
48     /**
49      * @return the context URL under which our application to test runs.
50      */

51     public String JavaDoc getContextURL()
52     {
53         // Try to read it from a System property first and then if it fails
54
// from the Cactus configuration file.
55
String JavaDoc contextURL = System.getProperty(CACTUS_CONTEXT_URL_PROPERTY);
56
57         if (contextURL == null)
58         {
59             throw new ChainedRuntimeException("Missing Cactus property ["
60                 + CACTUS_CONTEXT_URL_PROPERTY + "]");
61         }
62
63         return contextURL;
64     }
65
66     /**
67      * @return the initializer class (i.e. a class that is executed before the
68      * Cactus tests start on the client side) or null if none has been
69      * defined
70      */

71     public String JavaDoc getInitializer()
72     {
73         return System.getProperty(CACTUS_INITIALIZER_PROPERTY);
74     }
75 }
76
Popular Tags