KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > services > resources > TurbineResources


1 package org.apache.turbine.services.resources;
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 import java.util.Iterator JavaDoc;
20 import java.util.List JavaDoc;
21
22 import org.apache.commons.configuration.Configuration;
23
24 import org.apache.turbine.Turbine;
25 import org.apache.turbine.TurbineConstants;
26 import org.apache.turbine.services.security.SecurityService;
27
28 /**
29  * This is a static class for defining the default Turbine configuration
30  * keys used by core Turbine components.
31  *
32  * @author <a HREF="mailto:jon@latchkey.com">Jon S. Stevens</a>
33  * @author <a HREF="mailto:greg@shwoop.com">Greg Ritter</a>
34  * @author <a HREF="mailto:luta.raphael@networks.vivendi.net">Raphaël Luta</a>
35  * @author <a HREF="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
36  * @author <a HREF="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
37  * @version $Id: TurbineResources.java,v 1.12.2.3 2004/08/16 22:57:49 henning Exp $
38  * @deprecated as of Turbine 2.2 use Turbine.getConfiguration()
39  */

40 public abstract class TurbineResources
41 {
42     /** @deprecated Use the corresponding constant from TurbineConstants */
43     public static final String JavaDoc MAIL_SERVER_KEY = TurbineConstants.MAIL_SERVER_KEY;
44
45     /** @deprecated Use the corresponding constant from TurbineConstants */
46     public static final String JavaDoc MODULE_CACHE_KEY = TurbineConstants.MODULE_CACHE_KEY;
47
48     /** @deprecated Use the corresponding constant from TurbineConstants */
49     public static final String JavaDoc MODULE_PACKAGES_KEY = TurbineConstants.MODULE_PACKAGES;
50
51     /** @deprecated Use the corresponding constant from TurbineConstants */
52     public static final String JavaDoc ACTION_CACHE_SIZE_KEY = TurbineConstants.ACTION_CACHE_SIZE_KEY;
53
54     /** @deprecated Use the corresponding constant from TurbineConstants */
55     public static final String JavaDoc LAYOUT_CACHE_SIZE_KEY = TurbineConstants.LAYOUT_CACHE_SIZE_KEY;
56
57     /** @deprecated Use the corresponding constant from TurbineConstants */
58     public static final String JavaDoc NAVIGATION_CACHE_SIZE_KEY = TurbineConstants.NAVIGATION_CACHE_SIZE_KEY;
59
60     /** @deprecated Use the corresponding constant from TurbineConstants */
61     public static final String JavaDoc PAGE_CACHE_SIZE_KEY = TurbineConstants.PAGE_CACHE_SIZE_KEY;
62
63     /** @deprecated Use the corresponding constant from TurbineConstants */
64     public static final String JavaDoc SCREEN_CACHE_SIZE_KEY = TurbineConstants.SCREEN_CACHE_SIZE_KEY;
65
66     /** @deprecated Use the corresponding constant from SecurityService */
67     public static final String JavaDoc USER_CLASS_KEY = SecurityService.USER_CLASS_KEY;
68
69     /** @deprecated No longer used */
70     public static final String JavaDoc MAX_FILE_SIZE_KEY = "max.file.size.bytes";
71
72     /** @deprecated No longer used */
73     public static final String JavaDoc FILE_SERVER = "file.server";
74
75     /** @deprecated Use the corresponding constant from TurbineConstants */
76     public static final String JavaDoc LOGIN_MESSAGE = TurbineConstants.LOGIN_MESSAGE;
77
78     /** @deprecated Use the corresponding constant from TurbineConstants */
79     public static final String JavaDoc LOGIN_ERROR = TurbineConstants.LOGIN_ERROR;
80
81     /** @deprecated Use the corresponding constant from TurbineConstants */
82     public static final String JavaDoc LOGIN_MESSAGE_NOSCREEN = TurbineConstants.LOGIN_MESSAGE_NOSCREEN;
83
84     /** @deprecated Use the corresponding constant from TurbineConstants */
85     public static final String JavaDoc LOGOUT_MESSAGE = TurbineConstants.LOGOUT_MESSAGE;
86
87     /**
88      * Set a property in with a key=value pair.
89      *
90      * @param key
91      * @param value
92      */

93     public static void setProperty(String JavaDoc key, String JavaDoc value)
94     {
95         Turbine.getConfiguration().setProperty(key, value);
96     }
97
98     /**
99      * The purpose of this method is to get the configuration resource
100      * with the given name as a boolean value.
101      *
102      * @param name The resource name.
103      * @return The value of the named resource as a boolean.
104      */

105     public static boolean getBoolean(String JavaDoc name)
106     {
107         return Turbine.getConfiguration().getBoolean(name);
108     }
109
110     /**
111      * The purppose of this method is to get the configuration
112      * resource with the given name as a boolean value, or a default
113      * value.
114      *
115      * @param name The resource name.
116      * @param def The default value of the resource.
117      * @return The value of the named resource as a boolean.
118      */

119     public static boolean getBoolean(String JavaDoc name,
120                                      boolean def)
121     {
122         return Turbine.getConfiguration().getBoolean(name, def);
123     }
124
125     /**
126      * The purpose of this method is to get the configuration resource
127      * with the given name as a double.
128      *
129      * @param name The resoource name.
130      * @return The value of the named resource as double.
131      */

132     public static double getDouble(String JavaDoc name)
133     {
134         return Turbine.getConfiguration().getDouble(name);
135     }
136
137     /**
138      * The purpose of this method is to get the configuration resource
139      * with the given name as a double, or a default value.
140      *
141      * @param name The resource name.
142      * @param def The default value of the resource.
143      * @return The value of the named resource as a double.
144      */

145     public static double getDouble(String JavaDoc name,
146                                    double def)
147     {
148         return Turbine.getConfiguration().getDouble(name, def);
149     }
150
151     /**
152      * The purpose of this method is to get the configuration resource
153      * with the given name as a float.
154      *
155      * @param name The resource name.
156      * @return The value of the resource as a float.
157      */

158     public static float getFloat(String JavaDoc name)
159     {
160         return Turbine.getConfiguration().getFloat(name);
161     }
162
163     /**
164      * The purpose of this method is to get the configuration resource
165      * with the given name as a float, or a default value.
166      *
167      * @param name The resource name.
168      * @param def The default value of the resource.
169      * @return The value of the resource as a float.
170      */

171     public static float getFloat(String JavaDoc name,
172                                  float def)
173     {
174         return Turbine.getConfiguration().getFloat(name, def);
175     }
176
177     /**
178      * The purpose of this method is to get the configuration resource
179      * with the given name as an integer.
180      *
181      * @param name The resource name.
182      * @return The value of the resource as an integer.
183      */

184     public static int getInt(String JavaDoc name)
185     {
186         return Turbine.getConfiguration().getInt(name);
187     }
188
189     /**
190      * The purpose of this method is to get the configuration resource
191      * with the given name as an integer, or a default value.
192      *
193      * @param name The resource name.
194      * @param def The default value of the resource.
195      * @return The value of the resource as an integer.
196      */

197     public static int getInt(String JavaDoc name,
198                              int def)
199     {
200         return Turbine.getConfiguration().getInt(name, def);
201     }
202
203     /**
204      * Get the list of the keys contained in the configuration
205      * repository.
206      *
207      * @return An Enumeration with all the keys.
208      */

209     public static Iterator JavaDoc getKeys()
210     {
211         return Turbine.getConfiguration().getKeys();
212     }
213
214     /**
215      * Get the list of the keys contained in the configuration
216      * repository that match the specified prefix.
217      *
218      * @param prefix A String prefix to test against.
219      * @return An Enumeration of keys that match the prefix.
220      */

221     public static Iterator JavaDoc getKeys(String JavaDoc prefix)
222     {
223         return Turbine.getConfiguration().getKeys(prefix);
224     }
225
226     /**
227      * The purpose of this method is to get the configuration resource
228      * with the given name as a long.
229      *
230      * @param name The resource name.
231      * @return The value of the resource as a long.
232      */

233     public static long getLong(String JavaDoc name)
234     {
235         return Turbine.getConfiguration().getLong(name);
236     }
237
238     /**
239      * The purpose of this method is to get the configuration resource
240      * with the given name as a long, or a default value.
241      *
242      * @param name The resource name.
243      * @param def The default value of the resource.
244      * @return The value of the resource as a long.
245      */

246     public static long getLong(String JavaDoc name,
247                                long def)
248     {
249         return Turbine.getConfiguration().getLong(name, def);
250     }
251
252     /**
253      * The purpose of this method is to get the configuration resource
254      * with the given name as a string.
255      *
256      * @param name The resource name.
257      * @return The value of the resource as a string.
258      */

259     public static String JavaDoc getString(String JavaDoc name)
260     {
261         return Turbine.getConfiguration().getString(name);
262     }
263
264     /**
265      * The purpose of this method is to get the configuration resource
266      * with the given name as a string, or a default value.
267      *
268      * @param name The resource name.
269      * @param def The default value of the resource.
270      * @return The value of the resource as a string.
271      */

272     public static String JavaDoc getString(String JavaDoc name,
273                                    String JavaDoc def)
274     {
275         return Turbine.getConfiguration().getString(name, def);
276     }
277
278     /**
279      * The purpose of this method is to get the configuration resource
280      * with the given name as a string array.
281      *
282      * @param name The resource name.
283      * @return The value of the resource as a string array.
284      */

285     public static String JavaDoc[] getStringArray(String JavaDoc name)
286     {
287         return Turbine.getConfiguration().getStringArray(name);
288     }
289
290     /**
291      * The purpose of this method is to get the configuration resource
292      * with the given name as a vector.
293      *
294      * @param name The resource name.
295      * @return The value of the resource as a vector.
296      */

297     public static List JavaDoc getList(String JavaDoc name)
298     {
299         return Turbine.getConfiguration().getList(name);
300     }
301
302     /**
303      * The purpose of this method is to get the configuration resource
304      * with the given name as a vector, or a default value.
305      *
306      * @param name The resource name.
307      * @param def The default value of the resource.
308      * @return The value of the resource as a vector.
309      */

310     public static List JavaDoc getList(String JavaDoc name,
311                                    List JavaDoc def)
312     {
313         return Turbine.getConfiguration().getList(name, def);
314     }
315
316     /**
317      * Get the configuration.
318      *
319      * @return configuration.
320      */

321     public static Configuration getConfiguration()
322     {
323         return Turbine.getConfiguration();
324     }
325
326     /**
327      * The purpose of this method is to extract a subset configuration
328      * sharing a common name prefix.
329      *
330      * @param prefix the common name prefix
331      * @return A Configuration providing the subset of configuration.
332      */

333     public static Configuration getConfiguration(String JavaDoc prefix)
334     {
335         return Turbine.getConfiguration().subset(prefix);
336     }
337 }
338
Popular Tags