Here is the ChainBase execute method, gentlemen. If you think that is CoR,
then I have nothing further to say. This is the real "pattern". It is not
even OOP. It merely uses a class as a repository to do C coding.
// Documented in Chain interface
public boolean execute(Context context) throws Exception {
// Verify our parameters
if (context == null) {
throw new IllegalArgumentException();
}
// Freeze the configuration of the command list
frozen = true;
// Execute the commands in this list until one returns true
// or throws an exception
boolean saveResult = false;
Exception saveException = null;
int i = 0;
int n = commands.length;;
for (i = 0; i < n; i++) {
try {
saveResult = commands[i].execute(context);
if (saveResult) {
break;
}
} catch (Exception e) {
saveException = e;
break;
}
}
// Call postprocess methods on Filters in reverse order
if (i >= n) { // Fell off the end of the chain
i--;
}
boolean handled = false;
boolean result = false;
for (int j = i; j >= 0; j--) {
if (commands[j] instanceof Filter) {
try {
result =
((Filter) commands[j]).postprocess(context,
saveException);
if (result) {
handled = true;
}
} catch (Exception e) {
; // Silently ignore
}
}
}
// Return the exception or result state from the last execute()
if ((saveException != null) && !handled) {
throw saveException;
} else {
return (saveResult);
}
}
On 2/19/06, Frank W. Zammetti <[EMAIL PROTECTED]> wrote:
>
> Does "MyCommand" represent a chain in MyCatalog? If so, while I
> wouldn't presume to speak for Craig, it sure seems like it :) I've
> personally used the "fire a chain from an Action" in the past, but I can
> certainly see where this would be very nice.
>
> Frank
>
> Martin Cooper wrote:
> > On 2/19/06, Craig McClanahan <[EMAIL PROTECTED]> wrote:
> > <snip/>
> >
> > The next step would be to provide customizable chains per Action
> (becoming
> >> even more like how you configure actions in WebWork) -- but you can
> even
> >> do
> >> that today by using an Action that itself executed a chain.
> >
> >
> > Craig, isn't that what we already have with:
> >
> >
> > <action path="/MyAction"
> > catalog="MyCatalog"
> > command="MyCommand"/>
> >
> > or am I misunderstanding?
> >
> > --
> > Martin Cooper
> >
> >
> > Michael.
> >>
> >> Craig
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~