KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > core > misc > ConfigExpresso


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.core.misc;
66
67 import java.util.HashMap JavaDoc;
68 import java.util.Vector JavaDoc;
69
70
71 /**
72  * Class that maps to the &lt;expresso-config&gt; top level section in the
73  * expresso-config.xml file.
74  */

75 public class ConfigExpresso {
76     /**
77      * Location of log directory
78      */

79     private String JavaDoc logDirectory = "%web-app%WEB-INF/log";
80
81     /**
82      * Use Strong crypto? Default is no
83      */

84     private String JavaDoc strongCrypto = "n";
85
86     /**
87      * Servlet API version
88      */

89     private String JavaDoc servletAPI = "2_3";
90
91     /**
92      * All the contexts
93      */

94     private Vector JavaDoc contexts = new Vector JavaDoc();
95
96     /**
97      * Cache Manager paramters
98      */

99     private ConfigCacheManager myCache = null;
100
101     /**
102      * Private cryptographic key for how we encrypt the cookies and other gizmos
103      */

104     private String JavaDoc cryptoKey = null;
105
106     /**
107      * What encryption mode do we use?
108      */

109     private String JavaDoc encryptMode = null;
110
111     /**
112      * A list of all the classHandlers available to the system.
113      */

114     private static HashMap JavaDoc classHandlers = new HashMap JavaDoc();
115
116     /**
117      * What is our normal http port? Used for redirecting between SSL and
118      * non-ssl pages
119      */

120     private String JavaDoc httpPort = "80";
121
122     /**
123      * What is our SSL port? Used for redirecting between SSL and non-ssl pages
124      */

125     private String JavaDoc sslPort = "443";
126
127     public ConfigExpresso() {
128     }
129
130     public void setCryptoKey(String JavaDoc newKey) {
131         cryptoKey = newKey;
132     }
133
134     public void setEncryptMode(String JavaDoc newMode) {
135         encryptMode = newMode;
136     }
137
138     public void setHttpPort(String JavaDoc newValue) {
139         httpPort = newValue;
140     }
141
142     public void setSslPort(String JavaDoc newValue) {
143         sslPort = newValue;
144     }
145
146     public String JavaDoc getEncryptMode() {
147         return encryptMode;
148     }
149
150     public String JavaDoc getCryptoKey() {
151         return cryptoKey;
152     }
153
154     public String JavaDoc getHttpPort() {
155         return httpPort;
156     }
157
158     public String JavaDoc getSslPort() {
159         return sslPort;
160     }
161
162     public void addCacheManager(ConfigCacheManager newCache) {
163         myCache = newCache;
164     }
165
166     public static void addClassHandler(ConfigClassHandler cch) {
167         classHandlers.put(cch.getName(), cch);
168     }
169
170     public ConfigCacheManager getCacheManager() {
171         return myCache;
172     }
173
174     public Vector JavaDoc getContexts() {
175         return contexts;
176     }
177
178     // public String getUserInfo() {
179
// return userInfo;
180
// }
181
public HashMap JavaDoc getClassHandlers() {
182         return classHandlers;
183     }
184
185     public void addContext(ConfigContext newContext) {
186         contexts.addElement(newContext);
187     }
188
189     public void setLogDirectory(String JavaDoc newDir) {
190         StringUtil.assertNotBlank(newDir,
191                 "You must specify a non-blank log directory");
192         logDirectory = newDir;
193     }
194
195     public String JavaDoc getLogDirectory() {
196         return ConfigManager.expandValue(logDirectory);
197     }
198
199     public void setStrongCrypto(String JavaDoc newCrypto) {
200         StringUtil.assertBoolean(newCrypto,
201                 "You must specify a boolean value for the strong encryption flag");
202         strongCrypto = newCrypto;
203     }
204
205     public boolean strongCrypto() {
206         return StringUtil.toBoolean(strongCrypto);
207     }
208
209     public void setServletAPI(String JavaDoc newAPI) {
210         servletAPI = newAPI;
211     }
212
213     public void setServletApi(String JavaDoc newAPI) {
214         servletAPI = newAPI;
215     }
216
217     public String JavaDoc getServletAPI() {
218         return servletAPI;
219     }
220 }
Popular Tags