Tim Moore wrote:
It seems to me that just making Action an interface wouldn't even solve
your problem.  Your problem is that you want to use inheritance for the
template method pattern, but you also want to use inheritance to reuse
functionality from the LookupDispatchAction.  The best solution I can
think of is to have your class subclass BaseAdminAction and delegate to
LookupDispatchAction.

for example

public class MyAction extends BaseAdminAction {
  // this is whatever your non-final execute method is called
  public ActionForward myExecute(ActionMapping mapping, ... ) {
    return new LookupDispatchAction().execute(mapping, ... );
  }
}

Even better, create a single LookupDispatchAction in the constructor and
reuse it across requests.  I haven't tried anything like this, but I
can't think of any reasons off-hand why it shouldn't work.  Any
comments?
One reason it won't work this way... LookupDispatchAction is abstract :)

I've given your idea some thought in the past though, and it should work as long as I create a subclass of LookupDispatchAction to delegate to. Ugly, but at least it'd work with the existing Struts codebase rather than me cutting and pasting.

Same situation would apply to DispatchAction too... you'd need to implement the actual functionality in a separate subclass (or perhaps anonymous inner classes if you wanted to get tricky with it).

So, your idea is a reasonable one, but its trickier in practice to pull off.

Erik



--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to