Pilgrim, Peter on 01/08/05 09:30, wrote:
Struts 2 should force an Action or ActionForm to be interface or subclass of an abstract type, hence dependency injection.

If the former is the case, then it follows that calling the action
method should be flexible

public void bluegrass(ActionContext ac) { /* ... */}

or

public void bluegrass() {
>   ActionContext ac = typeOfThreadLocal.getFromSomeWhere();
>   /* ... */ }

then you need to handle absurdities like so (the general case )

public void bluegrass( A a, B b, ... ActionContext ac, ... Y y, Z z )
{ /* ... */}


Dependency injection lets me swap implementations really easily, so for
instance in testing for business tier, I can have either real DAOs or Mock DAOs depending on the XML configuration I choose.

So in the servlet tier, what would be the advantages? In testing again I guess, choosing to inject either the real Factories or Mock Factories (or Delegates or Session Facade, choose your pattern).

You could put this IoC in the struts-config. It could also inject the form bean, if the plan allows for its seperation from the action. The action would have to be instantiated for each request in that case, rather than having one per container.

Adam

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

Reply via email to