You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2004/04/15 01:46:15 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/config/impl ModuleConfigImpl.java

husted      2004/04/14 16:46:15

  Modified:    src/share/org/apache/struts/config ConfigRuleSet.java
                        ModuleConfig.java
               src/share/org/apache/struts/config/impl
                        ModuleConfigImpl.java
  Log:
  Apply #28330 "Configure "regular" ActionForward class" reported by Niall Pemberton.
  
  Revision  Changes    Path
  1.19      +45 -13    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ConfigRuleSet.java	14 Mar 2004 06:23:47 -0000	1.18
  +++ ConfigRuleSet.java	14 Apr 2004 23:46:15 -0000	1.19
  @@ -105,11 +105,9 @@
               ("struts-config/action-mappings/action/exception/set-property",
                "property", "value");
   
  -        digester.addObjectCreate
  +        digester.addFactoryCreate
               ("struts-config/action-mappings/action/forward",
  -             //             "org.apache.struts.config.ForwardConfig",
  -             "org.apache.struts.action.ActionForward",
  -             "className");
  +             new ActionForwardFactory());
           digester.addSetProperties
               ("struts-config/action-mappings/action/forward");
           digester.addSetNext
  @@ -186,7 +184,7 @@
   
           digester.addRule
               ("struts-config/global-forwards",
  -             new SetGlobalForwardClassRule());
  +             new SetActionForwardClassRule());
   
           digester.addFactoryCreate
               ("struts-config/global-forwards/forward",
  @@ -394,9 +392,9 @@
    * instances. The value is set on the object on the top of the stack, which
    * must be a <code>org.apache.struts.config.ModuleConfig</code>.
    */
  -final class SetGlobalForwardClassRule extends Rule {
  +final class SetActionForwardClassRule extends Rule {
   
  -    public SetGlobalForwardClassRule() {
  +    public SetActionForwardClassRule() {
           super();
       }
   
  @@ -404,7 +402,7 @@
           String className = attributes.getValue("type");
           if (className != null) {
               ModuleConfig mc = (ModuleConfig) digester.peek();
  -            mc.setGlobalForwardClass(className);
  +            mc.setActionForwardClass(className);
           }
       }
   
  @@ -426,7 +424,7 @@
           String className = attributes.getValue("className");
           if (className == null) {
               ModuleConfig mc = (ModuleConfig) digester.peek();
  -            className = mc.getGlobalForwardClass();
  +            className = mc.getActionForwardClass();
           }
   
           // Instantiate the new object and return it
  @@ -440,6 +438,40 @@
           }
   
           return globalForward;
  +    }
  +
  +}
  +
  +
  +/**
  + * An object creation factory which creates action forward instances, taking
  + * into account the default class name, which may have been specified on the
  + * parent element and which is made available through the object on the top
  + * of the stack, which must be a
  + * <code>org.apache.struts.config.ModuleConfig</code>.
  + */
  +final class ActionForwardFactory extends AbstractObjectCreationFactory {
  +
  +    public Object createObject(Attributes attributes) {
  +
  +        // Identify the name of the class to instantiate
  +        String className = attributes.getValue("className");
  +        if (className == null) {
  +            ModuleConfig mc = (ModuleConfig) digester.peek(1);
  +            className = mc.getActionForwardClass();
  +        }
  +
  +        // Instantiate the new object and return it
  +        Object actionForward = null;
  +        try {
  +            actionForward =
  +                RequestUtils.applicationInstance(className);
  +        } catch (Exception e) {
  +            digester.getLogger().error(
  +                    "ActionForwardFactory.createObject: ", e);
  +        }
  +
  +        return actionForward;
       }
   
   }
  
  
  
  1.8       +10 -10    jakarta-struts/src/share/org/apache/struts/config/ModuleConfig.java
  
  Index: ModuleConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/ModuleConfig.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ModuleConfig.java	14 Mar 2004 06:23:47 -0000	1.7
  +++ ModuleConfig.java	14 Apr 2004 23:46:15 -0000	1.8
  @@ -140,17 +140,17 @@
       void addFormBeanConfig(FormBeanConfig config);
   
       /**
  -     * The default class name to be used when creating global forward instances.
  +     * The default class name to be used when creating action forward instances.
        */
  -    String getGlobalForwardClass();
  +    String getActionForwardClass();
   
       /**
  -     * The default class name to be used when creating global forward instances.
  +     * The default class name to be used when creating action forward instances.
        *
  -     * @param globalForwardClass default class name to be used when creating
  -     *                           global forward instances.
  +     * @param actionForwardClass default class name to be used when creating
  +     *                           action forward instances.
        */
  -    void setGlobalForwardClass(String globalForwardClass);
  +    void setActionForwardClass(String actionForwardClass);
   
       /**
        * Add a new <code>ForwardConfig</code> instance to the set of global
  
  
  
  1.14      +15 -15    jakarta-struts/src/share/org/apache/struts/config/impl/ModuleConfigImpl.java
  
  Index: ModuleConfigImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/impl/ModuleConfigImpl.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ModuleConfigImpl.java	8 Apr 2004 22:53:18 -0000	1.13
  +++ ModuleConfigImpl.java	14 Apr 2004 23:46:15 -0000	1.14
  @@ -63,7 +63,7 @@
           this.actionConfigList = new ArrayList();
           this.actionFormBeanClass = "org.apache.struts.action.ActionFormBean";
           this.actionMappingClass = "org.apache.struts.action.ActionMapping";
  -        this.globalForwardClass = "org.apache.struts.action.ActionForward";
  +        this.actionForwardClass = "org.apache.struts.action.ActionForward";
           this.configured = false;
           this.controllerConfig = null;
           this.dataSources = new HashMap();
  @@ -241,20 +241,20 @@
       }
   
       /**
  -     * The default class name to be used when creating global forward instances.
  +     * The default class name to be used when creating action forward instances.
        */
  -    public String getGlobalForwardClass() {
  -        return this.globalForwardClass;
  +    public String getActionForwardClass() {
  +        return this.actionForwardClass;
       }
   
       /**
  -     * The default class name to be used when creating global forward instances.
  +     * The default class name to be used when creating action forward instances.
        *
  -     * @param globalForwardClass default class name to be used when creating 
  -     *                           action mapping instances.
  +     * @param actionForwardClass default class name to be used when creating
  +     *                           action forward instances.
        */
  -    public void setGlobalForwardClass(String globalForwardClass) {
  -        this.globalForwardClass = globalForwardClass;
  +    public void setActionForwardClass(String actionForwardClass) {
  +        this.actionForwardClass= actionForwardClass;
       }
   
       /**
  @@ -704,9 +704,9 @@
       protected String actionMappingClass = "org.apache.struts.action.ActionMapping";
       
       /**
  -     * The default class name to be used when creating global forward instances.
  +     * The default class name to be used when creating action forward instances.
        */
  -    protected String globalForwardClass = "org.apache.struts.action.ActionForward";
  +    protected String actionForwardClass = "org.apache.struts.action.ActionForward";
       
       /**
        * Matches action config paths against compiled wildcard patterns
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org