struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From craig...@apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/action DynaActionFormClass.java
Date Sat, 13 Jul 2002 18:05:06 GMT
craigmcc    2002/07/13 11:05:05

  Modified:    src/share/org/apache/struts/action DynaActionFormClass.java
  Log:
  Make it possible to serialize DynaActionForm instances, as long as the
  property values themselves are also Serializable.  This also relies on
  a fix in the 20020714 nightly build of commons-beanutils to be effective.
  
  PR: Bugzilla #10380
  Submitted by:	Matt Raible (matt at raibledesigns.com>
  
  Revision  Changes    Path
  1.7       +41 -10    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DynaActionFormClass.java	29 Jun 2002 03:14:19 -0000	1.6
  +++ DynaActionFormClass.java	13 Jul 2002 18:05:05 -0000	1.7
  @@ -63,6 +63,7 @@
   package org.apache.struts.action;
   
   
  +import java.io.Serializable;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.Map;
  @@ -87,7 +88,7 @@
    * @since Struts 1.1
    */
   
  -public class DynaActionFormClass implements DynaClass {
  +public class DynaActionFormClass implements DynaClass, Serializable {
   
   
       // ----------------------------------------------------------- Constructors
  @@ -120,7 +121,7 @@
        * The <code>DynaActionForm</code> implementation <code>Class</code>
which
        * we will use to create new bean instances.
        */
  -    protected Class beanClass = null;
  +    protected transient Class beanClass = null;
   
   
       /**
  @@ -156,7 +157,14 @@
        * The set of <code>DynaActionFormClass</code> instances that have
        * ever been created, keyed by the form bean name.
        */
  -    protected static HashMap dynaClasses = new HashMap();
  +    protected transient static HashMap dynaClasses = new HashMap();
  +
  +
  +    /**
  +     * The lockable object we can synchronize on, even if dynaClasses
  +     * is null,
  +     */
  +    protected static String lock = "";
   
   
       // ------------------------------------------------------ DynaClass Methods
  @@ -227,7 +235,8 @@
       public DynaBean newInstance()
           throws IllegalAccessException, InstantiationException {
   
  -        DynaActionForm dynaBean = (DynaActionForm) beanClass.newInstance();
  +        DynaActionForm dynaBean =
  +            (DynaActionForm) getBeanClass().newInstance();
           dynaBean.setDynaActionFormClass(this);
           FormPropertyConfig props[] = config.findFormPropertyConfigs();
           for (int i = 0; i < props.length; i++) {
  @@ -272,7 +281,10 @@
        */
       public static void clear() {
   
  -        synchronized (dynaClasses) {
  +        synchronized (lock) {
  +            if (dynaClasses == null) {
  +                dynaClasses = new HashMap();
  +            }
               dynaClasses.clear();
           }
   
  @@ -293,7 +305,10 @@
       public static DynaActionFormClass
           createDynaActionFormClass(FormBeanConfig config) {
   
  -        synchronized (dynaClasses) {
  +        synchronized (lock) {
  +            if (dynaClasses == null) {
  +                dynaClasses = new HashMap();
  +            }
               DynaActionFormClass dynaClass =
                   (DynaActionFormClass) dynaClasses.get(config.getName());
               if (dynaClass == null) {
  @@ -307,6 +322,22 @@
   
   
       // ------------------------------------------------------ Protected Methods
  +
  +
  +    /**
  +     * Return the implementation class we are using to construct new
  +     * instances, re-introspecting our {@link FormBeanConfig} if necessary
  +     * (i.e. after being deserialized, since <code>beanClass</code> is
  +     * marked transient.
  +     */
  +    protected Class getBeanClass() {
  +
  +        if (beanClass == null) {
  +            introspect(config);
  +        }
  +        return (beanClass);
  +
  +    }
   
   
       /**
  
  
  

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


Mime
View raw message