KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > config > ControllerConfig


1 /*
2  * $Id: ControllerConfig.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-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
20 package org.apache.struts.config;
21
22
23 import java.io.Serializable JavaDoc;
24
25
26 /**
27  * <p>A JavaBean representing the configuration information of a
28  * <code>&lt;controller&gt;</code> element in a Struts
29  * configuration file.</p>
30  *
31  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
32  * @since Struts 1.1
33  */

34
35 public class ControllerConfig implements Serializable JavaDoc {
36
37
38     // ----------------------------------------------------- Instance Variables
39

40
41     /**
42      * Has this component been completely configured?
43      */

44     protected boolean configured = false;
45
46
47     // ------------------------------------------------------------- Properties
48

49
50     /**
51      * The input buffer size for file uploads.
52      */

53     protected int bufferSize = 4096;
54
55     public int getBufferSize() {
56         return (this.bufferSize);
57     }
58
59     public void setBufferSize(int bufferSize) {
60         if (configured) {
61             throw new IllegalStateException JavaDoc("Configuration is frozen");
62         }
63         this.bufferSize = bufferSize;
64     }
65
66
67     /**
68      * The content type and character encoding to be set on each response.
69      */

70     protected String JavaDoc contentType = "text/html";
71
72     public String JavaDoc getContentType() {
73         return (this.contentType);
74     }
75
76     public void setContentType(String JavaDoc contentType) {
77         if (configured) {
78             throw new IllegalStateException JavaDoc("Configuration is frozen");
79         }
80         this.contentType = contentType;
81     }
82
83     /**
84      * <p>The replacement pattern used to determine a context-relative URL
85      * from a {@link ForwardConfig} element. The pattern may consist of any
86      * combination of the following markers and characters:</p>
87      * <ul>
88      * <li><code><strong>$M</strong></code> - Replaced by the module
89      * prefix for the current module.</li>
90      * <li><code><strong>$P</strong></code> - Replaced by the <code>path</code>
91      * property of a {@link ForwardConfig} instance.</li>
92      * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
93      * ("$") character in the resulting URL.</li>
94      * <li>A dollar sign followed by any other character is reserved for
95      * future use, and both characters are silently swallowed.</li>
96      * <li>All other characters in the pattern are passed through unchanged.
97      * </li>
98      * </ul>
99      *
100      * <p>If this property is set to <code>null</code>, a default pattern of
101      * <code>$M$P</code> is utilized, which is backwards compatible with
102      * the hard coded functionality in prior versions.</p>
103      */

104     protected String JavaDoc forwardPattern = null;
105
106     public String JavaDoc getForwardPattern() {
107         return (this.forwardPattern);
108     }
109
110     public void setForwardPattern(String JavaDoc forwardPattern) {
111         this.forwardPattern = forwardPattern;
112     }
113
114
115     /**
116      * <p>Should the <code>input</code> property of {@link ActionConfig}
117      * instances associated with this module be treated as the
118      * name of a corresponding {@link ForwardConfig}. A <code>false</code>
119      * value treats them as a module-relative path (consistent
120      * with the hard coded behavior of earlier versions of Struts.</p>
121      *
122      * @since Struts 1.1
123      */

124     protected boolean inputForward = false;
125
126     public boolean getInputForward() {
127         return (this.inputForward);
128     }
129
130     public void setInputForward(boolean inputForward) {
131         this.inputForward = inputForward;
132     }
133
134
135     /**
136      * Should we store a Locale object in the user's session if needed?
137      */

138     protected boolean locale = true;
139
140     public boolean getLocale() {
141         return (this.locale);
142     }
143
144     public void setLocale(boolean locale) {
145         if (configured) {
146             throw new IllegalStateException JavaDoc("Configuration is frozen");
147         }
148         this.locale = locale;
149     }
150
151
152     /**
153      * The maximum file size to process for file uploads.
154      */

155     protected String JavaDoc maxFileSize = "250M";
156
157     public String JavaDoc getMaxFileSize() {
158         return (this.maxFileSize);
159     }
160
161     public void setMaxFileSize(String JavaDoc maxFileSize) {
162         if (configured) {
163             throw new IllegalStateException JavaDoc("Configuration is frozen");
164         }
165         this.maxFileSize = maxFileSize;
166     }
167
168
169     /**
170      * The maximum file size to retain in memory.
171      */

172     protected String JavaDoc memFileSize = "256K";
173
174     public String JavaDoc getMemFileSize() {
175         return (this.memFileSize);
176     }
177
178     public void setMemFileSize(String JavaDoc memFileSize) {
179         if (configured) {
180             throw new IllegalStateException JavaDoc("Configuration is frozen");
181         }
182         this.memFileSize = memFileSize;
183     }
184
185
186     /**
187      * The fully qualified Java class name of the MultipartRequestHandler
188      * class to be used.
189      */

190     protected String JavaDoc multipartClass =
191         "org.apache.struts.upload.CommonsMultipartRequestHandler";
192
193     public String JavaDoc getMultipartClass() {
194         return (this.multipartClass);
195     }
196
197     public void setMultipartClass(String JavaDoc multipartClass) {
198         if (configured) {
199             throw new IllegalStateException JavaDoc("Configuration is frozen");
200         }
201         this.multipartClass = multipartClass;
202     }
203
204
205     /**
206      * Should we set no-cache HTTP headers on each response?
207      */

208     protected boolean nocache = false;
209
210     public boolean getNocache() {
211         return (this.nocache);
212     }
213
214     public void setNocache(boolean nocache) {
215         if (configured) {
216             throw new IllegalStateException JavaDoc("Configuration is frozen");
217         }
218         this.nocache = nocache;
219     }
220
221
222     /**
223      * <p>The replacement pattern used to determine a context-relative URL
224      * from the <code>page</code> attribute of Struts tags and configuration
225      * properties. The pattern may consist of any combination of the
226      * following markers and characters:</p>
227      * <ul>
228      * <li><code><strong>$M</strong></code> - Replaced by the module
229      * prefix for the current module.</li>
230      * <li><code><strong>$P</strong></code> - Replaced by the <code>page</code>
231      * attribute value being evaluated.</li>
232      * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
233      * ("$") character in the resulting URL.</li>
234      * <li>A dollar sign followed by any other character is reserved for
235      * future use, and both characters are silently swallowed.</li>
236      * <li>All other characters in the pattern are passed through unchanged.
237      * </li>
238      * </ul>
239      *
240      * <p>If this property is set to <code>null</code>, a default pattern of
241      * <code>$M$P</code> is utilized, which is backwards compatible with
242      * the hard coded functionality in prior versions.</p>
243      */

244     protected String JavaDoc pagePattern = null;
245
246     public String JavaDoc getPagePattern() {
247         return (this.pagePattern);
248     }
249
250     public void setPagePattern(String JavaDoc pagePattern) {
251         this.pagePattern = pagePattern;
252     }
253
254
255     /**
256      * The fully qualified class name of the RequestProcessor implementation
257      * class to be used for this module.
258      */

259     protected String JavaDoc processorClass =
260         "org.apache.struts.action.RequestProcessor";
261
262     public String JavaDoc getProcessorClass() {
263         return (this.processorClass);
264     }
265
266     public void setProcessorClass(String JavaDoc processorClass) {
267         if (configured) {
268             throw new IllegalStateException JavaDoc("Configuration is frozen");
269         }
270         this.processorClass = processorClass;
271     }
272
273
274     /**
275      * The temporary working directory to use for file uploads.
276      */

277     protected String JavaDoc tempDir = null;
278
279     public String JavaDoc getTempDir() {
280         return (this.tempDir);
281     }
282
283     public void setTempDir(String JavaDoc tempDir) {
284         if (configured) {
285             throw new IllegalStateException JavaDoc("Configuration is frozen");
286         }
287         this.tempDir = tempDir;
288     }
289
290
291     // --------------------------------------------------------- Public Methods
292

293
294     /**
295      * Freeze the configuration of this component.
296      */

297     public void freeze() {
298
299         configured = true;
300
301     }
302
303
304     /**
305      * Return a String representation of this object.
306      */

307     public String JavaDoc toString() {
308
309         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("ControllerConfig[");
310         sb.append("bufferSize=");
311         sb.append(this.bufferSize);
312         if (this.contentType != null) {
313             sb.append(",contentType=");
314             sb.append(this.contentType);
315         }
316         if (this.forwardPattern != null) {
317             sb.append(",forwardPattern=");
318             sb.append(this.forwardPattern);
319         }
320         sb.append(",inputForward=");
321         sb.append(this.inputForward);
322         sb.append(",locale=");
323         sb.append(this.locale);
324         if (this.maxFileSize != null) {
325             sb.append(",maxFileSize=");
326             sb.append(this.maxFileSize);
327         }
328         if (this.memFileSize != null) {
329             sb.append(",memFileSize=");
330             sb.append(this.memFileSize);
331         }
332         sb.append(",multipartClass=");
333         sb.append(this.multipartClass);
334         sb.append(",nocache=");
335         sb.append(this.nocache);
336         if (this.pagePattern != null) {
337             sb.append(",pagePattern=");
338             sb.append(this.pagePattern);
339         }
340         sb.append(",processorClass=");
341         sb.append(this.processorClass);
342         if (this.tempDir != null) {
343             sb.append(",tempDir=");
344             sb.append(this.tempDir);
345         }
346         sb.append("]");
347         return (sb.toString());
348
349     }
350
351
352 }
353
Popular Tags