I've recently been designing applications so that per-action-path
commands are retrieved from Spring rather than from the default
commons-chain CatalogFactory. This then makes the lifecycle of the
command an external property (based on the "singleton" attribute of a
<bean> element in a Spring beans XML file.)
Of course this required custom request processing commands, since
Struts 1.3 doesn't have direct dependencies upon Spring.
More to the point, though, I don't think there's really that much
"wow" to saying that Chain can "execute any arbitrary class" -- even
"executing a class" implies that the class implements Command, and
then its not arbitrary any more.
The best thing I think would be to write a command which instantiated
this other arbitrary class, extracting properties from the Context to
pass to the "main" method of the arbitrary class and interpreting the
return appropriately (possibly modifying the Context as well.)
This is basically how the Chain deals with Struts Actions right now;
it's an unimportant detail that the Struts Actions are pooled and not
created each time, but the point is that rather than modifying Action
to implement Command,we wrote a bridge Command. If your arbitrary
class isn't threadsafe, rather than modifying that arbitrary class to
implement Command you should write a complementary Command which
knows how to use that class in a threadsafe manner.
Make sense?
Joe
At 9:49 AM +0200 9/23/05, Wolfgang Gehner wrote:
Hi there,
I keep telling people that 1.3 allows out of the box to execute ANY
ARBITRARY CLASS via command=, catalog= and chain-config, as long as
it implements the command interface. If those classes have to be
tread-safe, like old actions had to be, that is not entirely true.
Any idea how to configure non-thread-safe commands (i.e. that have
instance variables outside methods) in Struts 1.3, even if they are
not perfect commands (Commons-chain says that catalog.getCommand
will reuse instances).
How about overriding ExecuteCommand to create new instances if some
action-mapping parameter is present, and how to (a question to
commons-chain).
That should also be made VERY evident in the Docs.
We are just deploying a 400 screens application we wrote on Struts
1.3, and it works great! of course our commands are all thread-safe.
Kind regards,
Wolfgang Gehner
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Joe Germuska
[EMAIL PROTECTED]
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction" -The Ex
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]