View Javadoc

1   /*
2    * $Id: ControllerConfig.java 421119 2006-07-12 04:49:11Z wsmoak $
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  package org.apache.struts.config;
19  
20  
21  /***
22   * <p>A JavaBean representing the configuration information of a
23   * <code>&lt;controller&gt;</code> element in a Struts configuration
24   * file.</p>
25   *
26   * @version $Rev: 421119 $ $Date: 2005-05-12 18:41:19 -0400 (Thu, 12 May 2005)
27   *          $
28   * @since Struts 1.1
29   */
30  public class ControllerConfig extends BaseConfig {
31      // ------------------------------------------------------------- Properties
32  
33      /***
34       * <p> The input buffer size for file uploads. </p>
35       */
36      protected int bufferSize = 4096;
37  
38      /***
39       * <p> The content type and character encoding to be set on each response.
40       * </p>
41       */
42      protected String contentType = "text/html";
43  
44      /***
45       * <p> The chain catalog name for this module. </p>
46       */
47      protected String catalog = "struts";
48  
49      /***
50       * <p> The chain command to execute for each request. </p>
51       */
52      protected String command = "servlet-standard";
53  
54      /***
55       * <p>The replacement pattern used to determine a context-relative URL
56       * from a {@link ForwardConfig} element.  The pattern may consist of any
57       * combination of the following markers and characters:</p>
58       *
59       * <ul>
60       *
61       * <li><code><strong>$M</strong></code> - Replaced by the module prefix
62       * for the current module.</li>
63       *
64       * <li><code><strong>$P</strong></code> - Replaced by the
65       * <code>path</code> property of a {@link ForwardConfig} instance.</li>
66       *
67       * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
68       * ("$") character in the resulting URL.</li>
69       *
70       * <li>A dollar sign followed by any other character is reserved for
71       * future use, and both characters are silently swallowed.</li>
72       *
73       * <li>All other characters in the pattern are passed through unchanged.
74       * </li>
75       *
76       * </ul>
77       *
78       * <p>If this property is set to <code>null</code>, a default pattern of
79       * <code>$M$P</code> is utilized, which is backwards compatible with the
80       * hard coded functionality in prior versions.</p>
81       */
82      protected String forwardPattern = null;
83  
84      /***
85       * <p>Should the <code>input</code> property of {@link ActionConfig}
86       * instances associated with this module be treated as the name of a
87       * corresponding {@link ForwardConfig}.  A <code>false</code> value treats
88       * them as a module-relative path (consistent with the hard coded behavior
89       * of earlier versions of Struts.</p>
90       *
91       * @since Struts 1.1
92       */
93      protected boolean inputForward = false;
94  
95      /***
96       * <p> Should we store a Locale object in the user's session if needed?
97       * </p>
98       */
99      protected boolean locale = true;
100 
101     /***
102      * <p> The maximum file size to process for file uploads. </p>
103      */
104     protected String maxFileSize = "250M";
105 
106     /***
107      * <p> The maximum file size to retain in memory. </p>
108      */
109     protected String memFileSize = "256K";
110 
111     /***
112      * <p> The fully qualified Java class name of the MultipartRequestHandler
113      * class to be used. </p>
114      */
115     protected String multipartClass =
116         "org.apache.struts.upload.CommonsMultipartRequestHandler";
117 
118     /***
119      * <p> Should we set no-cache HTTP headers on each response? </p>
120      */
121     protected boolean nocache = false;
122 
123     /***
124      * <p>The replacement pattern used to determine a context-relative URL
125      * from the <code>page</code> attribute of Struts tags and configuration
126      * properties.  The pattern may consist of any combination of the
127      * following markers and characters:</p>
128      *
129      * <ul>
130      *
131      * <li><code><strong>$M</strong></code> - Replaced by the module prefix
132      * for the current module.</li>
133      *
134      * <li><code><strong>$P</strong></code> - Replaced by the
135      * <code>page</code> attribute value being evaluated.</li>
136      *
137      * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
138      * ("$") character in the resulting URL.</li>
139      *
140      * <li>A dollar sign followed by any other character is reserved for
141      * future use, and both characters are silently swallowed.</li>
142      *
143      * <li>All other characters in the pattern are passed through unchanged.
144      * </li>
145      *
146      * </ul>
147      *
148      * <p>If this property is set to <code>null</code>, a default pattern of
149      * <code>$M$P</code> is utilized, which is backwards compatible with the
150      * hard coded functionality in prior versions.</p>
151      */
152     protected String pagePattern = null;
153 
154     /***
155      * <p> The fully qualified class name of the RequestProcessor
156      * implementation class to be used for this module. </p>
157      */
158     protected String processorClass =
159         "org.apache.struts.chain.ComposableRequestProcessor";
160 
161     /***
162      * <p> The temporary working directory to use for file uploads. </p>
163      */
164     protected String tempDir = null;
165 
166     public int getBufferSize() {
167         return (this.bufferSize);
168     }
169 
170     public void setBufferSize(int bufferSize) {
171         if (configured) {
172             throw new IllegalStateException("Configuration is frozen");
173         }
174 
175         this.bufferSize = bufferSize;
176     }
177 
178     public String getContentType() {
179         return (this.contentType);
180     }
181 
182     public void setContentType(String contentType) {
183         if (configured) {
184             throw new IllegalStateException("Configuration is frozen");
185         }
186 
187         this.contentType = contentType;
188     }
189 
190     public String getCatalog() {
191         return (this.catalog);
192     }
193 
194     public void setCatalog(String catalog) {
195         if (configured) {
196             throw new IllegalStateException("Configuration is frozen");
197         }
198 
199         this.catalog = catalog;
200     }
201 
202     public String getCommand() {
203         return (this.command);
204     }
205 
206     public void setCommand(String command) {
207         if (configured) {
208             throw new IllegalStateException("Configuration is frozen");
209         }
210 
211         this.command = command;
212     }
213 
214     public String getForwardPattern() {
215         return (this.forwardPattern);
216     }
217 
218     public void setForwardPattern(String forwardPattern) {
219         this.forwardPattern = forwardPattern;
220     }
221 
222     public boolean getInputForward() {
223         return (this.inputForward);
224     }
225 
226     public void setInputForward(boolean inputForward) {
227         this.inputForward = inputForward;
228     }
229 
230     public boolean getLocale() {
231         return (this.locale);
232     }
233 
234     public void setLocale(boolean locale) {
235         if (configured) {
236             throw new IllegalStateException("Configuration is frozen");
237         }
238 
239         this.locale = locale;
240     }
241 
242     public String getMaxFileSize() {
243         return (this.maxFileSize);
244     }
245 
246     public void setMaxFileSize(String maxFileSize) {
247         if (configured) {
248             throw new IllegalStateException("Configuration is frozen");
249         }
250 
251         this.maxFileSize = maxFileSize;
252     }
253 
254     public String getMemFileSize() {
255         return (this.memFileSize);
256     }
257 
258     public void setMemFileSize(String memFileSize) {
259         if (configured) {
260             throw new IllegalStateException("Configuration is frozen");
261         }
262 
263         this.memFileSize = memFileSize;
264     }
265 
266     public String getMultipartClass() {
267         return (this.multipartClass);
268     }
269 
270     public void setMultipartClass(String multipartClass) {
271         if (configured) {
272             throw new IllegalStateException("Configuration is frozen");
273         }
274 
275         this.multipartClass = multipartClass;
276     }
277 
278     public boolean getNocache() {
279         return (this.nocache);
280     }
281 
282     public void setNocache(boolean nocache) {
283         if (configured) {
284             throw new IllegalStateException("Configuration is frozen");
285         }
286 
287         this.nocache = nocache;
288     }
289 
290     public String getPagePattern() {
291         return (this.pagePattern);
292     }
293 
294     public void setPagePattern(String pagePattern) {
295         this.pagePattern = pagePattern;
296     }
297 
298     public String getProcessorClass() {
299         return (this.processorClass);
300     }
301 
302     public void setProcessorClass(String processorClass) {
303         if (configured) {
304             throw new IllegalStateException("Configuration is frozen");
305         }
306 
307         this.processorClass = processorClass;
308     }
309 
310     public String getTempDir() {
311         return (this.tempDir);
312     }
313 
314     public void setTempDir(String tempDir) {
315         if (configured) {
316             throw new IllegalStateException("Configuration is frozen");
317         }
318 
319         this.tempDir = tempDir;
320     }
321 
322     // --------------------------------------------------------- Public Methods
323 
324     /***
325      * <p> Return a String representation of this object. </p>
326      */
327     public String toString() {
328         StringBuffer sb = new StringBuffer("ControllerConfig[");
329 
330         sb.append("bufferSize=");
331         sb.append(this.bufferSize);
332 
333         if (this.contentType != null) {
334             sb.append(",contentType=");
335             sb.append(this.contentType);
336         }
337 
338         if (this.forwardPattern != null) {
339             sb.append(",forwardPattern=");
340             sb.append(this.forwardPattern);
341         }
342 
343         sb.append(",inputForward=");
344         sb.append(this.inputForward);
345         sb.append(",locale=");
346         sb.append(this.locale);
347 
348         if (this.maxFileSize != null) {
349             sb.append(",maxFileSize=");
350             sb.append(this.maxFileSize);
351         }
352 
353         if (this.memFileSize != null) {
354             sb.append(",memFileSize=");
355             sb.append(this.memFileSize);
356         }
357 
358         sb.append(",multipartClass=");
359         sb.append(this.multipartClass);
360         sb.append(",nocache=");
361         sb.append(this.nocache);
362 
363         if (this.pagePattern != null) {
364             sb.append(",pagePattern=");
365             sb.append(this.pagePattern);
366         }
367 
368         sb.append(",processorClass=");
369         sb.append(this.processorClass);
370 
371         if (this.tempDir != null) {
372             sb.append(",tempDir=");
373             sb.append(this.tempDir);
374         }
375 
376         sb.append("]");
377 
378         return (sb.toString());
379     }
380 }