struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Hardy <ahardy.str...@cyberspaceroad.com>
Subject Re: [STRUTS 2X]: Ideas
Date Mon, 01 Aug 2005 22:43:19 GMT
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message