struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad A Cupit" <b...@lsu.edu>
Subject RE: interesting proxy + action chain issue
Date Mon, 07 Apr 2008 20:16:44 GMT
ServletActionRedirectResult worked when I used it instead of the
ActionChainResult. This performs an extra round trip back to the
browser, which isn't terrible unless I want to pass data from one Action
to another, and herein lies some concern.

Here's my design, and if you guys think it's flawed I'm certainly
willing to take criticism!

GETs are simple: just an Action that does some work and forwards to the
view.

POSTS should each have their own Action (which may write the data to the
DB). This Action should only process the POST. Afterwards, it forwards
(chains) to another Action, which sits in front of the view. If the view
needs data from the DB, it goes in the Action for that view (not the
POST-handling Action). If the view doesn't need data, then the Action is
dumb and just forwards to the view.

No direct links are made to JSPs, instead they link to the associated
Action. We can make exceptions for very simple views that are tied to
the POST (like a confirmation page), maybe it wouldn't need two Actions.

The advantage of this is two-fold:
a) if we ever need to make a 'dumb' action do DB lookups, we don't have
to change any links, just the dumb Action
b) we can reuse any JSP easily since all DB operations for it are
performed by its associated Action

Seems like a nice design, but Action chaining isn't recommended, and
isn't working with CGLIB proxies  :-(

p.s. the codebehind plugin makes it so we don't have to write those dumb
actions. Nice!!

Brad Cupit
Louisiana State University - UIS

-----Original Message-----
From: Brad A Cupit 
Sent: Monday, April 07, 2008 11:10 AM
To: 'user@struts.apache.org'
Subject: interesting proxy + action chain issue

Hi! I'm having a very interesting issue with CGLIB proxies. I'm proxying
my actions with Spring AOP (to get declarative transactions on each
Action).

Everything is working great, except when I try action chaining, I get a
class cast exception that Action2 can't be cast to Action1 (Action1 is
first in the chain).

This was very unusual, so I investigated. Here's what I found:

OgnlUtil.copy() is calling all of the getters in Action1 and pumping
that data into setters on Action2. With CGLIB, it calls getCallbacks()
and setCallbacks(), two methods created by CGLIB. This results in
Action2 having Action1's callbacks. Basically, it's similar to the
Action2 proxy referencing the Action1 target!

I can't use JDK proxies because the getters on my action (whose values
will be part of the value stack) are not defined on any interfaces, so
reflection on a JDK proxy will not find those getters.

I have a few ideas for workarounds, but I'd like to ask: has anyone else
seen this? Am I the first to try CGLIB proxies and Action chaining?

I've also read that action chaining is discouraged, but I don't
understand why. Maybe a completely different approach would work better?

Thanks!

Brad Cupit
Louisiana State University - UIS


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


Mime
View raw message