You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Hubert Rabago <hr...@gmail.com> on 2005/03/23 16:25:32 UTC
Adventures with configuration inheritance
So I started with inheriting Form Bean configuration. It seemed like
the best candidate because it's where the feature seemed most
applicable at first glance. Once I had that working, I moved on to
ForwardConfig.
I figured, it should be easier and more straightforward. No
subelements like a form bean's form properties, and I already know the
basic approach from working on Form Beans. Well ForwardConfig didn't
want to cooperate by making it easy for me since I had to deal with
global forwards and action forwards. I especially liked this:
<global-forwards>
<forward name="success" path="/home.jsp"/>
</global-forwards>
<action-mappings>
<action path="/somePath"
type="SomeAction">
<forward name="success" extends="success" redirect="true"/>
</action>
</action-mappings>
... where I interpret /somePath's <forward> as <forward>whatever's in
the "success" global-forward, but with a redirect</forward>. Form
Bean config inheritance worked by finding config objects by name.
With ForwardConfig, the ancestor's name could be the same, so we do
some hacking^H^H^H^H^H^H^H tweaking.
Now we move to ActionConfig. Should be simple, right? Action
mappings are already global within the module. Sure there are
subelements, but we should be able to apply what we learned from
FormBeanConfig. Ha ha, not so fast. I started inheriting the
forwards from another action mapping, then came across this scenario:
<action path="/somePathA"
type="SomeAction"
name="someForm">
<forward name="baseForward" path="/page1.jsp"/>
<forward name="subForward" extends="baseForward" redirect="true"/>
</action>
<action path="/someOtherPath"
extends="/somePathA">
<forward name="subForward" module="/otherModule"/>
</action>
What does /someOtherPath's subForward look like? After some thought,
I had the answer: redirect to /otherModule/page1.jsp
We "inherit" the forward definition of the same name from the action,
which by that time, should be expanded already. For cases like this,
the "extends" tag is also inherited, although in the case above, there
was nothing more to inherit.
Once you get started with weird cases, of course, you won't be able to stop:
<action path="/somePath"
type="SomeAction"
name="someForm">
<forward name="baseForward" path="/page1.jsp"/>
<forward name="subForward" extends="baseForward" redirect="true"/>
</action>
<action path="/someOtherPath"
extends="/somePath">
<forward name="baseForward" path="/page2.jsp"/>
<forward name="subForward" module="/otherModule"/>
</action>
What does /someOtherPath's subForward look like now? Answer: redirect
to /otherModule/page1.jsp. The "extends" was inherited, but by first
inheriting /somePath's subForward, the "path" property already had a
value, so there was nothing to inherit from /someOtherPath's
baseForward.
<action path="/somePath"
type="SomeAction"
name="someForm">
<forward name="baseForward" path="/page1.jsp"/>
<forward name="subForward" extends="baseForward" module="/otherModuleA"/>
</action>
<action path="/someOtherPath"
extends="/somePath">
<forward name="baseForward" path="/page2.jsp"
module="/otherModuleB" redirect="true"/>
</action>
What's the value now for /someOtherPath's subForward? Answer:
redirect to /otherModuleA/page1.jsp
==============
Here's what I have so far. There are still debug statements I'll be
removing, and a bunch of TODO items to update messages. I'll get to
these before I check in code.
http://www.rabago.net/struts/configinheritance/configinheritance.txt
Here's the config (so far) of the sample app I'm playing with:
http://www.rabago.net/struts/configinheritance/struts-config.xml
Hubert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Adventures with configuration inheritance
Posted by Hubert Rabago <hr...@gmail.com>.
On Wed, 23 Mar 2005 09:25:32 -0600, Hubert Rabago <hr...@gmail.com> wrote:
>
> Here's the config (so far) of the sample app I'm playing with:
> http://www.rabago.net/struts/configinheritance/struts-config.xml
I forgot to mention that the sample app I play with is only using one
action for several mappings (most having the same "base" mapping), and
that the action extends MappingDispatchAction. It'd make the config
look really strange if the person looking didn't know that.
Hubert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Adventures with configuration inheritance
Posted by Joe Germuska <Jo...@Germuska.com>.
At 9:25 AM -0600 3/23/05, Hubert Rabago wrote:
(description of ForwardConfig inheritance -- no comments)
followed by:
>Now we move to ActionConfig. Should be simple, right? Action
>mappings are already global within the module. Sure there are
>subelements, but we should be able to apply what we learned from
>FormBeanConfig. Ha ha, not so fast. I started inheriting the
>forwards from another action mapping, then came across this scenario:
>
><action path="/somePathA"
> type="SomeAction"
> name="someForm">
> <forward name="baseForward" path="/page1.jsp"/>
> <forward name="subForward" extends="baseForward" redirect="true"/>
></action>
>
><action path="/someOtherPath"
> extends="/somePathA">
> <forward name="subForward" module="/otherModule"/>
></action>
>
>What does /someOtherPath's subForward look like? After some thought,
>I had the answer: redirect to /otherModule/page1.jsp
>
>We "inherit" the forward definition of the same name from the action,
>which by that time, should be expanded already. For cases like this,
>the "extends" tag is also inherited, although in the case above, there
>was nothing more to inherit.
>
I disagree with this interpretation. For what it's worth, my
assumption would be that any named ForwardConfig in an extended
ActionConfig would override, not extend an identically named
ForwardConfig in the parent ActionConfig.
Most important is defining the behavior, but I just wanted to point
out that your interpretation is counter-intuitive to me.
>
>Once you get started with weird cases, of course, you won't be able to stop:
>
><action path="/somePath"
> type="SomeAction"
> name="someForm">
> <forward name="baseForward" path="/page1.jsp"/>
> <forward name="subForward" extends="baseForward" redirect="true"/>
></action>
>
><action path="/someOtherPath"
> extends="/somePath">
> <forward name="baseForward" path="/page2.jsp"/>
> <forward name="subForward" module="/otherModule"/>
></action>
>
>What does /someOtherPath's subForward look like now? Answer: redirect
>to /otherModule/page1.jsp. The "extends" was inherited, but by first
>inheriting /somePath's subForward, the "path" property already had a
>value, so there was nothing to inherit from /someOtherPath's
>baseForward.
By my interpretation, the /someOtherPath forward named "subForward"
would have no relationship to "/somePath"'s forward named
"subForward" I agree that you are being consistent, but just
elaborating my earlier interpretation in this case.
>
><action path="/somePath"
> type="SomeAction"
> name="someForm">
> <forward name="baseForward" path="/page1.jsp"/>
> <forward name="subForward" extends="baseForward" module="/otherModuleA"/>
></action>
>
><action path="/someOtherPath"
> extends="/somePath">
> <forward name="baseForward" path="/page2.jsp"
>module="/otherModuleB" redirect="true"/>
></action>
>
>What's the value now for /someOtherPath's subForward? Answer:
>redirect to /otherModuleA/page1.jsp
I agree with this, in that the inheritance parent of "subForward" is
not "/someOtherPath"'s "baseForward".
Not sure when I'll have time to look more carefully at your config or
sample app...
Joe
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Adventures with configuration inheritance
Posted by Hubert Rabago <hr...@gmail.com>.
Inline
> From: Joe Germuska [mailto:Joe@Germuska.com]
>
> At 9:25 AM -0600 3/23/05, Hubert Rabago wrote:
> >
> >We "inherit" the forward definition of the same name from the action,
> >which by that time, should be expanded already. For cases like this,
> >the "extends" tag is also inherited, although in the case
> above, there
> >was nothing more to inherit.
> >
>
> I disagree with this interpretation. For what it's worth, my
> assumption would be that any named ForwardConfig in an extended
> ActionConfig would override, not extend an identically named
> ForwardConfig in the parent ActionConfig.
>
Yes, I prefer your interpretation, too. :)
> Most important is defining the behavior, but I just wanted to point
> out that your interpretation is counter-intuitive to me.
And as a result, harder to keep track of. This did concern me, and I
guess it's one of those cases where I was too close to it. It's also
a reason why I wanted to provide illustrations in this message.
So let's spell this out. If ActionB extends ActionA, ActionB inherits
all of ActionA's forward definitions. If ActionB includes a forward
def that has the same name as an ActionA forward, ActionB loses the
ActionA forward with that name and instead starts fresh with the
definition it has.
>
> >
> >Once you get started with weird cases, of course, you won't
> be able to stop:
> >
> ><action path="/somePath"
> > type="SomeAction"
> > name="someForm">
> > <forward name="baseForward" path="/page1.jsp"/>
> > <forward name="subForward" extends="baseForward"
> redirect="true"/>
> ></action>
> >
> ><action path="/someOtherPath"
> > extends="/somePath">
> > <forward name="baseForward" path="/page2.jsp"/>
> > <forward name="subForward" module="/otherModule"/>
> ></action>
> >
<snip/>
> By my interpretation, the /someOtherPath forward named "subForward"
> would have no relationship to "/somePath"'s forward named
> "subForward" I agree that you are being consistent, but just
> elaborating my earlier interpretation in this case.
>
Going by the new interpretation, /someOtherPath's "subForward" would
log an error as it is incomplete.
> >
> ><action path="/somePath"
> > type="SomeAction"
> > name="someForm">
> > <forward name="baseForward" path="/page1.jsp"/>
> > <forward name="subForward" extends="baseForward"
> module="/otherModuleA"/>
> ></action>
> >
> ><action path="/someOtherPath"
> > extends="/somePath">
> > <forward name="baseForward" path="/page2.jsp"
> >module="/otherModuleB" redirect="true"/>
> ></action>
> >
> >What's the value now for /someOtherPath's subForward? Answer:
> >redirect to /otherModuleA/page1.jsp
>
> I agree with this, in that the inheritance parent of "subForward" is
> not "/someOtherPath"'s "baseForward".
>
> Not sure when I'll have time to look more carefully at your config or
> sample app...
>
> Joe
Btw, the sample app link is just a short XML - doesn't really contain
the source.
Hubert
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org