KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > db > CmsCacheSettings


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/CmsCacheSettings.java,v $
3  * Date : $Date: 2005/06/23 11:11:24 $
4  * Version: $Revision: 1.4 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.db;
33
34 /**
35  * The settings of the OpenCms driver manager.<p>
36  *
37  * @author Thomas Weckert
38  *
39  * @version $Revision: 1.4 $
40  *
41  * @since 6.0.0
42  */

43 public class CmsCacheSettings {
44
45     /** The size of the driver manager's cache for ACLs. */
46     private int m_aclCacheSize;
47
48     /** The name of the class to generate cache keys. */
49     private String JavaDoc m_cacheKeyGenerator;
50
51     /** The size of the driver manager's cache for groups. */
52     private int m_groupCacheSize;
53
54     /** The size of the security manager's cache for permission checks. */
55     private int m_permissionCacheSize;
56
57     /** The size of the driver manager's cache for projects. */
58     private int m_projectCacheSize;
59
60     /** The size of the driver manager's cache for properties. */
61     private int m_propertyCacheSize;
62
63     /** The size of the driver manager's cache for resources. */
64     private int m_resourceCacheSize;
65
66     /** The size of the driver manager's cache for lists of resources. */
67     private int m_resourcelistCacheSize;
68
69     /** The size of the driver manager's cache for users. */
70     private int m_userCacheSize;
71
72     /** The size of the driver manager's cache for user/group relations. */
73     private int m_userGroupsCacheSize;
74
75     /**
76      * Default constructor.<p>
77      */

78     public CmsCacheSettings() {
79
80         super();
81     }
82
83     /**
84      * Returns the size of the driver manager's cache for ACLs.<p>
85      *
86      * @return the size of the driver manager's cache for ACLs
87      */

88     public int getAclCacheSize() {
89
90         return m_aclCacheSize;
91     }
92
93     /**
94      * Returns the name of the class to generate cache keys.<p>
95      *
96      * @return the name of the class to generate cache keys
97      */

98     public String JavaDoc getCacheKeyGenerator() {
99
100         return m_cacheKeyGenerator;
101     }
102
103     /**
104      * Returns the size of the driver manager's cache for groups.<p>
105      *
106      * @return the size of the driver manager's cache for groups
107      */

108     public int getGroupCacheSize() {
109
110         return m_groupCacheSize;
111     }
112
113     /**
114      * Returns the size of the security manager's cache for permission checks.<p>
115      *
116      * @return the size of the security manager's cache for permission checks
117      */

118     public int getPermissionCacheSize() {
119
120         return m_permissionCacheSize;
121     }
122
123     /**
124      * Returns the size of the driver manager's cache for projects.<p>
125      *
126      * @return the size of the driver manager's cache for projects
127      */

128     public int getProjectCacheSize() {
129
130         return m_projectCacheSize;
131     }
132
133     /**
134      * Returns the size of the driver manager's cache for properties.<p>
135      *
136      * @return the size of the driver manager's cache for properties
137      */

138     public int getPropertyCacheSize() {
139
140         return m_propertyCacheSize;
141     }
142
143     /**
144      * Returns the size of the driver manager's cache for resources.<p>
145      *
146      * @return the size of the driver manager's cache for resources
147      */

148     public int getResourceCacheSize() {
149
150         return m_resourceCacheSize;
151     }
152
153     /**
154      * Returns the size of the driver manager's cache for lists of resources.<p>
155      *
156      * @return the size of the driver manager's cache for lists of resources
157      */

158     public int getResourcelistCacheSize() {
159
160         return m_resourcelistCacheSize;
161     }
162
163     /**
164      * Returns the size of the driver manager's cache for users.<p>
165      *
166      * @return the size of the driver manager's cache for users
167      */

168     public int getUserCacheSize() {
169
170         return m_userCacheSize;
171     }
172
173     /**
174      * Returns the size of the driver manager's cache for user/group relations.<p>
175      *
176      * @return the size of the driver manager's cache for user/group relations
177      */

178     public int getUserGroupsCacheSize() {
179
180         return m_userGroupsCacheSize;
181     }
182
183     /**
184      * Sets the size of the driver manager's cache for ACLs.<p>
185      *
186      * @param size the size of the driver manager's cache for ACLs
187      */

188     public void setAclCacheSize(String JavaDoc size) {
189
190         m_aclCacheSize = getIntValue(size, 1024);
191     }
192
193     /**
194      * Sets the name of the class to generate cache keys.<p>
195      *
196      * @param classname the name of the class to generate cache keys
197      */

198     public void setCacheKeyGenerator(String JavaDoc classname) {
199
200         m_cacheKeyGenerator = classname;
201     }
202
203     /**
204      * Sets the size of the driver manager's cache for groups.<p>
205      *
206      * @param size the size of the driver manager's cache for groups
207      */

208     public void setGroupCacheSize(String JavaDoc size) {
209
210         m_groupCacheSize = getIntValue(size, 64);
211     }
212
213     /**
214      * Sets the size of the security manager's cache for permission checks.<p>
215      *
216      * @param size the size of the security manager's cache for permission checks
217      */

218     public void setPermissionCacheSize(String JavaDoc size) {
219
220         m_permissionCacheSize = getIntValue(size, 1024);
221     }
222
223     /**
224      * Sets the size of the driver manager's cache for projects.<p>
225      *
226      * @param size the size of the driver manager's cache for projects
227      */

228     public void setProjectCacheSize(String JavaDoc size) {
229
230         m_projectCacheSize = getIntValue(size, 32);
231     }
232
233     /**
234      * Sets the size of the driver manager's cache for properties.<p>
235      *
236      * @param size the size of the driver manager's cache for properties
237      */

238     public void setPropertyCacheSize(String JavaDoc size) {
239
240         m_propertyCacheSize = getIntValue(size, 128);
241     }
242
243     /**
244      * Sets the size of the driver manager's cache for resources.<p>
245      *
246      * @param size the size of the driver manager's cache for resources
247      */

248     public void setResourceCacheSize(String JavaDoc size) {
249
250         m_resourceCacheSize = getIntValue(size, 8192);
251     }
252
253     /**
254      * Sets the size of the driver manager's cache for lists of resources.<p>
255      *
256      * @param size the size of the driver manager's cache for lists of resources
257      */

258     public void setResourcelistCacheSize(String JavaDoc size) {
259
260         m_resourcelistCacheSize = getIntValue(size, 256);
261     }
262
263     /**
264      * Sets the size of the driver manager's cache for users.<p>
265      *
266      * @param size the size of the driver manager's cache for users
267      */

268     public void setUserCacheSize(String JavaDoc size) {
269
270         m_userCacheSize = getIntValue(size, 64);
271     }
272
273     /**
274      * Sets the size of the driver manager's cache for user/group relations.<p>
275      *
276      * @param size the size of the driver manager's cache for user/group relations
277      */

278     public void setUserGroupsCacheSize(String JavaDoc size) {
279
280         m_userGroupsCacheSize = getIntValue(size, 256);
281     }
282
283     /**
284      * Turns a string into an int.<p>
285      *
286      * @param str the string to be converted
287      * @param defaultValue a default value to be returned in case the string could not be parsed or the parsed int value is <= 0
288      * @return the int value of the string
289      */

290     private int getIntValue(String JavaDoc str, int defaultValue) {
291
292         try {
293             int intValue = Integer.parseInt(str);
294             return (intValue > 0) ? intValue : defaultValue;
295         } catch (NumberFormatException JavaDoc e) {
296             // intentionally left blank
297
}
298
299         return defaultValue;
300     }
301
302 }
303
Popular Tags