001: /*
002: * $Id: ControllerConfig.java 471754 2006-11-06 14:55:09Z husted $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts.config;
022:
023: /**
024: * <p>A JavaBean representing the configuration information of a
025: * <code><controller></code> element in a Struts configuration
026: * file.</p>
027: *
028: * @version $Rev: 471754 $ $Date: 2005-05-12 18:41:19 -0400 (Thu, 12 May 2005)
029: * $
030: * @since Struts 1.1
031: */
032: public class ControllerConfig extends BaseConfig {
033: // ------------------------------------------------------------- Properties
034:
035: /**
036: * <p> The input buffer size for file uploads. </p>
037: */
038: protected int bufferSize = 4096;
039:
040: /**
041: * <p> The content type and character encoding to be set on each response.
042: * </p>
043: */
044: protected String contentType = "text/html";
045:
046: /**
047: * <p> The chain catalog name for this module. </p>
048: */
049: protected String catalog = "struts";
050:
051: /**
052: * <p> The chain command to execute for each request. </p>
053: */
054: protected String command = "servlet-standard";
055:
056: /**
057: * <p>The replacement pattern used to determine a context-relative URL
058: * from a {@link ForwardConfig} element. The pattern may consist of any
059: * combination of the following markers and characters:</p>
060: *
061: * <ul>
062: *
063: * <li><code><strong>$M</strong></code> - Replaced by the module prefix
064: * for the current module.</li>
065: *
066: * <li><code><strong>$P</strong></code> - Replaced by the
067: * <code>path</code> property of a {@link ForwardConfig} instance.</li>
068: *
069: * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
070: * ("$") character in the resulting URL.</li>
071: *
072: * <li>A dollar sign followed by any other character is reserved for
073: * future use, and both characters are silently swallowed.</li>
074: *
075: * <li>All other characters in the pattern are passed through unchanged.
076: * </li>
077: *
078: * </ul>
079: *
080: * <p>If this property is set to <code>null</code>, a default pattern of
081: * <code>$M$P</code> is utilized, which is backwards compatible with the
082: * hard coded functionality in prior versions.</p>
083: */
084: protected String forwardPattern = null;
085:
086: /**
087: * <p>Should the <code>input</code> property of {@link ActionConfig}
088: * instances associated with this module be treated as the name of a
089: * corresponding {@link ForwardConfig}. A <code>false</code> value treats
090: * them as a module-relative path (consistent with the hard coded behavior
091: * of earlier versions of Struts.</p>
092: *
093: * @since Struts 1.1
094: */
095: protected boolean inputForward = false;
096:
097: /**
098: * <p> Should we store a Locale object in the user's session if needed?
099: * </p>
100: */
101: protected boolean locale = true;
102:
103: /**
104: * <p> The maximum file size to process for file uploads. </p>
105: */
106: protected String maxFileSize = "250M";
107:
108: /**
109: * <p> The maximum file size to retain in memory. </p>
110: */
111: protected String memFileSize = "256K";
112:
113: /**
114: * <p> The fully qualified Java class name of the MultipartRequestHandler
115: * class to be used. </p>
116: */
117: protected String multipartClass = "org.apache.struts.upload.CommonsMultipartRequestHandler";
118:
119: /**
120: * <p> Should we set no-cache HTTP headers on each response? </p>
121: */
122: protected boolean nocache = false;
123:
124: /**
125: * <p>The replacement pattern used to determine a context-relative URL
126: * from the <code>page</code> attribute of Struts tags and configuration
127: * properties. The pattern may consist of any combination of the
128: * following markers and characters:</p>
129: *
130: * <ul>
131: *
132: * <li><code><strong>$M</strong></code> - Replaced by the module prefix
133: * for the current module.</li>
134: *
135: * <li><code><strong>$P</strong></code> - Replaced by the
136: * <code>page</code> attribute value being evaluated.</li>
137: *
138: * <li><code><strong>$$</strong></code> - Renders a literal dollar sign
139: * ("$") character in the resulting URL.</li>
140: *
141: * <li>A dollar sign followed by any other character is reserved for
142: * future use, and both characters are silently swallowed.</li>
143: *
144: * <li>All other characters in the pattern are passed through unchanged.
145: * </li>
146: *
147: * </ul>
148: *
149: * <p>If this property is set to <code>null</code>, a default pattern of
150: * <code>$M$P</code> is utilized, which is backwards compatible with the
151: * hard coded functionality in prior versions.</p>
152: */
153: protected String pagePattern = null;
154:
155: /**
156: * <p> The fully qualified class name of the RequestProcessor
157: * implementation class to be used for this module. </p>
158: */
159: protected String processorClass = "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: }
|