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...@apache.org on 2002/12/08 03:09:45 UTC

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

craigmcc    2002/12/07 18:09:45

  Modified:    src/share/org/apache/struts/action DynaActionFormClass.java
               src/share/org/apache/struts/config FormBeanConfig.java
               src/share/org/apache/struts/config/impl
                        ModuleConfigImpl.java
  Log:
  Make it possible to use DynaActionForms in more than one module, even
  though they have the same form name.  This required making the static
  collection of created DynaActionFormClass instances use a key composed of
  the form bean name *and* the module prefix.
  
  Removed redundant getDynaActionFormClass() method from DynaActionFormClass.
  It wasn't being used anywhere, and createDynaActionFormClass() did the
  correct thing already.
  
  PR: Bugzilla #13837
  Submitted by:	Gen Kagawa <kagawa at sun12.tis.co.jp>
  
  Revision  Changes    Path
  1.11      +8 -28     jakarta-struts/src/share/org/apache/struts/action/DynaActionFormClass.java
  
  Index: DynaActionFormClass.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/action/DynaActionFormClass.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DynaActionFormClass.java	15 Nov 2002 06:02:42 -0000	1.10
  +++ DynaActionFormClass.java	8 Dec 2002 02:09:44 -0000	1.11
  @@ -308,35 +308,15 @@
               if (dynaClasses == null) {
                   dynaClasses = new HashMap();
               }
  +            String key =
  +                config.getName() + config.getModuleConfig().getPrefix();
               DynaActionFormClass dynaClass =
  -                (DynaActionFormClass) dynaClasses.get(config.getName());
  +                (DynaActionFormClass) dynaClasses.get(key);
               if (dynaClass == null) {
                   dynaClass = new DynaActionFormClass(config);
  -                dynaClasses.put(config.getName(), dynaClass);
  +                dynaClasses.put(key, dynaClass);
               }
               return (dynaClass);
  -        }
  -
  -    }
  -
  -
  -    /**
  -     * Return an existing <code>DynaActionFormClass</code> of the specified
  -     * name, if one has been configured previously.  If no such instance has
  -     * been configured, return <code>null</code> instead.
  -     *
  -     * @param name Name of the <code>DynaActionFormClass</code> to be
  -     *  returned
  -     */
  -    public static DynaActionFormClass
  -        getDynaActionFormClass(String name) {
  -
  -        synchronized (lock) {
  -            if (dynaClasses == null) {
  -                return (null);
  -            } else {
  -                return ((DynaActionFormClass) dynaClasses.get(name));
  -            }
           }
   
       }
  
  
  
  1.9       +34 -4     jakarta-struts/src/share/org/apache/struts/config/FormBeanConfig.java
  
  Index: FormBeanConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/config/FormBeanConfig.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- FormBeanConfig.java	19 Jul 2002 04:42:21 -0000	1.8
  +++ FormBeanConfig.java	8 Dec 2002 02:09:44 -0000	1.9
  @@ -123,6 +123,36 @@
   
   
       /**
  +     * The {@link ModuleConfig} with which this form bean definition
  +     * is associated.
  +     */
  +    protected ModuleConfig moduleConfig = null;
  +
  +
  +    /**
  +     * Return the {@link ModuleConfig} with which this form bean definition
  +     * is associated.
  +     */
  +    public ModuleConfig getModuleConfig() {
  +        return (this.moduleConfig);
  +    }
  +
  +
  +    /**
  +     * Set the {@link ModuleConfig} with which this form bean definition
  +     * is associated.
  +     *
  +     * @param moduleConfig The new {@link ModuleConfig} or <code>null</code>
  +     *  to disassociate this form bean configuration from any module
  +     */
  +    public void setModuleConfig(ModuleConfig moduleConfig) {
  +        if (configured) {
  +            throw new IllegalStateException("Configuration is frozen");
  +        }
  +        this.moduleConfig = moduleConfig;
  +    }
  +
  +    /**
        * The unique identifier of this form bean, which is used to reference this
        * bean in <code>ActionMapping</code> instances as well as for the name of
        * the request or session attribute under which the corresponding form bean
  
  
  
  1.2       +6 -4      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ModuleConfigImpl.java	6 Nov 2002 04:48:29 -0000	1.1
  +++ ModuleConfigImpl.java	8 Dec 2002 02:09:45 -0000	1.2
  @@ -334,6 +334,7 @@
           if (configured) {
               throw new IllegalStateException("Configuration is frozen");
           }
  +        config.setModuleConfig(this);
           formBeans.put(config.getName(), config);
   
       }
  @@ -653,6 +654,7 @@
           if (configured) {
               throw new IllegalStateException("Configuration is frozen");
           }
  +        config.setModuleConfig(null);
           formBeans.remove(config.getName());
   
       }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>