struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Meder <ch...@absolutegiganten.org>
Subject Re: svn commit: r345179 - in /struts/core/trunk: conf/java/struts-config_1_3.dtd src/java/org/apache/struts/action/DynaActionFormClass.java src/java/org/apache/struts/config/FormBeanConfig.java src/java/org/apache/struts/util/DynaBeanInterceptor.java
Date Fri, 18 Nov 2005 07:04:54 GMT
On Thu, 2005-11-17 at 16:29 -0500, Laurie Harper wrote:
> Christian Meder wrote:
> > On Thu, 2005-11-17 at 03:40 +0000, laurieh@apache.org wrote: 
> >>
> >>     /**
> >>+     * <p>The CGLIB <code>Enhancer</code> which we will use
to dynamically
> >>+     * add getters/setters if 'enhanced' is true in the form config.
> >>+     */
> >>+    protected transient Enhancer enhancer = null;
> > 
> > Shouldn't we mark enhancer private as getBeanEnhancer will always do the
> > right thing ?
> 
> protected seems to be the norm in Struts code for members of classes 
> likely to be subclassed. This is just consistent with other members in 
> the class.

Just after posting I saw that it's consistent with other members in the
class ;-)

But that still leaves the point that the re-introspection after
deserialization isn't properly encapsulated and bug-prone if you can
access the enhancer directly without the check. Consistently the same
issue for the other transient members like beanClass ;-)

> 
> >>+
> >>+    /**
> >>      * <p>The form bean configuration information for this class.</p>
> >>      */
> >>     protected FormBeanConfig config = null;
> >>@@ -193,9 +192,14 @@
> >>     public DynaBean newInstance()
> >>         throws IllegalAccessException, InstantiationException {
> >> 
> >>-        FormPropertyConfig[] props = config.findFormPropertyConfigs();
> >>-        DynaActionForm dynaBean = (DynaActionForm) doCreate(props);
> >>+        DynaActionForm dynaBean = null;
> >>+        if (config.isEnhanced()) {
> >>+            dynaBean = (DynaActionForm) getBeanEnhancer().create();
> >>+        } else {
> >>+            dynaBean = (DynaActionForm) getBeanClass().newInstance();
> >>+        }
> >>         dynaBean.setDynaActionFormClass(this);
> >>+        FormPropertyConfig[] props = config.findFormPropertyConfigs();
> >>         for (int i = 0; i < props.length; i++) {
> >>             dynaBean.set(props[i].getName(), props[i].initial());
> >>         }
> >>@@ -273,6 +277,24 @@
> >> 
> >>
> >>     /**
> >>+     * <p>Return the <code>Enhancer</code> we are using to
construct new
> >>+     * instances, re-introspecting our {@link FormBeanConfig} if necessary
> >>+     * (that is, after being deserialized, since <code>enhancer</code>
is
> >>+     * marked transient).</p>
> >>+     *
> >>+     * @return The enhancer used to construct new instances.
> >>+     */
> >>+    protected Enhancer getBeanEnhancer() {
> >>+
> >>+        if (enhancer == null) {
> >>+            introspect(config);
> >>+        }
> >>+        return (enhancer);
> > 
> > Idiom question. Why the brackets around enhancer ?
> 
> Local coding convention... They're redundant but, again, this is 
> consistent with other code.

Thanks. But is there any explanation for this coding convention ?

Greetings,


				Christian
-- 
Christian Meder, email: chris@absolutegiganten.org

The Way-Seeking Mind of a tenzo is actualized 
by rolling up your sleeves.

                (Eihei Dogen Zenji)

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


Mime
View raw message