1 package org.apache.turbine.services.resources;
2
3 /* ====================================================================
4 * The Apache Software License, Version 1.1
5 *
6 * Copyright (c) 2001 The Apache Software Foundation. All rights
7 * reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
19 * distribution.
20 *
21 * 3. The end-user documentation included with the redistribution,
22 * if any, must include the following acknowledgment:
23 * "This product includes software developed by the
24 * Apache Software Foundation (http://www.apache.org/)."
25 * Alternately, this acknowledgment may appear in the software itself,
26 * if and wherever such third-party acknowledgments normally appear.
27 *
28 * 4. The names "Apache" and "Apache Software Foundation" and
29 * "Apache Turbine" must not be used to endorse or promote products
30 * derived from this software without prior written permission. For
31 * written permission, please contact apache@apache.org.
32 *
33 * 5. Products derived from this software may not be called "Apache",
34 * "Apache Turbine", nor may "Apache" appear in their name, without
35 * prior written permission of the Apache Software Foundation.
36 *
37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48 * SUCH DAMAGE.
49 * ====================================================================
50 *
51 * This software consists of voluntary contributions made by many
52 * individuals on behalf of the Apache Software Foundation. For more
53 * information on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57 import java.util.Iterator;
58 import java.util.Vector;
59 import org.apache.commons.configuration.Configuration;
60 import org.apache.turbine.services.TurbineServices;
61
62 /***
63 * <p>This is a static class for defining the default Turbine configuration
64 * keys used by core Turbine components.</p>
65 * <p>It also extends the basic static accessor class to the
66 * <code>ResourcesService</code> so that you directly access the
67 * properties through this class</p>
68 *
69 * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
70 * @author <a href="mailto:greg@shwoop.com">Greg Ritter</a>
71 * @author <a href="mailto:luta.raphael@networks.vivendi.net">Raphaël Luta</a>
72 * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
73 * @version $Id: TurbineResources.java,v 1.5 2002/07/11 16:53:25 mpoeschl Exp $
74 */
75 public abstract class TurbineResources
76 {
77 public static final String MAIL_SERVER_KEY = "mail.server";
78 public static final String MODULE_CACHE_KEY = "module.cache";
79 public static final String MODULE_PACKAGES_KEY = "module.packages";
80 public static final String ACTION_CACHE_SIZE_KEY = "action.cache.size";
81 public static final String LAYOUT_CACHE_SIZE_KEY = "layout.cache.size";
82 public static final String NAVIGATION_CACHE_SIZE_KEY = "navigation.cache.size";
83 public static final String PAGE_CACHE_SIZE_KEY = "page.cache.size";
84 public static final String SCREEN_CACHE_SIZE_KEY = "screen.cache.size";
85 public static final String USER_CLASS_KEY = "user.class";
86 public static final String MAX_FILE_SIZE_KEY = "max.file.size.bytes";
87 public static final String DB_DRIVER_KEY = "database.default.driver";
88 public static final String DB_URL_KEY = "database.default.url";
89 public static final String DB_USERNAME_KEY = "database.default.username";
90 public static final String DB_PASSWORD_KEY = "database.default.password";
91 public static final String DB_MAXCONNECTIONS_KEY = "database.maxConnections";
92 public static final String DB_EXPIRYTIME_KEY = "database.expiryTime";
93 public static final String FILE_SERVER = "file.server";
94 public static final String LOGIN_MESSAGE = "login.message";
95 public static final String LOGIN_ERROR = "login.error";
96 public static final String LOGIN_MESSAGE_NOSCREEN = "login.message.noscreen";
97 public static final String LOGOUT_MESSAGE = "logout.message";
98 public static final String DB_IDBROKER_CLEVERQUANTITY = "database.idbroker.cleverquantity";
99 public static final String DB_IDBROKER_PREFETCH = "database.idbroker.prefetch";
100
101 /***
102 * Utility method for accessing the service
103 * implementation
104 *
105 * @return a ResourcesService implementation instance
106 */
107 protected static ResourceService getService()
108 {
109 return (ResourceService)TurbineServices
110 .getInstance()
111 .getService(ResourceService.SERVICE_NAME);
112 }
113
114 /***
115 * Set a property in with a key=value pair.
116 *
117 * @param String key
118 * @param String value
119 */
120 public static void setProperty(String key, String value)
121 {
122 getService().setProperty(key,value);
123 }
124
125 /***
126 * The purpose of this method is to get the configuration resource
127 * with the given name as a boolean value.
128 *
129 * @param name The resource name.
130 * @return The value of the named resource as a boolean.
131 */
132 public static boolean getBoolean(String name)
133 {
134 return getService().getBoolean (name);
135 }
136
137 /***
138 * The purppose of this method is to get the configuration
139 * resource with the given name as a boolean value, or a default
140 * value.
141 *
142 * @param name The resource name.
143 * @param def The default value of the resource.
144 * @return The value of the named resource as a boolean.
145 */
146 public static boolean getBoolean(String name,
147 boolean def)
148 {
149 return getService().getBoolean(name, def);
150 }
151
152 /***
153 * The purpose of this method is to get the configuration resource
154 * with the given name as a double.
155 *
156 * @param name The resoource name.
157 * @return The value of the named resource as double.
158 */
159 public static double getDouble(String name)
160 {
161 return getService().getDouble(name);
162 }
163
164 /***
165 * The purpose of this method is to get the configuration resource
166 * with the given name as a double, or a default value.
167 *
168 * @param name The resource name.
169 * @param def The default value of the resource.
170 * @return The value of the named resource as a double.
171 */
172 public static double getDouble(String name,
173 double def)
174 {
175 return getService().getDouble(name, def);
176 }
177
178 /***
179 * The purpose of this method is to get the configuration resource
180 * with the given name as a float.
181 *
182 * @param name The resource name.
183 * @return The value of the resource as a float.
184 */
185 public static float getFloat(String name)
186 {
187 return getService().getFloat(name);
188 }
189
190 /***
191 * The purpose of this method is to get the configuration resource
192 * with the given name as a float, or a default value.
193 *
194 * @param name The resource name.
195 * @param def The default value of the resource.
196 * @return The value of the resource as a float.
197 */
198 public static float getFloat(String name,
199 float def)
200 {
201 return getService().getFloat(name, def);
202 }
203
204 /***
205 * The purpose of this method is to get the configuration resource
206 * with the given name as an integer.
207 *
208 * @param name The resource name.
209 * @return The value of the resource as an integer.
210 */
211 public static int getInt(String name)
212 {
213 return getService().getInt(name);
214 }
215
216 /***
217 * The purpose of this method is to get the configuration resource
218 * with the given name as an integer, or a default value.
219 *
220 * @param name The resource name.
221 * @param def The default value of the resource.
222 * @return The value of the resource as an integer.
223 */
224 public static int getInt(String name,
225 int def)
226 {
227 return getService().getInt(name, def);
228 }
229
230 /***
231 * Get the list of the keys contained in the configuration
232 * repository.
233 *
234 * @return An Enumeration with all the keys.
235 */
236 public static Iterator getKeys()
237 {
238 return getService().getKeys();
239 }
240
241 /***
242 * Get the list of the keys contained in the configuration
243 * repository that match the specified prefix.
244 *
245 * @param prefix A String prefix to test against.
246 * @return An Enumeration of keys that match the prefix.
247 */
248 public static Iterator getKeys(String prefix)
249 {
250 return getService().getKeys(prefix);
251 }
252
253 /***
254 * The purpose of this method is to get the configuration resource
255 * with the given name as a long.
256 *
257 * @param name The resource name.
258 * @return The value of the resource as a long.
259 */
260 public static long getLong(String name)
261 {
262 return getService().getLong(name);
263 }
264
265 /***
266 * The purpose of this method is to get the configuration resource
267 * with the given name as a long, or a default value.
268 *
269 * @param name The resource name.
270 * @param def The default value of the resource.
271 * @return The value of the resource as a long.
272 */
273 public static long getLong(String name,
274 long def)
275 {
276 return getService().getLong(name, def);
277 }
278
279 /***
280 * The purpose of this method is to get the configuration resource
281 * with the given name as a string.
282 *
283 * @param name The resource name.
284 * @return The value of the resource as a string.
285 */
286 public static String getString(String name)
287 {
288 return getService().getString(name);
289 }
290
291 /***
292 * The purpose of this method is to get the configuration resource
293 * with the given name as a string, or a default value.
294 *
295 * @param name The resource name.
296 * @param def The default value of the resource.
297 * @return The value of the resource as a string.
298 */
299 public static String getString(String name,
300 String def)
301 {
302 return getService().getString(name, def);
303 }
304
305 /***
306 * The purpose of this method is to get the configuration resource
307 * with the given name as a string array.
308 *
309 * @param name The resource name.
310 * @return The value of the resource as a string array.
311 */
312 public static String[] getStringArray(String name)
313 {
314 return getService().getStringArray(name);
315 }
316
317 /***
318 * The purpose of this method is to get the configuration resource
319 * with the given name as a vector.
320 *
321 * @param name The resource name.
322 * @return The value of the resource as a vector.
323 */
324 public static Vector getVector(String name)
325 {
326 return getService().getVector(name);
327 }
328
329 /***
330 * The purpose of this method is to get the configuration resource
331 * with the given name as a vector, or a default value.
332 *
333 * @param name The resource name.
334 * @param def The default value of the resource.
335 * @return The value of the resource as a vector.
336 */
337 public static Vector getVector(String name,
338 Vector def)
339 {
340 return getService().getVector(name,def);
341 }
342
343 /***
344 * The purpose of this method is to extract a subset of configuraton
345 * resources sharing a common name prefix.
346 *
347 * @param prefix the common name prefix
348 * @return A ResourceService providing the subset of configuration.
349 */
350 public static ResourceService getResources(String prefix)
351 {
352 return getService().getResources(prefix);
353 }
354
355 /***
356 * Get the configuraton.
357 *
358 * @return configuration.
359 */
360 public static Configuration getConfiguration()
361 {
362 return getService().getConfiguration();
363 }
364
365 /***
366 * The purpose of this method is to extract a subset configuraton
367 * sharing a common name prefix.
368 *
369 * @param prefix the common name prefix
370 * @return A Configuration providing the subset of configuration.
371 */
372 public static Configuration getConfiguration(String prefix)
373 {
374 return getService().getConfiguration(prefix);
375 }
376 }
This page was automatically generated by Maven