001: /*
002: * File : $Source: /usr/local/cvs/opencms/src/org/opencms/db/CmsCacheSettings.java,v $
003: * Date : $Date: 2008-02-27 12:05:43 $
004: * Version: $Revision: 1.7 $
005: *
006: * This library is part of OpenCms -
007: * the Open Source Content Management System
008: *
009: * Copyright (c) 2002 - 2008 Alkacon Software GmbH (http://www.alkacon.com)
010: *
011: * This library is free software; you can redistribute it and/or
012: * modify it under the terms of the GNU Lesser General Public
013: * License as published by the Free Software Foundation; either
014: * version 2.1 of the License, or (at your option) any later version.
015: *
016: * This library is distributed in the hope that it will be useful,
017: * but WITHOUT ANY WARRANTY; without even the implied warranty of
018: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: * Lesser General Public License for more details.
020: *
021: * For further information about Alkacon Software GmbH, please see the
022: * company website: http://www.alkacon.com
023: *
024: * For further information about OpenCms, please see the
025: * project website: http://www.opencms.org
026: *
027: * You should have received a copy of the GNU Lesser General Public
028: * License along with this library; if not, write to the Free Software
029: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
030: */
031:
032: package org.opencms.db;
033:
034: /**
035: * The settings of the OpenCms driver manager.<p>
036: *
037: * @author Thomas Weckert
038: *
039: * @version $Revision: 1.7 $
040: *
041: * @since 6.0.0
042: */
043: public class CmsCacheSettings {
044:
045: /** The size of the driver manager's cache for ACLs. */
046: private int m_aclCacheSize;
047:
048: /** The name of the class to generate cache keys. */
049: private String m_cacheKeyGenerator;
050:
051: /** The size of the driver manager's cache for groups. */
052: private int m_groupCacheSize;
053:
054: /** The size of the driver manager's cache for organizational units. */
055: private int m_orgUnitCacheSize = -1; // this configuration entry is optional
056:
057: /** The size of the security manager's cache for permission checks. */
058: private int m_permissionCacheSize;
059:
060: /** The size of the driver manager's cache for projects. */
061: private int m_projectCacheSize;
062:
063: /** The size of the driver manager's cache for project resources. */
064: private int m_projectResourcesCacheSize = -1; // this configuration entry is optional
065:
066: /** The size of the driver manager's cache for properties. */
067: private int m_propertyCacheSize;
068:
069: /** The size of the driver manager's cache for property lists. */
070: private int m_propertyListsCacheSize = -1; // this configuration entry is optional
071:
072: /** The size of the driver manager's cache for resources. */
073: private int m_resourceCacheSize;
074:
075: /** The size of the driver manager's cache for lists of resources. */
076: private int m_resourcelistCacheSize;
077:
078: /** The size of the driver manager's cache for roles. */
079: private int m_rolesCacheSize = -1;
080:
081: /** The size of the driver manager's cache for users. */
082: private int m_userCacheSize;
083:
084: /** The size of the driver manager's cache for user/group relations. */
085: private int m_userGroupsCacheSize;
086:
087: /**
088: * Default constructor.<p>
089: */
090: public CmsCacheSettings() {
091:
092: super ();
093: }
094:
095: /**
096: * Returns the size of the driver manager's cache for ACLs.<p>
097: *
098: * @return the size of the driver manager's cache for ACLs
099: */
100: public int getAclCacheSize() {
101:
102: return m_aclCacheSize;
103: }
104:
105: /**
106: * Returns the name of the class to generate cache keys.<p>
107: *
108: * @return the name of the class to generate cache keys
109: */
110: public String getCacheKeyGenerator() {
111:
112: return m_cacheKeyGenerator;
113: }
114:
115: /**
116: * Returns the size of the driver manager's cache for organizational units.<p>
117: *
118: * Might be <code>-1</code> if configuration entry is missing.<p>
119: *
120: * @return the size of the driver manager's cache for organizational units
121: */
122: public int getConfiguredOrgUnitCacheSize() {
123:
124: return m_orgUnitCacheSize;
125: }
126:
127: /**
128: * Returns the size of the driver manager's cache for project resources.<p>
129: *
130: * Might be <code>-1</code> if configuration entry is missing.<p>
131: *
132: * @return the size of the driver manager's cache for project resources
133: */
134: public int getConfiguredProjectResourcesCacheSize() {
135:
136: return m_projectResourcesCacheSize;
137: }
138:
139: /**
140: * Returns the size of the driver manager's cache for property lists.<p>
141: *
142: * Might be <code>-1</code> if configuration entry is missing.<p>
143: *
144: * @return the size of the driver manager's cache for property lists
145: */
146: public int getConfiguredPropertyListsCacheSize() {
147:
148: return m_propertyListsCacheSize;
149: }
150:
151: /**
152: * Returns the size of the driver manager's cache for roles.<p>
153: *
154: * Might be <code>-1</code> if configuration entry is missing.<p>
155: *
156: * @return the size of the driver manager's cache for roles
157: */
158: public int getConfiguredRolesCacheSize() {
159:
160: return m_rolesCacheSize;
161: }
162:
163: /**
164: * Returns the size of the driver manager's cache for groups.<p>
165: *
166: * @return the size of the driver manager's cache for groups
167: */
168: public int getGroupCacheSize() {
169:
170: return m_groupCacheSize;
171: }
172:
173: /**
174: * Returns the size of the driver manager's cache for organizational units.<p>
175: *
176: * @return the size of the driver manager's cache for organizational units
177: */
178: public int getOrgUnitCacheSize() {
179:
180: if (m_orgUnitCacheSize < 0) {
181: return getGroupCacheSize();
182: }
183: return m_orgUnitCacheSize;
184: }
185:
186: /**
187: * Returns the size of the security manager's cache for permission checks.<p>
188: *
189: * @return the size of the security manager's cache for permission checks
190: */
191: public int getPermissionCacheSize() {
192:
193: return m_permissionCacheSize;
194: }
195:
196: /**
197: * Returns the size of the driver manager's cache for projects.<p>
198: *
199: * @return the size of the driver manager's cache for projects
200: */
201: public int getProjectCacheSize() {
202:
203: return m_projectCacheSize;
204: }
205:
206: /**
207: * Returns the size of the driver manager's cache for project resources.<p>
208: *
209: * @return the size of the driver manager's cache for project resources
210: */
211: public int getProjectResourcesCacheSize() {
212:
213: if (m_propertyListsCacheSize < 0) {
214: return getProjectCacheSize();
215: }
216: return m_projectResourcesCacheSize;
217: }
218:
219: /**
220: * Returns the size of the driver manager's cache for properties.<p>
221: *
222: * @return the size of the driver manager's cache for properties
223: */
224: public int getPropertyCacheSize() {
225:
226: return m_propertyCacheSize;
227: }
228:
229: /**
230: * Returns the size of the driver manager's cache for property lists.<p>
231: *
232: * @return the size of the driver manager's cache for property lists
233: */
234: public int getPropertyListsCacheSize() {
235:
236: if (m_propertyListsCacheSize < 0) {
237: return getPropertyCacheSize();
238: }
239: return m_propertyListsCacheSize;
240: }
241:
242: /**
243: * Returns the size of the driver manager's cache for resources.<p>
244: *
245: * @return the size of the driver manager's cache for resources
246: */
247: public int getResourceCacheSize() {
248:
249: return m_resourceCacheSize;
250: }
251:
252: /**
253: * Returns the size of the driver manager's cache for lists of resources.<p>
254: *
255: * @return the size of the driver manager's cache for lists of resources
256: */
257: public int getResourcelistCacheSize() {
258:
259: return m_resourcelistCacheSize;
260: }
261:
262: /**
263: * Returns the size of the driver manager's cache for roles.<p>
264: *
265: * @return the size of the driver manager's cache for roles
266: */
267: public int getRolesCacheSize() {
268:
269: if (m_rolesCacheSize < 0) {
270: return getPermissionCacheSize();
271: }
272: return m_rolesCacheSize;
273: }
274:
275: /**
276: * Returns the size of the driver manager's cache for users.<p>
277: *
278: * @return the size of the driver manager's cache for users
279: */
280: public int getUserCacheSize() {
281:
282: return m_userCacheSize;
283: }
284:
285: /**
286: * Returns the size of the driver manager's cache for user/group relations.<p>
287: *
288: * @return the size of the driver manager's cache for user/group relations
289: */
290: public int getUserGroupsCacheSize() {
291:
292: return m_userGroupsCacheSize;
293: }
294:
295: /**
296: * Sets the size of the driver manager's cache for ACLs.<p>
297: *
298: * @param size the size of the driver manager's cache for ACLs
299: */
300: public void setAclCacheSize(String size) {
301:
302: m_aclCacheSize = getIntValue(size, 1024);
303: }
304:
305: /**
306: * Sets the name of the class to generate cache keys.<p>
307: *
308: * @param classname the name of the class to generate cache keys
309: */
310: public void setCacheKeyGenerator(String classname) {
311:
312: m_cacheKeyGenerator = classname;
313: }
314:
315: /**
316: * Sets the size of the driver manager's cache for groups.<p>
317: *
318: * @param size the size of the driver manager's cache for groups
319: */
320: public void setGroupCacheSize(String size) {
321:
322: m_groupCacheSize = getIntValue(size, 64);
323: }
324:
325: /**
326: * Sets the size of the driver manager's cache for organizational units.<p>
327: *
328: * @param size the size of the driver manager's cache for organizational units
329: */
330: public void setOrgUnitCacheSize(String size) {
331:
332: m_orgUnitCacheSize = getIntValue(size, 64);
333: }
334:
335: /**
336: * Sets the size of the security manager's cache for permission checks.<p>
337: *
338: * @param size the size of the security manager's cache for permission checks
339: */
340: public void setPermissionCacheSize(String size) {
341:
342: m_permissionCacheSize = getIntValue(size, 1024);
343: }
344:
345: /**
346: * Sets the size of the driver manager's cache for projects.<p>
347: *
348: * @param size the size of the driver manager's cache for projects
349: */
350: public void setProjectCacheSize(String size) {
351:
352: m_projectCacheSize = getIntValue(size, 32);
353: }
354:
355: /**
356: * Sets the size of the driver manager's cache for project resources.<p>
357: *
358: * @param size the size of the driver manager's cache for project resources
359: */
360: public void setProjectResourcesCacheSize(String size) {
361:
362: m_projectResourcesCacheSize = getIntValue(size, -1);
363: }
364:
365: /**
366: * Sets the size of the driver manager's cache for properties.<p>
367: *
368: * @param size the size of the driver manager's cache for properties
369: */
370: public void setPropertyCacheSize(String size) {
371:
372: m_propertyCacheSize = getIntValue(size, 128);
373: }
374:
375: /**
376: * Sets the size of the driver manager's cache for property lists.<p>
377: *
378: * @param size the size of the driver manager's cache for property lists
379: */
380: public void setPropertyListsCacheSize(String size) {
381:
382: m_propertyListsCacheSize = getIntValue(size, -1);
383: }
384:
385: /**
386: * Sets the size of the driver manager's cache for resources.<p>
387: *
388: * @param size the size of the driver manager's cache for resources
389: */
390: public void setResourceCacheSize(String size) {
391:
392: m_resourceCacheSize = getIntValue(size, 8192);
393: }
394:
395: /**
396: * Sets the size of the driver manager's cache for lists of resources.<p>
397: *
398: * @param size the size of the driver manager's cache for lists of resources
399: */
400: public void setResourcelistCacheSize(String size) {
401:
402: m_resourcelistCacheSize = getIntValue(size, 256);
403: }
404:
405: /**
406: * Sets the size of the driver manager's cache for roles.<p>
407: *
408: * @param size the size of the driver manager's cache for roles
409: */
410: public void setRolesCacheSize(String size) {
411:
412: m_rolesCacheSize = getIntValue(size, 8192);
413: }
414:
415: /**
416: * Sets the size of the driver manager's cache for users.<p>
417: *
418: * @param size the size of the driver manager's cache for users
419: */
420: public void setUserCacheSize(String size) {
421:
422: m_userCacheSize = getIntValue(size, 64);
423: }
424:
425: /**
426: * Sets the size of the driver manager's cache for user/group relations.<p>
427: *
428: * @param size the size of the driver manager's cache for user/group relations
429: */
430: public void setUserGroupsCacheSize(String size) {
431:
432: m_userGroupsCacheSize = getIntValue(size, 256);
433: }
434:
435: /**
436: * Turns a string into an int.<p>
437: *
438: * @param str the string to be converted
439: * @param defaultValue a default value to be returned in case the string could not be parsed or the parsed int value is <= 0
440: * @return the int value of the string
441: */
442: private int getIntValue(String str, int defaultValue) {
443:
444: try {
445: int intValue = Integer.parseInt(str);
446: return (intValue > 0) ? intValue : defaultValue;
447: } catch (NumberFormatException e) {
448: // intentionally left blank
449: }
450: return defaultValue;
451: }
452: }
|