craigmcc 01/12/30 17:42:13 Modified: src/share/org/apache/struts/config ActionConfig.java ApplicationConfig.java ConfigRuleSet.java Added: src/share/org/apache/struts/config ExceptionConfig.java Log: Add configuration information for <exception> elements. Revision Changes Path 1.2 +53 -5 jakarta-struts/src/share/org/apache/struts/config/ActionConfig.java Index: ActionConfig.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfig.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ActionConfig.java 26 Dec 2001 19:16:25 -0000 1.1 +++ ActionConfig.java 31 Dec 2001 01:42:13 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ActionConfig.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/ActionConfig.java,v 1.2 2001/12/31 01:42:13 craigmcc Exp $ + * $Revision: 1.2 $ + * $Date: 2001/12/31 01:42:13 $ * * ==================================================================== * @@ -74,7 +74,7 @@ * configuration file.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.1 $ $Date: 2001/12/26 19:16:25 $ + * @version $Revision: 1.2 $ $Date: 2001/12/31 01:42:13 $ * @since Struts 1.1 */ @@ -85,6 +85,13 @@ /** + * The set of exception handling configurations for this + * action, if any, keyed by the <code>type</code> property. + */ + protected FastHashMap exceptions = new FastHashMap(); + + + /** * The set of local forward configurations for this action, if any, * keyed by the <code>name</code> property. */ @@ -362,8 +369,24 @@ /** + * Add a new <code>ExceptionConfig</code> object to the set associated + * with this action. + * + * @param config The new configuration object to be added + * + * @exception IllegalStateException if this application configuration + * has been frozen + */ + public void addExceptionConfig(ExceptionConfig config) { + + exceptions.put(config.getType(), config); + + } + + + /** * Add a new <code>ForwardConfig</code> object to the set of global - * forwards associated with this application. + * forwards associated with this action. * * @param config The new configuration object to be added * @@ -373,6 +396,31 @@ public void addForwardConfig(ForwardConfig config) { forwards.put(config.getName(), config); + + } + + + /** + * Return the exception configuration for the specified type, if any; + * otherwise return <code>null</code>. + * + * @param type Exception class name to find a configuration for + */ + public ExceptionConfig findExceptionConfig(String type) { + + return ((ExceptionConfig) exceptions.get(type)); + + } + + + /** + * Return the exception configurations for this action. If there + * are none, a zero-length array is returned. + */ + public ExceptionConfig[] findExceptionConfigs() { + + ExceptionConfig results[] = new ExceptionConfig[exceptions.size()]; + return ((ExceptionConfig[]) exceptions.values().toArray(results)); } 1.3 +54 -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.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ApplicationConfig.java 26 Dec 2001 23:14:50 -0000 1.2 +++ ApplicationConfig.java 31 Dec 2001 01:42:13 -0000 1.3 @@ -1,7 +1,7 @@ /* - * $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 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ApplicationConfig.java,v 1.3 2001/12/31 01:42:13 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/12/31 01:42:13 $ * * ==================================================================== * @@ -78,7 +78,7 @@ * previous Struts behavior that only supported one application.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.2 $ $Date: 2001/12/26 23:14:50 $ + * @version $Revision: 1.3 $ $Date: 2001/12/31 01:42:13 $ * @since Struts 1.1 */ @@ -122,6 +122,13 @@ /** + * The set of exception handling configurations for this + * application, if any, keyed by the <code>type</code> property. + */ + protected FastHashMap exceptions = new FastHashMap(); + + + /** * The set of form bean configurations for this application, if any, * keyed by the <code>name</code> property. */ @@ -250,6 +257,24 @@ /** + * Add a new <code>ExceptionConfig</code> object to the set associated + * with this application. + * + * @param config The new configuration object to be added + * + * @exception IllegalStateException if this application configuration + * has been frozen + */ + public void addExceptionConfig(ExceptionConfig config) { + + if (configured) + throw new IllegalStateException("Configuration is frozen"); + exceptions.put(config.getType(), config); + + } + + + /** * Add a new <code>FormBeanConfig</code> object to the set associated * with this application. * @@ -331,6 +356,31 @@ DataSourceConfig results[] = new DataSourceConfig[dataSources.size()]; return ((DataSourceConfig[]) dataSources.values().toArray(results)); + + } + + + /** + * Return the exception configuration for the specified type, if any; + * otherwise return <code>null</code>. + * + * @param type Exception class name to find a configuration for + */ + public ExceptionConfig findExceptionConfig(String type) { + + return ((ExceptionConfig) exceptions.get(type)); + + } + + + /** + * Return the exception configurations for this application. If there + * are none, a zero-length array is returned. + */ + public ExceptionConfig[] findExceptionConfigs() { + + ExceptionConfig results[] = new ExceptionConfig[exceptions.size()]; + return ((ExceptionConfig[]) exceptions.values().toArray(results)); } 1.2 +33 -3 jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java Index: ConfigRuleSet.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConfigRuleSet.java 26 Dec 2001 23:14:50 -0000 1.1 +++ ConfigRuleSet.java 31 Dec 2001 01:42:13 -0000 1.2 @@ -1,7 +1,7 @@ /* - * $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 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ConfigRuleSet.java,v 1.2 2001/12/31 01:42:13 craigmcc Exp $ + * $Revision: 1.2 $ + * $Date: 2001/12/31 01:42:13 $ * * ==================================================================== * @@ -72,7 +72,7 @@ * configuration file (<code>struts-config.xml</code>).</p> * * @author Craig R. McClanahan - * @version $Revision: 1.1 $ $Date: 2001/12/26 23:14:50 $ + * @version $Revision: 1.2 $ $Date: 2001/12/31 01:42:13 $ * @since Struts 1.1 */ @@ -126,6 +126,21 @@ "property", "value"); digester.addObjectCreate + ("struts-config/action-mappings/action/exception", + "org.apache.struts.config.ExceptionConfig", + "className"); + digester.addSetProperties + ("struts-config/action-mappings/action/exception"); + digester.addSetNext + ("struts-config/action-mappings/action/exception", + "addExceptionConfig", + "org.apache.struts.config.ExceptionConfig"); + + digester.addSetProperty + ("struts-config/action-mappings/action/exception/set-property", + "property", "value"); + + digester.addObjectCreate ("struts-config/action-mappings/action/forward", "org.apache.struts.config.ForwardConfig", "className"); @@ -168,6 +183,21 @@ digester.addSetProperty ("struts-config/form-beans/form-bean/set-property", + "property", "value"); + + digester.addObjectCreate + ("struts-config/global-exceptions/exception", + "org.apache.struts.config.ExceptionConfig", + "className"); + digester.addSetProperties + ("struts-config/global-exceptions/exception"); + digester.addSetNext + ("struts-config/global-exceptions/exception", + "addExceptionConfig", + "org.apache.struts.config.ExceptionConfig"); + + digester.addSetProperty + ("struts-config/global-exceptions/exception/set-property", "property", "value"); digester.addObjectCreate 1.1 jakarta-struts/src/share/org/apache/struts/config/ExceptionConfig.java Index: ExceptionConfig.java =================================================================== /* * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ExceptionConfig.java,v 1.1 2001/12/31 01:42:13 craigmcc Exp $ * $Revision: 1.1 $ * $Date: 2001/12/31 01:42:13 $ * * ==================================================================== * * 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 an * <code><exception></code> element from a Struts application * configuration file.</p> * * @author Craig R. McClanahan * @version $Revision: 1.1 $ $Date: 2001/12/31 01:42:13 $ * @since Struts 1.1 */ public class ExceptionConfig { // ------------------------------------------------------------- Properties /** * The fully qualified Java class name of the exception handler class * which should be instantiated to handle this exception. */ protected String handler = "org.apache.struts.action.ExceptionHandler"; public String getHandler() { return (this.handler); } public void setHandler(String handler) { this.handler = handler; } /** * Should we use the inheritance hierarchy of this exception class to * find an appropriate handler? */ protected boolean hierarchical = true; public boolean getHierarchical() { return (this.hierarchical); } public void setHierarchical(boolean hierarchical) { this.hierarchical = hierarchical; } /** * The message resources key specifying the error message * associated with this exception. */ protected String key = null; public String getKey() { return (this.key); } public void setKey(String key) { this.key = key; } /** * The context-relative path of the resource to forward to if this * exception occurs during an <code>Action</code>. */ protected String path = null; public String getPath() { return (this.path); } public void setPath(String path) { this.path = path; } /** * The scope in which we should expose the ActionError for this exception * handler. */ protected String scope = "request"; public String getScope() { return (this.scope); } public void setScope(String scope) { this.scope = scope; } /** * The fully qualified Java class name of the exception that is to be * handled by this handler. */ protected String type = null; public String getType() { return (this.type); } public void setType(String type) { this.type = type; } // --------------------------------------------------------- Public Methods /** * Return a String representation of this object. */ public String toString() { StringBuffer sb = new StringBuffer("ExceptionConfig["); sb.append("type="); sb.append(this.type); sb.append(",key="); sb.append(this.key); sb.append(",path="); sb.append(this.path); sb.append(",scope="); sb.append(this.scope); sb.append("]"); return (sb.toString()); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>