Re: [picocontainer-dev] New Picocontainer-web ... defeating IoC made easier now :-(

Mauro Talevi <[email protected]>
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Paul Hammant wrote:
> In PicoServletContainerFilter, there is ..
> 
>   public static MutablePicoContainer getRequestContainerForThread() { .. }
> 
> .. which makes available a request container for our classes
> 
>   ActionFactory (Struts1)
>   PicoObjectFactory (Struts2)
>   PicoActionFactory (Webwork1)
>   PicoObjectFactory (WebWork2)
> 
> The problem is that actions themselves could call that static method to 
> get a container. You could make it policy in a dev team not to, but 
> PicoContainer is normally more protected than this.  IoC is normally 
> guaranteed.
> 
> I thought about a solution changing the method to ..
> 
>   public static MutablePicoContainer getRequestContainerForThread(String 
> magicKey) { .. }
> 
> And make all of the bits be aware of some value set in web.xml or 
> struts.xml (you get the picture), but not all of those four classes can 
> recieve config or reach back to getInitParameter(.) - so it isn't going 
> to work.
> 
> Thoughts?
> 
> - Paul
> 

I don't see the point of all this to be honest :-)

Even in the previous design the user could have gotten hold of the 
reference to the container from the action, using the context lookup 
key.   It has not changed in this respect.  It's a features of web 
development that is inherently and potentially un-IoC.

IMO we should avoid unnecessary complications and just put forward the 
"best practice".   I mean - Pico also supports setter-injection although 
that is known, if not well implemented, to leave objects in an unknown 
state.   And even constructor-injection can be implemented badly.  So, 
the bottom line is:  educate users but don't complicate unnecessarily ;-)

Cheers



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.