craigmcc 01/12/26 15:14:50 Modified: conf/share struts-config_1_1.dtd src/share/org/apache/struts/action Action.java src/share/org/apache/struts/config ApplicationConfig.java Added: src/share/org/apache/struts/config ConfigRuleSet.java ControllerConfig.java MessageResourcesConfig.java Log: Add configuration objects for the controller-specific characteristics, and the message resources, of each individual sub-application. Revision Changes Path 1.2 +61 -2 jakarta-struts/conf/share/struts-config_1_1.dtd Index: struts-config_1_1.dtd =================================================================== RCS file: /home/cvs/jakarta-struts/conf/share/struts-config_1_1.dtd,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- struts-config_1_1.dtd 2001/06/25 00:02:26 1.1 +++ struts-config_1_1.dtd 2001/12/26 23:14:50 1.2 @@ -11,7 +11,7 @@ "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> - $Id: struts-config_1_1.dtd,v 1.1 2001/06/25 00:02:26 craigmcc Exp $ + $Id: struts-config_1_1.dtd,v 1.2 2001/12/26 23:14:50 craigmcc Exp $ --> @@ -79,7 +79,7 @@ hierarchy, and contains nested elements for all of the other configuration settings. --> -<!ELEMENT struts-config (data-sources?, form-beans?, global-forwards?, action-mappings?)> +<!ELEMENT struts-config (data-sources?, form-beans?, global-forwards?, action-mappings?, controller?, message-resources?)> <!ATTLIST struts-config id ID #IMPLIED> @@ -343,6 +343,65 @@ <!ATTLIST action type %ClassName; #IMPLIED> <!ATTLIST action unknown %Boolean; #IMPLIED> <!ATTLIST action validate %Boolean; #IMPLIED> + + +<!-- The "controller" element specifies the controller characterstics for + requests directed to this application. The following attributes are + defined: + + bufferSize The size of the input buffer used when processing + file uploads. [4096] + + contentType Default content type (and optional character encoding) + to be set on each response. May be overridden by a + forwarded-to servlet or JSP page. [text/html] + + locale Set to true if you want a Locale object stored in the + user's session if not already present. [true] + + maxFileSize The maximum size (in bytes) of a file to be accepted + as a file upload. Can be expressed as a number followed + by a "K", "M", or "G", which are interpreted to mean + kilobytes, megabytes, or gigabytes, respectively. [250M] + + nocache Set to <code>true</code> if you want Struts to add + HTTP headers for defeating caching to every response. + [false] + + tempDir Temporary working directory to use when processing + file uploads. [Directory provided by servlet container] +--> +<!ELEMENT controller EMPTY> +<!ATTLIST controller id ID #IMPLIED> +<!ATTLIST controller bufferSize %Integer #IMPLIED> +<!ATTLIST controller contentType CDATA #IMPLIED> +<!ATTLIST controller locale %Boolean #IMPLIED> +<!ATTLIST controller maxFileSize CDATA #IMPLIED> +<!ATTLIST controller nocache %Boolean #IMPLIED> +<!ATTLIST controller tempDir CDATA #IMPLIED> + + +<!-- The "message-resources" element specifies the characteristics of the + MessageResources containing the messages for this application. The + following attributes are defined: + + factory Fully qualified Java class name of the + MessageResourcesFactory class we should use, if any. + By default, this is set to + org.apache.struts.util.PropertyMessageResourcesFactory. + + null Set to true if you want our message resources to return + a null string for unknown message keys, or false to + return a message with the bad key value. [true] + + parameter Configuration parameter to be passed to the + createResources() method of our MessageResourcesFactory. +--> +<!ELEMENT message-resources EMPTY> +<!ATTLIST message-resources id ID #IMPLIED> +<!ATTLIST message-resources factory %ClassName; #IMPLIED> +<!ATTLIST message-resources null %Boolean; #IMPLIED> +<!ATTLIST message-resources parameter CDATA #REQUIRED> <!-- The "set-property" element specifies the name and value of an additional 1.28 +14 -4 jakarta-struts/src/share/org/apache/struts/action/Action.java Index: Action.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- Action.java 2001/12/16 16:45:13 1.27 +++ Action.java 2001/12/26 23:14:50 1.28 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.27 2001/12/16 16:45:13 husted Exp $ - * $Revision: 1.27 $ - * $Date: 2001/12/16 16:45:13 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.28 2001/12/26 23:14:50 craigmcc Exp $ + * $Revision: 1.28 $ + * $Date: 2001/12/26 23:14:50 $ * * ==================================================================== * @@ -108,13 +108,23 @@ * by this Action. * * @author Craig R. McClanahan - * @version $Revision: 1.27 $ $Date: 2001/12/16 16:45:13 $ + * @version $Revision: 1.28 $ $Date: 2001/12/26 23:14:50 $ */ public class Action { // ----------------------------------------------------- Manifest Constants + + + /** + * The base of the context attributes key under which our + * <code>ApplicationConfig</code> data structure will be stored. This + * will be suffixed with the actual application prefix (including the + * leading "/" character) to form the actual attributes key. + */ + public static final String APPLICATION_KEY = + "org.apache.struts.action.APPLICATION."; /** 1.2 +40 -4 jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java Index: ApplicationConfig.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ApplicationConfig.java 2001/12/26 19:16:25 1.1 +++ ApplicationConfig.java 2001/12/26 23:14:50 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v 1.1 2001/12/26 19:16:25 craigmcc Exp $ - * $Revision: 1.1 $ - * $Date: 2001/12/26 19:16:25 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v 1.2 2001/12/26 23:14:50 craigmcc Exp $ + * $Revision: 1.2 $ + * $Date: 2001/12/26 23:14:50 $ * * ==================================================================== * @@ -78,7 +78,7 @@ * previous Struts behavior that only supported one application.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.1 $ $Date: 2001/12/26 19:16:25 $ + * @version $Revision: 1.2 $ $Date: 2001/12/26 23:14:50 $ * @since Struts 1.1 */ @@ -147,6 +147,42 @@ public boolean getConfigured() { return (this.configured); + } + + + /** + * The controller configuration object for this application. + */ + protected ControllerConfig controllerConfig = null; + + public ControllerConfig getControllerConfig() { + if (this.controllerConfig == null) + this.controllerConfig = new ControllerConfig(); + return (this.controllerConfig); + } + + public void setControllerConfig(ControllerConfig cc) { + if (configured) + throw new IllegalStateException("Configuration is frozen"); + this.controllerConfig = cc; + } + + + /** + * The message resources configuration object for this application. + */ + protected MessageResourcesConfig messageResourcesConfig = null; + + public MessageResourcesConfig getMessageResourcesConfig() { + if (this.messageResourcesConfig == null) + this.messageResourcesConfig = new MessageResourcesConfig(); + return (this.messageResourcesConfig); + } + + public void setMessageResourcesConfig(MessageResourcesConfig mrc) { + if (configured) + throw new IllegalStateException("Configuration is frozen"); + this.messageResourcesConfig = mrc; } 1.1 jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java Index: ConfigRuleSet.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java,v 1.1 2001/12/26 23:14:50 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/12/26 23:14:50 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.config; import org.apache.commons.digester.Digester; import org.apache.commons.digester.RuleSetBase; /** * <p>The set of Digester rules required to parse a Struts application * configuration file (<code>struts-config.xml</code>).</p> * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/12/26 23:14:50 $ * @since Struts 1.1 */ public class ConfigRuleSet extends RuleSetBase { // --------------------------------------------------------- Public Methods /** * <p>Add the set of Rule instances defined in this RuleSet to the * specified <code>Digester</code> instance, associating them with * our namespace URI (if any). This method should only be called * by a Digester instance. These rules assume that an instance of * <code>org.apache.struts.config.ApplicationConfig</code> is pushed * onto the evaluation stack before parsing begins.</p> * * @param digester Digester instance to which the new Rule instances * should be added. */ public void addRuleInstances(Digester digester) { digester.addObjectCreate ("struts-config/data-sources/data-source", "org.apache.struts.config.DataSourceConfig", "className"); digester.addSetProperties ("struts-config/data-sources/data-source"); digester.addSetNext ("struts-config/data-sources/data-source", "addDataSourceConfig", "org.apache.struts.config.DataSourceConfig"); digester.addSetProperty ("struts-config/data-sources/data-source/set-property", "property", "value"); digester.addObjectCreate ("struts-config/action-mappings/action", "org.apache.struts.config.ActionConfig", "className"); digester.addSetProperties ("struts-config/action-mappings/action"); digester.addSetNext ("struts-config/action-mappings/action", "addActionConfig", "org.apache.struts.config.ActionConfig"); digester.addSetProperty ("struts-config/action-mappings/action/set-property", "property", "value"); digester.addObjectCreate ("struts-config/action-mappings/action/forward", "org.apache.struts.config.ForwardConfig", "className"); digester.addSetProperties ("struts-config/action-mappings/action/forward"); digester.addSetNext ("struts-config/action-mappings/action/forward", "addForwardConfig", "org.apache.struts.config.ForwardConfig"); digester.addSetProperty ("struts-config/action-mappings/action/forward/set-property", "property", "value"); digester.addObjectCreate ("struts-config/controller", "org.apache.struts.config.ControllerConfig", "className"); digester.addSetProperties ("struts-config/controller"); digester.addSetNext ("struts-config/controller", "setControllerConfig", "org.apache.struts.config.ControllerConfig"); digester.addSetProperty ("struts-config/controller/set-property", "property", "value"); digester.addObjectCreate ("struts-config/form-beans/form-bean", "org.apache.struts.config.FormBeanConfig", "className"); digester.addSetProperties ("struts-config/form-beans/form-bean"); digester.addSetNext ("struts-config/form-beans/form-bean", "addFormBeanConfig", "org.apache.struts.config.FormBeanConfig"); digester.addSetProperty ("struts-config/form-beans/form-bean/set-property", "property", "value"); digester.addObjectCreate ("struts-config/global-forwards/forward", "org.apache.struts.config.ForwardConfig", "className"); digester.addSetProperties ("struts-config/global-forwards/forward"); digester.addSetNext ("struts-config/global-forwards/forward", "addForwardConfig", "org.apache.struts.config.ForwardConfig"); digester.addSetProperty ("struts-config/global-forwards/forward/set-property", "property", "value"); digester.addObjectCreate ("struts-config/message-resources", "org.apache.struts.config.MessageResourcesConfig", "className"); digester.addSetProperties ("struts-config/message-resources"); digester.addSetNext ("struts-config/messageResources", "setMessageResourcesConfig", "org.apache.struts.config.MessageResourcesConfig"); digester.addSetProperty ("struts-config/message-resources/set-property", "property", "value"); } } 1.1 jakarta-struts/src/share/org/apache/struts/config/ControllerConfig.java Index: ControllerConfig.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ControllerConfig.java,v 1.1 2001/12/26 23:14:50 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/12/26 23:14:50 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.config; /** * <p>A JavaBean representing the configuration information of a * <code><controller></code> element in a Struts application * configuration file.</p> * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/12/26 23:14:50 $ * @since Struts 1.1 */ public class ControllerConfig { // ------------------------------------------------------------- Properties /** * The input buffer size for file uploads. */ protected int bufferSize = 4096; public int getBufferSize() { return (this.bufferSize); } public void setBufferSize(int bufferSize) { this.bufferSize = bufferSize; } /** * The content type and character encoding to be set on each response. */ protected String contentType = "text/html"; public String getContentType() { return (this.contentType); } public void setContentType(String contentType) { this.contentType = contentType; } /** * Should we store a Locale object in the user's session if needed? */ protected boolean locale = false; public boolean getLocale() { return (this.locale); } public void setLocale(boolean locale) { this.locale = locale; } /** * The maximum file size to process for file uploads. */ protected String maxFileSize = "250M"; public String getMaxFileSize() { return (this.maxFileSize); } public void setMaxFileSize(String maxFileSize) { this.maxFileSize = maxFileSize; } /** * Should we set no-cache HTTP headers on each response? */ protected boolean nocache = false; public boolean getNocache() { return (this.nocache); } public void setNocache(boolean nocache) { this.nocache = nocache; } /** * The temporary working directory to use for file uploads. */ protected String tempDir = null; public String getTempDir() { return (this.tempDir); } public void setTempDir(String tempDir) { this.tempDir = tempDir; } // --------------------------------------------------------- Public Methods /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("ControllerConfig["); sb.append("bufferSize="); sb.append(this.bufferSize); if (this.contentType != null) { sb.append(",contentType="); sb.append(this.contentType); } sb.append(",locale="); sb.append(this.locale); if (this.maxFileSize != null) { sb.append(",maxFileSzie="); sb.append(this.maxFileSize); } sb.append(",nocache="); sb.append(this.nocache); if (this.tempDir != null) { sb.append(",tempDir="); sb.append(this.tempDir); } sb.append("]"); return (sb.toString()); } } 1.1 jakarta-struts/src/share/org/apache/struts/config/MessageResourcesConfig.java Index: MessageResourcesConfig.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/MessageResourcesConfig.java,v 1.1 2001/12/26 23:14:50 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/12/26 23:14:50 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * * Copyright (c) 1999-2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. * */ package org.apache.struts.config; /** * <p>A JavaBean representing the configuration information of a * <code><message-resources></code> element in a Struts application * configuration file.</p> * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/12/26 23:14:50 $ * @since Struts 1.1 */ public class MessageResourcesConfig { // ------------------------------------------------------------- Properties /** * Fully qualified Java class name of the MessageResourcesFactory class * we should use. */ protected String factory = "org.apache.struts.util.PropertyMessageResourcesFactory"; public String getFactory() { return (this.factory); } public void setFactory(String factory) { this.factory = factory; } /** * Should we return <code>null</code> for unknown message keys? */ protected boolean nullValue = true; public boolean getNull() { return (this.nullValue); } public void setNull(boolean nullValue) { this.nullValue = nullValue; } /** * Parameter that is passed to the <code>createResources()</code> method * of our MessageResourcesFactory implementation. */ protected String parameter = null; public String getParameter() { return (this.parameter); } public void setParameter(String parameter) { this.parameter = parameter; } // --------------------------------------------------------- Public Methods /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("MessageResourcesConfig["); sb.append("factory="); sb.append(this.factory); sb.append("null="); sb.append(this.nullValue); sb.append(",parameter="); sb.append(this.parameter); sb.append("]"); return (sb.toString()); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>