View Javadoc
1   /*
2    * $Id$
3    *
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  package org.apache.struts.config;
22  
23  
24  /**
25   * A JavaBean representing the configuration information of a
26   * {@code <controller>} element in a Struts configuration file.
27   *
28   * @since Struts 1.1
29   */
30  public class ControllerConfig extends BaseConfig {
31      private static final long serialVersionUID = 7704474362520651283L;
32  
33      // ------------------------------------------------------------- Properties
34  
35      /**
36       * The input buffer size for file uploads.
37       */
38      protected int bufferSize = 4096;
39  
40      /**
41       * The content type and character encoding to be set on each response.
42       */
43      protected String contentType = "text/html";
44  
45      /**
46       * The chain catalog name for this module.
47       */
48      protected String catalog = "struts";
49  
50      /**
51       * The chain command to execute for each request.
52       */
53      protected String command = "servlet-standard";
54  
55      /**
56       * The replacement pattern used to determine a context-relative URL from a
57       * {@link ForwardConfig} element. The pattern may consist of any
58       * combination of the following markers and characters:
59       *
60       * <ul>
61       *
62       * <li><strong>{@code $M}</strong> - Replaced by the module prefix for the
63       * current module.</li>
64       *
65       * <li><strong>{@code $P}</strong> - Replaced by the {@code path} property
66       * of a {@link ForwardConfig} instance.</li>
67       *
68       * <li><strong>{@code $$}</strong> - Renders a literal dollar sign ("$")
69       * character in the resulting URL.</li>
70       *
71       * <li>A dollar sign followed by any other character is reserved for future
72       * use, and both characters are silently swallowed.</li>
73       *
74       * <li>All other characters in the pattern are passed through
75       * unchanged.</li>
76       *
77       * </ul>
78       *
79       * <p>If this property is set to {@code null}, a default pattern of
80       * {@code $M$P} is utilized, which is backwards compatible with the hard
81       * coded functionality in prior versions.</p>
82       */
83      protected String forwardPattern = null;
84  
85      /**
86       * Should the {@code input} property of {@link ActionConfig} instances
87       * associated with this module be treated as the name of a corresponding
88       * {@link ForwardConfig}. A {@code false} value treats them as a
89       * module-relative path (consistent with the hard coded behavior of
90       * earlier versions of Struts.
91       *
92       * @since Struts 1.1
93       */
94      protected boolean inputForward = false;
95  
96      /**
97       * Should we store a Locale object in the user's session if needed?
98       */
99      protected boolean locale = true;
100 
101     /**
102      * The maximum size to process a complete request for file uploads.
103      */
104     protected String maxSize = "256M";
105 
106     /**
107      * The maximum file size to process for file uploads.
108      */
109     protected String maxFileSize = "250M";
110 
111     /**
112      * The maximum length of a string parameter in a multipart request.
113      */
114     protected String maxStringLen = "4K";
115 
116     /**
117      * The maximum permitted number of files that may be uploaded in a single
118      * request. A value of -1 indicates no maximum.
119      */
120     protected long fileCountMax = -1;
121 
122     /**
123      * The maximum file size to retain in memory.
124      */
125     protected String memFileSize = "256K";
126 
127     /**
128      * The fully qualified Java class name of the MultipartRequestHandler class
129      * to be used.
130      */
131     protected String multipartClass =
132         "org.apache.struts.upload.CommonsMultipartRequestHandler";
133 
134     /**
135      * Should we set no-cache HTTP headers on each response?
136      */
137     protected boolean nocache = false;
138 
139     /**
140      * The replacement pattern used to determine a context-relative URL from
141      * the {@code page} attribute of Struts tags and configuration properties.
142      * The pattern may consist of any combination of the following markers and
143      * characters:
144      *
145      * <ul>
146      *
147      * <li><strong>{@code $M}</strong> - Replaced by the module prefix for the
148      * current module.</li>
149      *
150      * <li><strong>{@code $P}</strong> - Replaced by the {@code page} attribute
151      * value being evaluated.</li>
152      *
153      * <li><strong>{@code $$}</strong> - Renders a literal dollar sign ("$")
154      * character in the resulting URL.</li>
155      *
156      * <li>A dollar sign followed by any other character is reserved for future
157      * use, and both characters are silently swallowed.</li>
158      *
159      * <li>All other characters in the pattern are passed through
160      * unchanged.</li>
161      *
162      * </ul>
163      *
164      * <p>If this property is set to {@code null}, a default pattern of
165      * {@code $M$P} is utilized, which is backwards compatible with the hard
166      * coded functionality in prior versions.</p>
167      */
168     protected String pagePattern = null;
169 
170     /**
171      * The fully qualified class name of the RequestProcessor implementation
172      * class to be used for this module.
173      */
174     protected String processorClass =
175         "org.apache.struts.chain.ComposableRequestProcessor";
176 
177     /**
178      * The temporary working directory to use for file uploads.
179      */
180     protected String tempDir = null;
181 
182     public int getBufferSize() {
183         return (this.bufferSize);
184     }
185 
186     public void setBufferSize(int bufferSize) {
187         if (configured) {
188             throw new IllegalStateException("Configuration is frozen");
189         }
190 
191         this.bufferSize = bufferSize;
192     }
193 
194     public String getContentType() {
195         return (this.contentType);
196     }
197 
198     public void setContentType(String contentType) {
199         if (configured) {
200             throw new IllegalStateException("Configuration is frozen");
201         }
202 
203         this.contentType = contentType;
204     }
205 
206     public String getCatalog() {
207         return (this.catalog);
208     }
209 
210     public void setCatalog(String catalog) {
211         if (configured) {
212             throw new IllegalStateException("Configuration is frozen");
213         }
214 
215         this.catalog = catalog;
216     }
217 
218     public String getCommand() {
219         return (this.command);
220     }
221 
222     public void setCommand(String command) {
223         if (configured) {
224             throw new IllegalStateException("Configuration is frozen");
225         }
226 
227         this.command = command;
228     }
229 
230     public String getForwardPattern() {
231         return (this.forwardPattern);
232     }
233 
234     public void setForwardPattern(String forwardPattern) {
235         this.forwardPattern = forwardPattern;
236     }
237 
238     public boolean getInputForward() {
239         return (this.inputForward);
240     }
241 
242     public void setInputForward(boolean inputForward) {
243         this.inputForward = inputForward;
244     }
245 
246     public boolean getLocale() {
247         return (this.locale);
248     }
249 
250     public void setLocale(boolean locale) {
251         if (configured) {
252             throw new IllegalStateException("Configuration is frozen");
253         }
254 
255         this.locale = locale;
256     }
257 
258     public String getMaxSize() {
259         return (this.maxSize);
260     }
261 
262     public void setMaxSize(String maxSize) {
263         if (configured) {
264             throw new IllegalStateException("Configuration is frozen");
265         }
266 
267         this.maxSize = maxSize;
268     }
269 
270     public String getMaxFileSize() {
271         return (this.maxFileSize);
272     }
273 
274     public void setMaxFileSize(String maxFileSize) {
275         if (configured) {
276             throw new IllegalStateException("Configuration is frozen");
277         }
278 
279         this.maxFileSize = maxFileSize;
280     }
281 
282     public String getMaxStringLen() {
283         return (this.maxStringLen);
284     }
285 
286     public void setMaxStringLen(String maxStringLen) {
287         if (configured) {
288             throw new IllegalStateException("Configuration is frozen");
289         }
290 
291         this.maxStringLen = maxStringLen;
292     }
293 
294     public long getFileCountMax() {
295         return (this.fileCountMax);
296     }
297 
298     public void setFileCountMax(long fileCountMax) {
299         if (configured) {
300             throw new IllegalStateException("Configuration is frozen");
301         }
302 
303         this.fileCountMax = fileCountMax;
304     }
305 
306     public String getMemFileSize() {
307         return (this.memFileSize);
308     }
309 
310     public void setMemFileSize(String memFileSize) {
311         if (configured) {
312             throw new IllegalStateException("Configuration is frozen");
313         }
314 
315         this.memFileSize = memFileSize;
316     }
317 
318     public String getMultipartClass() {
319         return (this.multipartClass);
320     }
321 
322     public void setMultipartClass(String multipartClass) {
323         if (configured) {
324             throw new IllegalStateException("Configuration is frozen");
325         }
326 
327         this.multipartClass = multipartClass;
328     }
329 
330     public boolean getNocache() {
331         return (this.nocache);
332     }
333 
334     public void setNocache(boolean nocache) {
335         if (configured) {
336             throw new IllegalStateException("Configuration is frozen");
337         }
338 
339         this.nocache = nocache;
340     }
341 
342     public String getPagePattern() {
343         return (this.pagePattern);
344     }
345 
346     public void setPagePattern(String pagePattern) {
347         this.pagePattern = pagePattern;
348     }
349 
350     public String getProcessorClass() {
351         return (this.processorClass);
352     }
353 
354     public void setProcessorClass(String processorClass) {
355         if (configured) {
356             throw new IllegalStateException("Configuration is frozen");
357         }
358 
359         this.processorClass = processorClass;
360     }
361 
362     public String getTempDir() {
363         return (this.tempDir);
364     }
365 
366     public void setTempDir(String tempDir) {
367         if (configured) {
368             throw new IllegalStateException("Configuration is frozen");
369         }
370 
371         this.tempDir = tempDir;
372     }
373 
374     // --------------------------------------------------------- Public Methods
375 
376     /**
377      * Return a String representation of this object.
378      */
379     public String toString() {
380         StringBuilder sb = new StringBuilder("ControllerConfig[");
381 
382         sb.append("bufferSize=");
383         sb.append(this.bufferSize);
384 
385         if (this.contentType != null) {
386             sb.append(",contentType=");
387             sb.append(this.contentType);
388         }
389 
390         if (this.forwardPattern != null) {
391             sb.append(",forwardPattern=");
392             sb.append(this.forwardPattern);
393         }
394 
395         sb.append(",inputForward=");
396         sb.append(this.inputForward);
397         sb.append(",locale=");
398         sb.append(this.locale);
399 
400         if (this.maxFileSize != null) {
401             sb.append(",maxFileSize=");
402             sb.append(this.maxFileSize);
403         }
404 
405         sb.append("fileCountMax=");
406         sb.append(this.fileCountMax);
407 
408         if (this.memFileSize != null) {
409             sb.append(",memFileSize=");
410             sb.append(this.memFileSize);
411         }
412 
413         sb.append(",multipartClass=");
414         sb.append(this.multipartClass);
415         sb.append(",nocache=");
416         sb.append(this.nocache);
417 
418         if (this.pagePattern != null) {
419             sb.append(",pagePattern=");
420             sb.append(this.pagePattern);
421         }
422 
423         sb.append(",processorClass=");
424         sb.append(this.processorClass);
425 
426         if (this.tempDir != null) {
427             sb.append(",tempDir=");
428             sb.append(this.tempDir);
429         }
430 
431         sb.append("]");
432 
433         return (sb.toString());
434     }
435 }