KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > flex > CmsFlexCacheConfiguration


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/flex/CmsFlexCacheConfiguration.java,v $
3  * Date : $Date: 2005/06/23 11:11:33 $
4  * Version: $Revision: 1.7 $
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.flex;
33
34 /**
35  * Flex Cache configuration class.<p>
36  *
37  * @author Armen Markarian
38  *
39  * @version $Revision: 1.7 $
40  *
41  * @since 6.0.0
42  */

43 public class CmsFlexCacheConfiguration {
44
45     private int m_avgCacheBytes;
46
47     /** Indicates if the cache is enabled or not. */
48     private boolean m_cacheEnabled;
49
50     /** Indicates if offline resources should be cached or not. */
51     private boolean m_cacheOffline;
52
53     /**
54      * Sizing parameters for the cached "entries" (ie. pages) in the FlexCache.<p>
55      *
56      * The amount of server memory available obviously is the
57      * critical factor here. The values below are set in byte size.
58      * The default is 2mb memory for the cached pages _or_ a maximum of 4000
59      * cached page variations in total.
60      */

61     private int m_maxCacheBytes;
62
63     private int m_maxEntryBytes;
64
65     private int m_maxKeys;
66
67     /**
68      * Empty public constructor for the digester.
69      */

70     public CmsFlexCacheConfiguration() {
71
72         // empty public constructor for digester
73
}
74
75     /**
76      * Returns the average cache bytes.<p>
77      *
78      * @return the average cache bytes
79      */

80     public int getAvgCacheBytes() {
81
82         return m_avgCacheBytes;
83     }
84
85     /**
86      * Returns the maxCacheBytes.<p>
87      *
88      * @return the maxCacheBytes
89      */

90     public int getMaxCacheBytes() {
91
92         return m_maxCacheBytes;
93     }
94
95     /**
96      * Returns the maxEntryBytes.<p>
97      *
98      * @return the maxEntryBytes
99      */

100     public int getMaxEntryBytes() {
101
102         return m_maxEntryBytes;
103     }
104
105     /**
106      * Returns the maxKeys.<p>
107      *
108      * @return the maxKeys
109      */

110     public int getMaxKeys() {
111
112         return m_maxKeys;
113     }
114
115     /**
116      * Initializes the flex cache configuration with required parameters.<p>
117      *
118      * @param enabled enables or disable the flexcache
119      * @param offline enable the flexcache for the offline project
120      * @param maxCacheBytes the max bytes for cache
121      * @param avgCacheBytes the average bytes for cache
122      * @param maxEntryBytes the max bytes for entry
123      * @param maxKeys the max keys
124      */

125     public void initialize(
126         String JavaDoc enabled,
127         String JavaDoc offline,
128         String JavaDoc maxCacheBytes,
129         String JavaDoc avgCacheBytes,
130         String JavaDoc maxEntryBytes,
131         String JavaDoc maxKeys) {
132
133         setCacheEnabled(Boolean.valueOf(enabled).booleanValue());
134         setCacheOffline(Boolean.valueOf(offline).booleanValue());
135         setMaxCacheBytes(Integer.parseInt(maxCacheBytes));
136         setAvgCacheBytes(Integer.parseInt(avgCacheBytes));
137         setMaxEntryBytes(Integer.parseInt(maxEntryBytes));
138         setMaxKeys(Integer.parseInt(maxKeys));
139     }
140
141     /**
142      * Checks if flexcache is enabled or not.<p>
143      *
144      * @return true if flexcache is enabled; otherwise false
145      */

146     public boolean isCacheEnabled() {
147
148         return m_cacheEnabled;
149     }
150
151     /**
152      * Checks the cacheOffline.<p>
153      *
154      * @return true if cacheoffline is set to true; otherwise false
155      */

156     public boolean isCacheOffline() {
157
158         return m_cacheOffline;
159     }
160
161     /**
162      * Sets the avgCacheBytes.<p>
163      *
164      * @param avgCacheBytes the avgCacheBytes to set
165      */

166     public void setAvgCacheBytes(int avgCacheBytes) {
167
168         m_avgCacheBytes = avgCacheBytes;
169     }
170
171     /**
172      * Sets the enabled.<p>
173      *
174      * @param enabled the enabled to set
175      */

176     public void setCacheEnabled(boolean enabled) {
177
178         m_cacheEnabled = enabled;
179     }
180
181     /**
182      * Sets the cacheOffline.<p>
183      *
184      * @param cacheOffline the cacheOffline to set
185      */

186     public void setCacheOffline(boolean cacheOffline) {
187
188         m_cacheOffline = cacheOffline;
189     }
190
191     /**
192      * Sets the maxCacheBytes.<p>
193      *
194      * @param maxCacheBytes the maxCacheBytes to set
195      */

196     public void setMaxCacheBytes(int maxCacheBytes) {
197
198         m_maxCacheBytes = maxCacheBytes;
199     }
200
201     /**
202      * Sets the maxEntryBytes.<p>
203      *
204      * @param maxEntryBytes the maxEntryBytes to set
205      */

206     public void setMaxEntryBytes(int maxEntryBytes) {
207
208         m_maxEntryBytes = maxEntryBytes;
209     }
210
211     /**
212      * Sets the maxKeys.<p>
213      *
214      * @param maxKeys the maxKeys to set
215      */

216     public void setMaxKeys(int maxKeys) {
217
218         m_maxKeys = maxKeys;
219     }
220 }
221
Popular Tags