You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/09/20 06:20:23 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/action ActionFormBean.java ActionFormBeans.java Action.java ActionMapping.java ActionMappingBase.java ActionMappings.java ActionServlet.java

craigmcc    00/09/19 21:20:23

  Modified:    src/share/org/apache/struts/action Action.java
                        ActionMapping.java ActionMappingBase.java
                        ActionMappings.java ActionServlet.java
  Added:       src/share/org/apache/struts/action ActionFormBean.java
                        ActionFormBeans.java
  Log:
  Modify ActionServlet to support the new configuration file format.  The
  old format is still supported, but this will be phased out by 1.0 release.
  
  Convert ActionMapping from an interface to a base class, and deprecate
  ActionMappingBase.  This will not cause backwards compatibility problems
  unless applications were implementing ActionMapping themselves.
  
  Deprecate the ActionMapping methods that were used only in the old
  configuration file format, in favor of the properties for the new format.
  
  Support registration of form bean information by logical name, so that
  particular form beans can be more easily shared between actions.
  
  Revision  Changes    Path
  1.4       +13 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Action.java	2000/06/30 00:46:35	1.3
  +++ Action.java	2000/09/20 04:20:21	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.3 2000/06/30 00:46:35 craigmcc Exp $
  - * $Revision: 1.3 $
  - * $Date: 2000/06/30 00:46:35 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Action.java,v 1.4 2000/09/20 04:20:21 craigmcc Exp $
  + * $Revision: 1.4 $
  + * $Date: 2000/09/20 04:20:21 $
    *
    * ====================================================================
    *
  @@ -90,7 +90,7 @@
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.3 $ $Date: 2000/06/30 00:46:35 $
  + * @version $Revision: 1.4 $ $Date: 2000/09/20 04:20:21 $
    */
   
   public interface Action {
  @@ -108,6 +108,15 @@
        */
       public static final String ERROR_KEY =
         "org.apache.struts.action.ERROR";
  +
  +
  +    /**
  +     * The context attributes key under which our ActionFormBeans collection
  +     * are normally stored, unless overridden when initializing our
  +     * ActionServlet.
  +     */
  +    public static final String FORM_BEANS_KEY =
  +        "org.apache.struts.action.FORM_BEANS";
   
   
       /**
  
  
  
  1.7       +511 -46   jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java
  
  Index: ActionMapping.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ActionMapping.java	2000/07/17 00:46:38	1.6
  +++ ActionMapping.java	2000/09/20 04:20:21	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java,v 1.6 2000/07/17 00:46:38 craigmcc Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/07/17 00:46:38 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMapping.java,v 1.7 2000/09/20 04:20:21 craigmcc Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/09/20 04:20:21 $
    *
    * ====================================================================
    *
  @@ -71,170 +71,571 @@
    * class itself, enabling access to this information directly.
    * <p>
    * An <code>ActionMapping</code> has the following minimal set of properties.
  - * Additional properties can be added by an implementation, simply by
  + * Additional properties can be added by a subclass, simply by
    * providing appropriate public "getter" and "setter" methods.
    * <ul>
  - * <li><strong>actionClass</strong> - Fully qualified Java class name of the
  + * <li><em>actionClass</em> - Fully qualified Java class name of the
    *     <code>Action</code> implementation class used by this mapping.  This
  - *     property is required.
  - * <li><strong>formAttribute</strong> - Name of the session attribute under
  + *     property is required.  <em>DEPRECATED - use <code>type</code>
  + *     instead</em>.
  + * <li><strong>attribute</strong> - Name of the request-scope or
  + *     session-scope attribute under which our form bean is accessed, if it
  + *     is other than the bean's specified name.  Replaces the old
  + *     <code>formAttribute</code> property.
  + * <li><em>formAttribute</em> - Name of the session attribute under
    *     which an <code>ActionForm</code> bean is created and/or updated for
    *     this mapping.  If not present, no <code>ActionForm</code> bean will
  - *     be maintained automatically.
  - * <li><strong>formClass</strong> - Fully qualified Java class name of the
  + *     be maintained automatically.  <em>DEPRECATED - use
  + *     <code>attribute</code> instead.</em>
  + * <li><em>formClass</em> - Fully qualified Java class name of the
    *     <code>ActionForm</code> implementation class used by this mapping
  - *     (if any).
  - * <li><strong>formPrefix</strong> - Prefix used to match request parameter
  + *     (if any).  <em>DEPRECATED - use the <code>name</code> attribute
  + *     to look up the corresponding ActionFormBean information</em>.
  + * <li><em>formPrefix</em> - Prefix used to match request parameter
    *     names when populating the properties of our <code>ActionForm</code>
  - *     bean (if any).
  - * <li><strong>formScope</strong> - Scope within which the form bean associated
  + *     bean (if any).  <em>DEPRECATED - use <code>prefix</code>
  + *     instead</em>.
  + * <li><em>formScope</em> - Scope within which the form bean associated
    *     with this mapping will be created or looked for.  Valid values are
  - *     "request" or "session".
  - * <li><strong>formSuffix</strong> - Suffix used to match request parameter
  + *     "request" or "session".  <em>DEPRECATED - use <code>scope</code>
  + *     instead</em>.
  + * <li><em>formSuffix</em> - Suffix used to match request parameter
    *     names when populating the properties of our <code>ActionForm</code>
  - *     bean (if any).
  + *     bean (if any).  <em>DEPRECATED - use <code>suffix</code>
  + *     instead</em>.
  + * <li><strong>forwards</strong> - The set of ActionForwards locally
  + *     associated with this mapping.
  + * <li><strong>input</strong> - Context-relative path of the input form
  + *     to which control should be returned if a validation error is
  + *     encountered.  Replaces the old <code>inputForm</code> property.
  + * <em>inputForm</em> - Context-relative path of the input form
  + *     to which control should be returned if a validation error is
  + *     encountered.  <em>DEPRECATED - use <code>input</code> instead</em>.
  + * <li><strong>mappings</strong> - The <code>ActionMappings</code>
  + *     collection of which we are a part.
  + * <li><strong>name</strong> - Name of the form bean, if any, associated
  + *     with this action.
    * <li><strong>path</strong> - Request URI path used to select this mapping.
    *     If extension mapping is used for the controller servlet, the extension
    *     will be stripped before comparisions against this value are made.
  - *     This parameter is required.
  + * <li><strong>prefix</strong> - Prefix used to match request parameter
  + *     names to form bean property names, if any.  Replaces the old
  + *     <code>formPrefix</code> property.
  + * <li><strong>scope</strong> - Identifier of the scope ("request" or
  + *     "session" within which the form bean, if any, associated with this
  + *     action will be created.  Replaces the old <code>formScope</code>
  + *     attribute.
  + * <li><strong>suffix</strong> - Suffix used to match request parameter
  + *     names when populating the properties of our <code>ActionForm</code>
  + *     bean (if any).  Replaces the old <code>formSuffix</code> property.
  + * <li><strong>type</strong> - Fully qualified Java class name of the
  + *     <code>Action</code> implementation class used by this mapping.
  + *     Replaces the old <code>actionClass</code> property.
  + * <li><strong>unknown</strong> - Set to <code>true</code> if this action
  + *     should be configured as the default for this application, to handle
  + *     all requests not handled by another action.  Only one action can be
  + *     defined as a default within a single application.
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.6 $ $Date: 2000/07/17 00:46:38 $
  + * @version $Revision: 1.7 $ $Date: 2000/09/20 04:20:21 $
    */
  +
  +public class ActionMapping {
  +
  +
  +    // ----------------------------------------------------- Instance Variables
  +
  +
  +    /**
  +     * The name of the request-scope or session-scope attribute under which
  +     * our form bean, if any, will be created.
  +     */
  +    protected String attribute = null;
   
  -public interface ActionMapping {
  +
  +    /**
  +     * The set of ActionForward objects associated with this mapping.
  +     */
  +    protected ActionForwards forwards = new ActionForwards();
  +
  +
  +    /**
  +     * The context-relative path of the input form to which control should
  +     * be returned if a validation error is encountered.
  +     */
  +    protected String input = null;
   
   
  +    /**
  +     * The initialized <code>Action</code> instance for this mapping.
  +     */
  +    protected Action instance = null;
  +
  +
  +    /**
  +     * The <code>ActionMappings</code> collection of which we are a part.
  +     */
  +    protected ActionMappings mappings = null;
  +
  +
  +    /**
  +     * The name of the form bean, if any, associated with this action.
  +     */
  +    protected String name = null;
  +
  +
  +    /**
  +     * The context-relative path of the submitted request, starting with a
  +     * "/" character, and without the filename extension (if any), that is
  +     * mapped to this action.
  +     */
  +    protected String path = null;
  +
  +
  +    /**
  +     * The parameter name prefix used to select parameters for this action.
  +     */
  +    protected String prefix = null;
  +
  +
  +    /**
  +     * The identifier of the scope ("request" or "session") under which the
  +     * form bean associated with this mapping, if any, should be created.
  +     */
  +    protected String scope = "session";
  +
  +
  +    /**
  +     * The parameter name suffix used to select parameters for this action.
  +     */
  +    protected String suffix = null;
  +
  +
  +    /**
  +     * The fully qualified Java class name of the <code>Action</code>
  +     * implementation class to be used to process requests for this mapping.
  +     */
  +    protected String type = null;
  +
  +
  +    /**
  +     * Should this action be the default for this application?
  +     */
  +    protected boolean unknown = false;
  +
  +
       // ------------------------------------------------------------- Properties
   
   
       /**
        * Return the action class name for this mapping.
  +     *
  +     * @deprecated Use getType() instead
        */
  -    public String getActionClass();
  +    public String getActionClass() {
  +
  +        return (getType());
  +
  +    }
   
   
       /**
        * Set the action class name for this mapping.
        *
        * @param actionClass The new action class name
  +     *
  +     * @deprecated Use setType(String) instead
        */
  -    public void setActionClass(String actionClass);
  +    public void setActionClass(String actionClass) {
  +
  +        setType(actionClass);
  +
  +    }
   
   
       /**
  +     * Return the attribute name for our form bean.
  +     */
  +    public String getAttribute() {
  +
  +        if (this.attribute == null)
  +            return (getName());
  +        else
  +            return (this.attribute);
  +
  +    }
  +
  +
  +    /**
  +     * Set the attribute name for our form bean.
  +     *
  +     * @param attribute The new attribute name
  +     */
  +    public void setAttribute(String attribute) {
  +
  +        this.attribute = attribute;
  +
  +    }
  +
  +
  +    /**
        * Return the form session attribute key for this mapping, if any.
  +     *
  +     * @deprecated Use getAttribute() instead
        */
  -    public String getFormAttribute();
  +    public String getFormAttribute() {
   
  +        return (getAttribute());
   
  +    }
  +
  +
       /**
        * Set the form session attribute key for this mapping.
        *
        * @param formAttribute The new form session attribute key
  +     *
  +     * @deprecated Use setAttribute(String) instead
        */
  -    public void setFormAttribute(String formAttribute);
  +    public void setFormAttribute(String formAttribute) {
  +
  +        setAttribute(formAttribute);
   
  +    }
   
  +
       /**
        * Return the form class name for this mapping.
  +     *
  +     * @deprecated Use the bean name to look up the corresponding
  +     *  ActionFormBean instead
        */
  -    public String getFormClass();
  +    public String getFormClass() {
  +
  +        return (getName());
   
  +    }
   
  +
       /**
        * Set the form class name for this mapping.
        *
        * @param formClass The new form class name
  +     *
  +     * @deprecated Modify the corresponding ActionFormBean instead
        */
  -    public void setFormClass(String formClass);
  +    public void setFormClass(String formClass) {
  +
  +        setName(formClass);
  +
  +    }
   
   
       /**
        * Return the form parameter name prefix for this mapping.
  +     *
  +     * @deprecated Use getPrefix() instead
        */
  -    public String getFormPrefix();
  +    public String getFormPrefix() {
  +
  +        return (getPrefix());
  +
  +    }
   
   
       /**
        * Set the form parameter name prefix for this mapping.
        *
        * @param formPrefix The new form prefix
  +     *
  +     * @deprecated Use setPrefix(String) instead
        */
  -    public void setFormPrefix(String formPrefix);
  +    public void setFormPrefix(String formPrefix) {
  +
  +        setPrefix(formPrefix);
   
  +    }
   
  +
       /**
        * Return the scope within which our form bean will be accessed.
  +     *
  +     * @deprecated Use getScope() instead
        */
  -    public String getFormScope();
  +    public String getFormScope() {
   
  +        return (getScope());
   
  +    }
  +
  +
       /**
        * Set the scope within which our form bean will be accessed.
        *
        * @param formScope The new scope ("request" or "session")
  +     *
  +     * @deprecated Use setScope(String) instead
        */
  -    public void setFormScope(String formScope);
  +    public void setFormScope(String formScope) {
   
  +        setScope(formScope);
   
  +    }
  +
  +
       /**
        * Return the form parameter name suffix for this mapping.
  +     *
  +     * @deprecated Use getSuffix() instead
        */
  -    public String getFormSuffix();
  +    public String getFormSuffix() {
  +
  +        return (getSuffix());
   
  +    }
   
  +
       /**
        * Set the form parameter name suffix for this mapping.
        *
        * @param formSuffix The new form suffix
  +     *
  +     * @deprecated Use setSuffix(String) instead
        */
  -    public void setFormSuffix(String formSuffix);
  +    public void setFormSuffix(String formSuffix) {
  +
  +        setSuffix(formSuffix);
   
  +    }
   
  +
       /**
  -     * Return the global forwards collection associated with this mapping.
  +     * Return the input form path for this mapping.
        */
  -    public ActionForwards getForwards();
  +    public String getInput() {
  +
  +        return (this.input);
   
  +    }
   
  +
       /**
  -     * Set the global forwards collection associated with this mapping.
  +     * Set the input form path for this mapping.
        *
  -     * @param forwards The associated forwards collection
  +     * @param input The new input form path
        */
  -    public void setForwards(ActionForwards forwards);
  +    public void setInput(String input) {
  +
  +        this.input = input;
   
  +    }
   
  +
       /**
        * Return the input form URI for this mapping.
  +     *
  +     * @deprecated Use getInput() instead
        */
  -    public String getInputForm();
  +    public String getInputForm() {
  +
  +        return (getInput());
   
  +    }
   
  +
       /**
        * Set the input form URI for this mapping.
        *
        * @param inputForm The new input form URI
  +     *
  +     * @deprecated Use setInput(String) instead
        */
  -    public void setInputForm(String inputForm);
  +    public void setInputForm(String inputForm) {
  +
  +        setInput(inputForm);
  +
  +    }
   
   
       /**
  +     * Return the <code>ActionMappings</code> collection of which
  +     * we are a part.
  +     */
  +    public ActionMappings getMappings() {
  +
  +        return (this.mappings);
  +
  +    }
  +
  +
  +    /**
  +     * Set the <code>ActionMappings</code> collection of which
  +     * we are a part.
  +     *
  +     * @param mappings The new ActionMappings collection
  +     */
  +    public void setMappings(ActionMappings mappings) {
  +
  +        this.mappings = mappings;
  +
  +    }
  +
  +
  +    /**
  +     * Return the name of the form bean for this mapping.
  +     */
  +    public String getName() {
  +
  +        return (this.name);
  +
  +    }
  +
  +
  +    /**
  +     * Set the name of the form bean for this mapping.
  +     *
  +     * @param name The new name
  +     */
  +    public void setName(String name) {
  +
  +        this.name = name;
  +
  +    }
  +
  +
  +    /**
        * Return the request URI path used to select this mapping.
        */
  -    public String getPath();
  +    public String getPath() {
  +
  +        return (this.path);
  +
  +    }
   
   
       /**
        * Set the request URI path used to select this mapping.
        *
        * @param path The new request URI path
  +     */
  +    public void setPath(String path) {
  +
  +        this.path = path;
  +
  +    }
  +
  +
  +    /**
  +     * Return the parameter name prefix for this mapping.
  +     */
  +    public String getPrefix() {
  +
  +        return (this.prefix);
  +
  +    }
  +
  +
  +    /**
  +     * Set the parameter name prefix for this mapping.
  +     *
  +     * @param prefix The new parameter name prefix
  +     */
  +    public void setPrefix(String prefix) {
  +
  +        this.prefix = prefix;
  +
  +    }
  +
  +
  +    /**
  +     * Return the attribute scope for this mapping.
  +     */
  +    public String getScope() {
  +
  +        return (this.scope);
  +
  +    }
  +
  +
  +    /**
  +     * Set the attribute scope for this mapping.
  +     *
  +     * @param scope The new attribute scope
  +     */
  +    public void setScope(String scope) {
  +
  +        this.scope = scope;
  +
  +    }
  +
  +
  +    /**
  +     * Return the parameter name suffix for this mapping.
  +     */
  +    public String getSuffix() {
  +
  +        return (this.suffix);
  +
  +    }
  +
  +
  +    /**
  +     * Set the parameter name suffix for this mapping.
  +     *
  +     * @param suffix The new parameter name suffix
  +     */
  +    public void setSuffix(String suffix) {
  +
  +        this.suffix = suffix;
  +
  +    }
  +
  +
  +    /**
  +     * Return the fully qualified Action class name.
  +     */
  +    public String getType() {
  +
  +        return (this.type);
  +
  +    }
  +
  +
  +    /**
  +     * Set the fully qualified Action class name.
  +     *
  +     * @param type The new class name
  +     */
  +    public void setType(String type) {
  +
  +        this.type = type;
  +
  +    }
  +
  +
  +    /**
  +     * Return the unknown flag for this mapping.
  +     */
  +    public boolean getUnknown() {
  +
  +        return (this.unknown);
  +
  +    }
  +
  +
  +    /**
  +     * Set the unknown flag for this mapping.
  +     *
  +     * @param unknown The new unknown flag
        */
  -    public void setPath(String path);
  +    public void setUnknown(boolean unknown) {
  +
  +        this.unknown = unknown;
   
  +    }
   
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -243,23 +644,59 @@
        *
        * @param forward The ActionForward to be added
        */
  -    public void addForward(ActionForward forward);
  +    public void addForward(ActionForward forward) {
  +
  +        forwards.addForward(forward);
   
  +    }
   
  +
       /**
        * Return an initialized instance of our Action class for this mapping.
        * If instantiation fails for any reason, <code>null</code> is returned.
        */
  -    public Action createActionInstance();
  +    public Action createActionInstance() {
  +
  +        // Return the already instantiated instance (if any)
  +        if (instance != null)
  +            return (instance);
  +
  +        // Instantiate and return a new instance of the Action class
  +        try {
  +            Class clazz = Class.forName(type);
  +            instance = (Action) clazz.newInstance();
  +        } catch (Throwable t) {
  +            instance = null;
  +        }
   
  +        return (instance);
   
  +    }
  +
  +
       /**
        * Create and return an initialized instance of our form class.  If
        * instantiation fails for any reason, <code>null</code> is returned.
        */
  -    public ActionForm createFormInstance();
  +    public ActionForm createFormInstance() {
  +
  +        // Look up the Java class name to be instantiated
  +        ActionFormBean formBean =
  +            getMappings().getServlet().findFormBean(getName());
  +        if (formBean == null)
  +            return (null);
  +
  +        // Instantiate and return an instance of this class
  +        try {
  +            Class clazz = Class.forName(formBean.getType());
  +            return ((ActionForm) clazz.newInstance());
  +        } catch (Throwable t) {
  +            return (null);
  +        }
   
  +    }
   
  +
       /**
        * Return the <code>ActionForward</code> with the specified name,
        * if any; otherwise return <code>null</code>.  If there is no locally
  @@ -269,7 +706,17 @@
        *
        * @param name Name of the forward entry to be returned
        */
  -    public ActionForward findForward(String name);
  +    public ActionForward findForward(String name) {
  +
  +        // First, check our locally defined forwards
  +        ActionForward forward = forwards.findForward(name);
  +        if (forward != null)
  +            return (forward);
  +
  +        // Second, check the globally defined forwards
  +        return (getMappings().getServlet().findForward(name));
  +
  +    }
   
   
       /**
  @@ -277,15 +724,33 @@
        * mapping.  If there are no such forwards, a zero-length array
        * is returned.
        */
  -    public String[] findForwards();
  +    public String[] findForwards() {
   
  +        return (forwards.findForwards());
   
  +    }
  +
  +
       /**
        * Remove a <code>ActionForward</code> associated with this mapping.
        *
        * @param forward The ActionForward to be removed
  +     */
  +    public void removeForward(ActionForward forward) {
  +
  +        forwards.removeForward(forward);
  +
  +    }
  +
  +
  +    /**
  +     * Return a String version of this mapping.
        */
  -    public void removeForward(ActionForward forward);
  +    public String toString() {
  +
  +	return ("ActionMapping[" + path + "]");
  +
  +    }
   
   
   }
  
  
  
  1.8       +7 -401    jakarta-struts/src/share/org/apache/struts/action/ActionMappingBase.java
  
  Index: ActionMappingBase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappingBase.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ActionMappingBase.java	2000/07/17 00:46:38	1.7
  +++ ActionMappingBase.java	2000/09/20 04:20:21	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappingBase.java,v 1.7 2000/07/17 00:46:38 craigmcc Exp $
  - * $Revision: 1.7 $
  - * $Date: 2000/07/17 00:46:38 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappingBase.java,v 1.8 2000/09/20 04:20:21 craigmcc Exp $
  + * $Revision: 1.8 $
  + * $Date: 2000/09/20 04:20:21 $
    *
    * ====================================================================
    *
  @@ -71,407 +71,13 @@
    * only the required properties.  Additional properties can be provided by
    * subclassing this class and adding new "getter" and "setter" methods.
    *
  + * @deprecated Now that ActionMapping is a class, you should use it intead
  + *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.7 $ $Date: 2000/07/17 00:46:38 $
  + * @version $Revision: 1.8 $ $Date: 2000/09/20 04:20:21 $
    */
  -
  -public class ActionMappingBase implements ActionMapping {
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    /**
  -     * The fully qualified Java class name of the <code>Action</code>
  -     * implementation class for this mapping.
  -     */
  -    protected String actionClass = null;
  -
  -
  -    /**
  -     * The initialized instance of the Action class for this mapping.
  -     */
  -    protected Action actionInstance = null;
  -
  -
  -    /**
  -     * The session attribute key under which an instance of our form class
  -     * is stored, if any.
  -     */
  -    protected String formAttribute = null;
  -
  -
  -    /**
  -     * The fully qualified Java class name of the <code>ActionForm</code>
  -     * JavaBean optionally associated with this mapping.
  -     */
  -    protected String formClass = null;
  -
  -
  -    /**
  -     * An instance of the form class itself.
  -     */
  -    protected Class formClassInstance = null;
  -
  -
  -    /**
  -     * The prefix for HTTP request parameter names to use when matching
  -     * against form instance properties (if any).
  -     */
  -    protected String formPrefix = null;
  -
  -
  -    /**
  -     * The scope (request or session) within which the form bean associated
  -     * with this mapping will be created or looked up.
  -     */
  -    protected String formScope = "session";
  -
  -
  -    /**
  -     * The suffix for HTTP request parameter names to use when matching
  -     * against form instance properties (if any).
  -     */
  -    protected String formSuffix = null;
  -
  -
  -    /**
  -     * The set of <code>ActionForward</code> instances associated with
  -     * this <code>ActionMapping</code>.
  -     */
  -    protected ActionForwards forwards = new ActionForwards();
  -
  -
  -    /**
  -     * The global ActionForwards collection associated with this mapping.
  -     */
  -    protected ActionForwards globals = null;
  -
  -
  -    /**
  -     * The input form URI for this mapping.
  -     */
  -    protected String inputForm = null;
  -
  -
  -    /**
  -     * The request URI path used to select this particular mapping.
  -     */
  -    protected String path = null;
  -
  -
  -    // ------------------------------------------------------------- Properties
  -
  -
  -    /**
  -     * Return the action class name for this mapping.
  -     */
  -    public String getActionClass() {
  -
  -	return (this.actionClass);
  -
  -    }
  -
  -
  -    /**
  -     * Set the action class name for this mapping.
  -     *
  -     * @param actionClass The new action class name
  -     */
  -    public void setActionClass(String actionClass) {
  -
  -	this.actionClass = actionClass;
  -	this.actionInstance = null;
  -
  -    }
  -
  -
  -    /**
  -     * Return the form session attribute key for this mapping.
  -     */
  -    public String getFormAttribute() {
  -
  -	return (this.formAttribute);
  -
  -    }
  -
  -
  -    /**
  -     * Set the form session attribute key for this mapping.
  -     *
  -     * @param formAttribute The new form session attribute key
  -     */
  -    public void setFormAttribute(String formAttribute) {
  -
  -	this.formAttribute = formAttribute;
  -
  -    }
  -
  -
  -    /**
  -     * Return the form class name for this mapping.
  -     */
  -    public String getFormClass() {
  -
  -	return (this.formClass);
  -
  -    }
  -
  -
  -    /**
  -     * Set the form class name for this mapping.
  -     *
  -     * @param formClass The new form class name
  -     */
  -    public void setFormClass(String formClass) {
  -
  -	this.formClass = formClass;
  -
  -    }
  -
  -
  -    /**
  -     * Return the form prefix for this mapping.
  -     */
  -    public String getFormPrefix() {
  -
  -	return (this.formPrefix);
  -
  -    }
  -
  -
  -    /**
  -     * Set the form prefix for this mapping.
  -     *
  -     * @param formPrefix The new form prefix
  -     */
  -    public void setFormPrefix(String formPrefix) {
  -
  -	this.formPrefix = formPrefix;
  -
  -    }
  -
  -
  -    /**
  -     * Return the scope within which our form bean will be accessed.
  -     */
  -    public String getFormScope() {
  -
  -	return (this.formScope);
  -
  -    }
  -
  -
  -    /**
  -     * Set the scope within which our form bean will be accessed.
  -     *
  -     * @param formScope The new scope ("request" or "session")
  -     */
  -    public void setFormScope(String formScope) {
  -
  -	this.formScope = formScope;
  -
  -    }
  -
  -
  -    /**
  -     * Return the form suffix for this mapping.
  -     */
  -    public String getFormSuffix() {
  -
  -	return (this.formSuffix);
  -
  -    }
  -
  -
  -    /**
  -     * Set the form suffix for this mapping.
  -     *
  -     * @param formSuffix The new form suffix
  -     */
  -    public void setFormSuffix(String formSuffix) {
  -
  -	this.formSuffix = formSuffix;
  -
  -    }
  -
  -
  -    /**
  -     * Return the global forwards collection associated with this mapping.
  -     */
  -    public ActionForwards getForwards() {
  -
  -	return (this.globals);
  -
  -    }
  -
  -
  -    /**
  -     * Set the global forwards collection associated with this mapping.
  -     *
  -     * @param forwards The associated forwards collection
  -     */
  -    public void setForwards(ActionForwards forwards) {
  -
  -	this.globals = forwards;
  -
  -    }
  -
  -
  -    /**
  -     * Return the input form URI for this mapping.
  -     */
  -    public String getInputForm() {
  -
  -	return (this.inputForm);
  -
  -    }
  -
  -
  -    /**
  -     * Set the input form URI for this mapping.
  -     *
  -     * @param inputForm The new input form URI
  -     */
  -    public void setInputForm(String inputForm) {
  -
  -	this.inputForm = inputForm;
  -
  -    }
  -
  -
  -    /**
  -     * Return the request URI path used to select this mapping.
  -     */
  -    public String getPath() {
  -
  -	return (this.path);
  -
  -    }
  -
  -
  -    /**
  -     * Set the request URI path used to select this mapping.
  -     *
  -     * @param path The new request URI path
  -     */
  -    public void setPath(String path) {
  -
  -	this.path = path;
  -
  -    }
  -
  -
  -    // --------------------------------------------------------- Public Methods
  -
  -
  -    /**
  -     * Add a new <code>ActionForward</code> associated with this mapping.
  -     *
  -     * @param forward The ActionForward to be added
  -     */
  -    public void addForward(ActionForward forward) {
  -
  -	forwards.addForward(forward);
  -
  -    }
  -
  -
  -    /**
  -     * Return an initialized instance of our Action class for this mapping.
  -     */
  -    public Action createActionInstance() {
  -
  -	// Return the already instantiated instance (if any)
  -	if (actionInstance != null)
  -	    return (actionInstance);
  -
  -	// Instantiate and return a new instance of the action class
  -	try {
  -	    Class actionClassInstance = Class.forName(actionClass);
  -	    actionInstance = (Action) actionClassInstance.newInstance();
  -	} catch (Throwable throwable) {
  -	    actionInstance = null;
  -	}
  -	return (actionInstance);
  -
  -    }
  -
  -
  -    /**
  -     * Create and return an initialized instance of our form class.
  -     */
  -    public ActionForm createFormInstance() {
  -
  -	ActionForm formInstance = null;
  -	try {
  -	    if (formClassInstance == null)
  -		formClassInstance = Class.forName(formClass);
  -	    formInstance = (ActionForm) formClassInstance.newInstance();
  -	} catch (Throwable throwable) {
  -	    System.out.println("createFormInstance:  " + throwable);
  -	    throwable.printStackTrace(System.out);
  -	    formInstance = null;
  -	}
  -	return (formInstance);
  -
  -    }
  -
  -
  -    /**
  -     * Return the <code>ActionForward</code> with the specified name,
  -     * if any; otherwise return <code>null</code>.  If there is no locally
  -     * defined forwarding for the specified name, but a global forwards
  -     * collection has been associated with this mapping, the global
  -     * collection will also be searched before returning.
  -     *
  -     * @param name Name of the forward entry to be returned
  -     */
  -    public ActionForward findForward(String name) {
  -
  -	ActionForward forward = forwards.findForward(name);
  -	if ((forward == null) && (globals != null))
  -	    forward = globals.findForward(name);
  -	return (forward);
  -
  -    }
  -
  -
  -    /**
  -     * Return the logical names of all locally defined forwards for this
  -     * mapping.  If there are no such forwards, a zero-length array
  -     * is returned.
  -     */
  -    public String[] findForwards() {
  -
  -	return (forwards.findForwards());
  -
  -    }
  -
  -
  -    /**
  -     * Remove a <code>ActionForward</code> associated with this mapping.
  -     *
  -     * @param forward The ActionForward to be removed
  -     */
  -    public void removeForward(ActionForward forward) {
  -
  -	forwards.removeForward(forward);
  -
  -    }
  -
  -
  -    /**
  -     * Return a String version of this mapping.
  -     */
  -    public String toString() {
  -
  -	return ("ActionMapping[" + path + "]");
  -
  -    }
  -
   
  -    // ------------------------------------------------------ Protected Methods
  +public class ActionMappingBase extends ActionMapping {
   
   
   }
  
  
  
  1.3       +68 -5     jakarta-struts/src/share/org/apache/struts/action/ActionMappings.java
  
  Index: ActionMappings.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappings.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ActionMappings.java	2000/06/30 01:19:32	1.2
  +++ ActionMappings.java	2000/09/20 04:20:21	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappings.java,v 1.2 2000/06/30 01:19:32 craigmcc Exp $
  - * $Revision: 1.2 $
  - * $Date: 2000/06/30 01:19:32 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionMappings.java,v 1.3 2000/09/20 04:20:21 craigmcc Exp $
  + * $Revision: 1.3 $
  + * $Date: 2000/09/20 04:20:21 $
    *
    * ====================================================================
    *
  @@ -73,7 +73,7 @@
    * administered and searched, while hiding the internal implementation.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.2 $ $Date: 2000/06/30 01:19:32 $
  + * @version $Revision: 1.3 $ $Date: 2000/09/20 04:20:21 $
    */
   
   public class ActionMappings {
  @@ -85,9 +85,70 @@
       /**
        * The collection of ActionMapping instances, keyed by request path.
        */
  -    private Hashtable mappings = new Hashtable();
  +    protected Hashtable mappings = new Hashtable();
   
   
  +    /**
  +     * The ActionServlet instance of our owning application.
  +     */
  +    protected ActionServlet servlet = null;
  +
  +
  +    /**
  +     * The ActionMapping that should handle unknown request paths, if any.
  +     */
  +    protected ActionMapping unknown = null;
  +
  +
  +    // ------------------------------------------------------------- Properties
  +
  +
  +    /**
  +     * Return the Action that should handle unknown request paths, if any.
  +     */
  +    public ActionMapping getUnknown() {
  +
  +        if (unknown != null)
  +            return (unknown);
  +
  +        String paths[] = findMappings();
  +        for (int i = 0; i < paths.length; i++) {
  +            ActionMapping mapping = findMapping(paths[i]);
  +            if (mapping.getUnknown()) {
  +                unknown = mapping;
  +                return (mapping);
  +            }
  +        }
  +
  +
  +        return (null);
  +
  +    }
  +
  +
  +    /**
  +     * Return the <code>ActionServlet</code> instance of our owning
  +     * application.
  +     */
  +    public ActionServlet getServlet() {
  +
  +        return (this.servlet);
  +
  +    }
  +
  +
  +    /**
  +     * Set the <code>ActionServlet</code> instance of our owning application.
  +     *
  +     * @param servlet The new servlet instance
  +     */
  +    public void setServlet(ActionServlet servlet) {
  +
  +        this.servlet = servlet;
  +
  +    }
  +
  +
       // --------------------------------------------------------- Public Methods
   
   
  @@ -99,6 +160,7 @@
       public void addMapping(ActionMapping mapping) {
   
   	mappings.put(mapping.getPath(), mapping);
  +        mapping.setMappings(this);
   
       }
   
  @@ -141,6 +203,7 @@
       public void removeMapping(ActionMapping mapping) {
   
   	mappings.remove(mapping.getPath());
  +        mapping.setMappings(null);
   
       }
   
  
  
  
  1.20      +310 -70   jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java
  
  Index: ActionServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- ActionServlet.java	2000/08/26 19:52:28	1.19
  +++ ActionServlet.java	2000/09/20 04:20:22	1.20
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.19 2000/08/26 19:52:28 craigmcc Exp $
  - * $Revision: 1.19 $
  - * $Date: 2000/08/26 19:52:28 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionServlet.java,v 1.20 2000/09/20 04:20:22 craigmcc Exp $
  + * $Revision: 1.20 $
  + * $Date: 2000/09/20 04:20:22 $
    *
    * ====================================================================
    *
  @@ -65,6 +65,7 @@
   
   import java.io.InputStream;
   import java.io.IOException;
  +import java.net.URL;
   import java.util.Hashtable;
   import java.util.Locale;
   import java.util.MissingResourceException;
  @@ -147,7 +148,7 @@
    *     containing our configuration information.  [/WEB-INF/action.xml]
    * <li><strong>debug</strong> - The debugging detail level for this
    *     servlet, which controls how much information is logged.  [0]
  - * <li><strong>digester</strong> - The debugging detail level for the Digester
  + * <li><strong>detail</strong> - The debugging detail level for the Digester
    *     we utilize in <code>initMapping()</code>, which logs to System.out
    *     instead of the servlet log.  [0]
    * <li><strong>forward</strong> - The Java class name of the ActionForward
  @@ -164,16 +165,16 @@
    *         <code>true</code>.
    *     </ul>
    * <li><strong>mapping</strong> - The Java class name of the ActionMapping
  - *     implementation to use [org.apache.struts.action.ActionMappingBase].
  + *     implementation to use [org.apache.struts.action.ActionMapping].
    *     Two convenient classes you may wish to use are:
    *     <ul>
    *     <li><em>org.apache.struts.action.RequestActionMapping</em> - Subclass
  - *         of <code>org.apache.struts.action.ActionMappingBase</code> that
  + *         of <code>org.apache.struts.action.ActionMapping</code> that
    *         defaults the <code>formScope</code> property to "request".
    *     <li><em>org.apache.struts.action.SessionActionMapping</em> - Subclass
  - *         of <code>org.apache.struts.action.ActionMappingBase</code> that
  + *         of <code>org.apache.struts.action.ActionMapping</code> that
    *         defaults the <code>formScope</code> property to "session".  (Same
  - *         as the ActionMappingBase default value).
  + *         as the ActionMapping default value).
    *     </ul>
    * <li><strong>nocache</strong> - If set to <code>true</code>, add HTTP headers
    *     to every response intended to defeat browser caching of any response we
  @@ -182,10 +183,12 @@
    *     resources to return <code>null</code> if an unknown message key is used.
    *     Otherwise, an error message including the offending message key will
    *     be returned.  [true]
  + * <li><strong>validate</strong> - Are we using the new configuration file
  + *     format?  [false]
    * </ul>
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.19 $ $Date: 2000/08/26 19:52:28 $
  + * @version $Revision: 1.20 $ $Date: 2000/09/20 04:20:22 $
    */
   
   public class ActionServlet
  @@ -214,6 +217,19 @@
   
   
       /**
  +     * The Java class name of the ActionFormBean implementation class to use.
  +     */
  +    protected String formBeanClass =
  +        "org.apache.struts.action.ActionFormBean";
  +
  +
  +    /**
  +     * The global ActionFormBean collection for this controller.
  +     */
  +    protected ActionFormBeans formBeans = new ActionFormBeans();
  +
  +
  +    /**
        * The Java class name of the ActionForward implementation class to use.
        */
       protected String forwardClass =
  @@ -242,7 +258,7 @@
        * The Java class name of our ActionMapping implementation class.
        */
       protected String mappingClass =
  -	"org.apache.struts.action.ActionMappingBase";
  +	"org.apache.struts.action.ActionMapping";
   
   
       /**
  @@ -257,6 +273,23 @@
       protected boolean nocache = false;
   
   
  +    /**
  +     * The set of public identifiers, and corresponding resource names, for
  +     * the versions of the configuration file DTD that we know about.  There
  +     * <strong>MUST</strong> be an even number of Strings in this list!
  +     */
  +    protected String registrations[] = {
  +        "-//Apache Software Foundation//DTD Struts Configuration 1.0//EN",
  +        "/org/apache/struts/resources/struts-config_1_0.dtd",
  +    };
  +
  +
  +    /**
  +     * Are we using the new configuration file format?
  +     */
  +    protected boolean validate = false;
  +
  +
       // ---------------------------------------------------- HttpServlet Methods
   
   
  @@ -338,6 +371,81 @@
   
   
       /**
  +     * Register a form bean definition to the set configured for this servlet.
  +     *
  +     * @param formBean The form bean definition to be added
  +     */
  +    public void addFormBean(ActionFormBean formBean) {
  +
  +        formBeans.addFormBean(formBean);
  +
  +    }
  +
  +
  +    /**
  +     * Register a logical forwarding to the set configured for this servlet.
  +     *
  +     * @param forward The forwarding to be added
  +     */
  +    public void addForward(ActionForward forward) {
  +
  +	forwards.addForward(forward);
  +
  +    }
  +
  +
  +    /**
  +     * Register a mapping to the set configured for this servlet.
  +     *
  +     * @param mapping The mapping to be added
  +     */
  +    public void addMapping(ActionMapping mapping) {
  +
  +	mappings.addMapping(mapping);
  +
  +    }
  +
  +
  +    /**
  +     * Return the form bean definition associated with the specified
  +     * logical name, if any; otherwise return <code>null</code>.
  +     *
  +     * @param name Logical name of the requested form bean definition
  +     */
  +    public ActionFormBean findFormBean(String name) {
  +
  +        return (formBeans.findFormBean(name));
  +
  +    }
  +
  +
  +    /**
  +     * Return the forwarding associated with the specified logical name,
  +     * if any; otherwise return <code>null</code>.
  +     *
  +     * @param name Logical name of the requested forwarding
  +     */
  +    public ActionForward findForward(String name) {
  +
  +	return (forwards.findForward(name));
  +
  +    }
  +
  +
  +    /**
  +     * Return the mapping associated with the specified request path, if any;
  +     * otherwise return <code>null</code>.
  +     *
  +     * @param path Request path for which a mapping is requested
  +     */
  +    public ActionMapping findMapping(String path) {
  +
  +	return (mappings.findMapping(path));
  +
  +    }
  +
  +
  +    /**
        * Return the debugging detail level for this servlet.
        */
       public int getDebug() {
  @@ -349,6 +457,17 @@
   
       /**
        * Return the Java class name of the class used to instantiate
  +     * <code>ActionFormBean</code> objects.
  +     */
  +    public String getFormBeanClass() {
  +
  +        return (this.formBeanClass);
  +
  +    }
  +
  +
  +    /**
  +     * Return the Java class name of the class used to instantiate
        * <code>ActionForward</code> objects.
        */
       public String getForwardClass() {
  @@ -380,75 +499,77 @@
   
   
       /**
  -     * Register a logical forwarding to the set configured for this servlet.
  +     * Deregister a form bean definition from the set configured for
  +     * this servlet.
        *
  -     * @param forward The forwarding to be added
  +     * @param formBean The form bean definition to be deregistered
        */
  -    public void addForward(ActionForward forward) {
  +    public void removeFormBean(ActionFormBean formBean) {
   
  -	forwards.addForward(forward);
  +        formBeans.removeFormBean(formBean);
   
       }
   
   
       /**
  -     * Register a mapping to the set configured for this servlet.
  +     * Deregister a forwarding from the set configured for this servlet.
        *
  -     * @param mapping The mapping to be added
  +     * @param forward The forwarding to be deregistered
        */
  -    public void addMapping(ActionMapping mapping) {
  +    public void removeForward(ActionForward forward) {
   
  -	mappings.addMapping(mapping);
  +	forwards.removeForward(forward);
   
       }
   
   
       /**
  -     * Return the forwarding associated with the specified logical name,
  -     * if any; otherwise return <code>null</code>.
  +     * Deregister a mapping from the set configured for this servlet.
        *
  -     * @param name Logical name of the requested forwarding
  +     * @param mapping The mapping to be deregistered
        */
  -    public ActionForward findForward(String name) {
  +    public void removeMapping(ActionMapping mapping) {
   
  -	return (forwards.findForward(name));
  +	mappings.removeMapping(mapping);
   
       }
   
   
       /**
  -     * Return the mapping associated with the specified request path, if any;
  -     * otherwise return <code>null</code>.
  +     * Set the Java class name of the class used to instantiate
  +     * <code>ActionFormBean</code> objects.
        *
  -     * @param path Request path for which a mapping is requested
  +     * @param formBeanClass The new class name
        */
  -    public ActionMapping findMapping(String path) {
  +    public void setFormBeanClass(String formBeanClass) {
   
  -	return (mappings.findMapping(path));
  +        this.formBeanClass = formBeanClass;
   
       }
   
   
       /**
  -     * Deregister a forwarding from the set configured for this servlet.
  +     * Set the Java class name of the class used to instantiate
  +     * <code>ActionForward</code> objects.
        *
  -     * @param forward The forwarding to be deregistered
  +     * @param forwardClass The new class name
        */
  -    public void removeForward(ActionForward forward) {
  +    public void setForwardClass(String forwardClass) {
   
  -	forwards.removeForward(forward);
  +        this.forwardClass = forwardClass;
   
       }
   
   
       /**
  -     * Deregister a mapping from the set configured for this servlet.
  +     * Set the Java class name of the class used to instantiate
  +     * <code>ActionMapping</code> objects.
        *
  -     * @param mapping The mapping to be deregistered
  +     * @param mappingClass The new class name
        */
  -    public void removeMapping(ActionMapping mapping) {
  +    public void setMappingClass(String mappingClass) {
   
  -	mappings.removeMapping(mapping);
  +        this.mappingClass = mappingClass;
   
       }
   
  @@ -527,6 +648,120 @@
   
   
       /**
  +     * Construct and return a digester that uses the new configuration
  +     * file format.
  +     */
  +    protected Digester initDigester(int detail) {
  +
  +	// Initialize a new Digester instance
  +	Digester digester = new Digester();
  +	digester.push(this);
  +	digester.setDebug(detail);
  +	digester.setValidating(true);
  +
  +	// Register our local copy of the DTDs that we can find
  +        for (int i = 0; i < registrations.length; i += 2) {
  +            URL url = this.getClass().getResource(registrations[i+1]);
  +            if (url != null)
  +                digester.register(registrations[i], url.toString());
  +        }
  +
  +	// Configure the processing rules
  +
  +        // FIXME "struts-config/action-mappings" type attribute
  +
  +        digester.addObjectCreate("struts-config/action-mappings/action",
  +                                 mappingClass, "className");
  +        digester.addSetProperties("struts-config/action-mappings/action");
  +        digester.addSetNext("struts-config/action-mappings/action",
  +                            "addMapping",
  +                            "org.apache.struts.action.ActionMapping");
  +
  +        digester.addObjectCreate
  +            ("struts-config/action-mappings/action/forward",
  +             forwardClass, "className");
  +        digester.addSetProperties
  +            ("struts-config/action-mappings/action/forward");
  +        digester.addSetNext("struts-config/action-mappings/action/forward",
  +                            "addForward",
  +                            "org.apache.struts.action.ActionForward");
  +
  +        digester.addSetProperty
  +            ("struts-config/action-mappings/action/forward/set-property",
  +             "property", "value");
  +
  +        digester.addSetProperty
  +            ("struts-config/action-mappings/action/set-property",
  +             "property", "value");
  +
  +        // FIXME "struts-config/form-beans" type attribute
  +
  +        digester.addObjectCreate("struts-config/form-beans/form-bean",
  +                                 formBeanClass, "className");
  +        digester.addSetProperties("struts-config/form-beans/form-bean");
  +        digester.addSetNext("struts-config/form-beans/form-bean",
  +                            "addFormBean",
  +                            "org.apache.struts.action.ActionFormBean");
  +
  +        // FIXME "struts-config/global-forwards" type attribute
  +
  +        digester.addObjectCreate("struts-config/global-forwards/forward",
  +                                 forwardClass, "className");
  +        digester.addSetProperties("struts-config/global-forwards/forward");
  +        digester.addSetNext("struts-config/global-forwards/forward",
  +                            "addForward",
  +                            "org.apache.struts.action.ActionForward");
  +
  +        digester.addSetProperty
  +            ("struts-config/global-forwards/forward/set-property",
  +             "property", "value");
  +
  +	return (digester);
  +
  +    }
  +
  +
  +    /**
  +     * Construct and return a digester that uses the old configuration
  +     * file format.
  +     */
  +    protected Digester initDigesterOld(int detail) {
  +
  +	// Initialize a new Digester instance
  +	Digester digester = new Digester();
  +	digester.push(this);
  +	digester.setDebug(detail);
  +	digester.setValidating(false);
  +
  +	// Configure the processing rules
  +	digester.addObjectCreate("action-mappings/action", mappingClass,
  +				 "className");
  +	digester.addSetProperties("action-mappings/action");
  +	digester.addSetNext("action-mappings/action", "addMapping",
  +			    "org.apache.struts.action.ActionMapping");
  +	digester.addObjectCreate("action-mappings/action/forward",
  +				 forwardClass, "className");
  +	digester.addSetProperties("action-mappings/action/forward");
  +	digester.addSetNext("action-mappings/action/forward", "addForward",
  +			    "org.apache.struts.action.ActionForward");
  +	digester.addSetProperty("action-mappings/action/forward/property",
  +				"name", "value");
  +	digester.addSetProperty("action-mappings/action/property",
  +				"name", "value");
  +	digester.addObjectCreate("action-mappings/forward",
  +				 forwardClass, "className");
  +	digester.addSetProperties("action-mappings/forward");
  +	digester.addSetNext("action-mappings/forward", "addForward",
  +			    "org.apache.struts.action.ActionForward");
  +	digester.addSetProperty("action-mappings/forward/property",
  +				"name", "value");
  +
  +	return (digester);
  +
  +    }
  +
  +
  +    /**
        * Initialize our internal MessageResources bundle.
        *
        * @exception ServletException if we cannot initialize these resources
  @@ -555,15 +790,28 @@
   
   	String value = null;
   
  +        // Link our mappings collection to this servlet instance
  +        mappings.setServlet(this);
  +
   	// Initialize the debugging detail level we will use
   	int detail;
   	try {
  -	    value = getServletConfig().getInitParameter("digester");
  +	    value = getServletConfig().getInitParameter("detail");
   	    detail = Integer.parseInt(value);
   	} catch (Throwable t) {
   	    detail = 0;
   	}
   
  +	// Initialize the format selector flag
  +	value = getServletConfig().getInitParameter("validate");
  +	if (value != null) {
  +	    if (value.equalsIgnoreCase("true") ||
  +	        value.equalsIgnoreCase("yes"))
  +	        validate = true;
  +	    else
  +	        validate = false;
  +	}
  +
   	// Initialize the name of our ActionForward implementation class
   	value = getServletConfig().getInitParameter("forward");
   	if (value != null)
  @@ -588,31 +836,11 @@
   		(internal.getMessage("configMissing", config));
   
   	// Build a digester to process our configuration resource
  -	Digester digester = new Digester();
  -	digester.push(this);
  -	digester.setDebug(detail);
  -	digester.setValidating(false);
  -	digester.addObjectCreate("action-mappings/action", mappingClass,
  -				 "className");
  -	digester.addSetProperties("action-mappings/action");
  -	digester.addSetNext("action-mappings/action", "addMapping",
  -			    "org.apache.struts.action.ActionMapping");
  -	digester.addObjectCreate("action-mappings/action/forward",
  -				 forwardClass, "className");
  -	digester.addSetProperties("action-mappings/action/forward");
  -	digester.addSetNext("action-mappings/action/forward", "addForward",
  -			    "org.apache.struts.action.ActionForward");
  -	digester.addSetProperty("action-mappings/action/forward/property",
  -				"name", "value");
  -	digester.addSetProperty("action-mappings/action/property",
  -				"name", "value");
  -	digester.addObjectCreate("action-mappings/forward",
  -				 forwardClass, "className");
  -	digester.addSetProperties("action-mappings/forward");
  -	digester.addSetNext("action-mappings/forward", "addForward",
  -			    "org.apache.struts.action.ActionForward");
  -	digester.addSetProperty("action-mappings/forward/property",
  -				"name", "value");
  +	Digester digester = null;
  +	if (validate)
  +	    digester = initDigester(detail);
  +	else
  +	    digester = initDigesterOld(detail);
   
   	// Parse the input stream to configure our mappings
   	try {
  @@ -623,12 +851,20 @@
   		(internal.getMessage("configParse", config), e);
   	}
   
  -	// Connect all of our defined mappings to the global forwards
  -	String paths[] = mappings.findMappings();
  -	for (int i = 0; i < paths.length; i++) {
  -	    ActionMapping mapping = mappings.findMapping(paths[i]);
  -	    mapping.setForwards(forwards);
  -	}
  +        // Transitional support for old format
  +        if (!validate) {
  +            String paths[] = mappings.findMappings();
  +            for (int i = 0; i < paths.length; i++) {
  +                String name =
  +                    mappings.findMapping(paths[i]).getName();
  +                if (name == null)
  +                    continue;
  +                ActionFormBean formBean = new ActionFormBean();
  +                formBean.setName(name);
  +                formBean.setType(name);
  +                formBeans.addFormBean(formBean);
  +            }
  +        }
   
       }
   
  @@ -647,7 +883,8 @@
   	    "yes".equalsIgnoreCase(value))
   	    nocache = true;
   
  -	// Publish our ActionForwards and ActionMappings collections
  +	// Publish our internal collections as necessary
  +        getServletContext().setAttribute(Action.FORM_BEANS_KEY, formBeans);
   	getServletContext().setAttribute(Action.FORWARDS_KEY, forwards);
   	getServletContext().setAttribute(Action.MAPPINGS_KEY, mappings);
   
  @@ -815,7 +1052,10 @@
        */
       protected ActionMapping processMapping(String path) {
   
  -	return (findMapping(path));
  +        ActionMapping mapping = findMapping(path);
  +        if (mapping == null)
  +            mapping = mappings.getUnknown();
  +        return (mapping);
   
       }
   
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/action/ActionFormBean.java
  
  Index: ActionFormBean.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionFormBean.java,v 1.1 2000/09/20 04:20:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/09/20 04:20:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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 apache@apache.org.
   *
   * 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.action;
  
  
  /**
   * An <strong>ActionFormBean</strong> is the definition of a form bean that
   * is loaded from a <code>&lt;form-bean&gt;</code> element in the Struts
   * configuration file.  It can be subclassed as necessary to add additional
   * properties.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/09/20 04:20:21 $
   */
  
  public class ActionFormBean {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The bean name of this action form bean.
       */
      private String name = null;
  
  
      /**
       * The Java class name of this action form bean.
       */
      private String type = null;
  
  
      // ------------------------------------------------------------- Properties
  
  
      /**
       * Return the bean name of this action form bean.
       */
      public String getName() {
  
  	return (this.name);
  
      }
  
  
      /**
       * Set the bean name of this action form bean.
       *
       * @param name The new bean name
       */
      public void setName(String name) {
  
  	this.name = name;
  
      }
  
  
      /**
       * Return the Java class name of this action form bean.
       */
      public String getType() {
  
  	return (this.type);
  
      }
  
  
      /**
       * Set the Java class name of this action form bean.
       *
       * @param type The new Java class name
       */
      public void setType(String type) {
  
  	this.type = type;
  
      }
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Return a string representation of this object.
       */
      public String toString() {
  
          StringBuffer sb = new StringBuffer("ActionFormBean[");
          sb.append(this.name);
          sb.append(']');
          return (sb.toString());
  
      }
  
  
  }
  
  
  
  1.1                  jakarta-struts/src/share/org/apache/struts/action/ActionFormBeans.java
  
  Index: ActionFormBeans.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/ActionFormBeans.java,v 1.1 2000/09/20 04:20:21 craigmcc Exp $
   * $Revision: 1.1 $
   * $Date: 2000/09/20 04:20:21 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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 apache@apache.org.
   *
   * 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.action;
  
  
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Vector;
  
  
  /**
   * Encapsulate a collection of ActionFormBean objects that can be
   * administered and searched, while hiding the internal implementation.
   *
   * @author Craig R. McClanahan
   * @version $Revision: 1.1 $ $Date: 2000/09/20 04:20:21 $
   */
  
  public class ActionFormBeans {
  
  
      // ----------------------------------------------------- Instance Variables
  
  
      /**
       * The collection of ActionFormBean instances, keyed by name.
       */
      private Hashtable formBeans = new Hashtable();
  
  
      // --------------------------------------------------------- Public Methods
  
  
      /**
       * Register a form bean to the set configured for this servlet.
       *
       * @param formBean The formBean to be added
       */
      public void addFormBean(ActionFormBean formBean) {
  
  	formBeans.put(formBean.getName(), formBean);
  
      }
  
  
      /**
       * Return the formBean associated with the specified logical name,
       * if any; otherwise return <code>null</code>.
       *
       * @param name Logical name of the desired form bean
       */
      public ActionFormBean findFormBean(String name) {
  
  	return ((ActionFormBean) formBeans.get(name));
  
      }
  
  
      /**
       * Return the set of names for form beans defined in this collection.
       * If there are no such formBeans, a zero-length array is returned.
       */
      public String[] findFormBeans() {
  
  	Vector names = new Vector();
  	Enumeration keys = formBeans.keys();
  	while (keys.hasMoreElements())
  	    names.addElement(keys.nextElement());
  	String results[] = new String[names.size()];
  	names.copyInto(results);
  	return (results);
  
      }
  
  
      /**
       * Deregister a formBean from the set configured for this servlet.
       *
       * @param formBean The formBean to be deregistered
       */
      public void removeFormBean(ActionFormBean formBean) {
  
  	formBeans.remove(formBean.getName());
  
      }
  
  
  }