On 2/16/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote: > > > I think CoR is a great pattern, I've used it with great success, but I'm > not as sure how it fits into Struts *outside* the composable RP, which is > a *perfect* application for it. Just curious how you (and/or others) are > already using it.
Ted has some good use case examples in his Agility stuff. One simple scenario is where you want to reuse fine grained commands that allocate resources, without the actual processing logic having to know where it came from (and you're not using a dependency injection framework). Consider a Filter (in the Commons Chain sense, a Command that gets control on the way in and on the way out) that "injects" a JDBC Connection (or a Hibernate session, or whatever) into the Context object. You'd do that part in the execute() method, then clean up in postprocess() on the way back out. This would be configured into a chain in front of the particular Command that actually performs your business logic -- and its reusable for all commands that need a Connection handed to them. Need some more resources? Add some more fine grained reusable decoarator commands to allocate and release them. This pattern, of course, can be used today in a Struts 1.x action ... or in the "action" equivalent of any other framework too (JSF, WebWork, whatever). And, it's not even web specific ... you can design your whole business logic layer out of chains. Craig