All this PicoContainer stuff reminds me of the excellent article from DrDobbs Journal a couple of years ago called new Considered Harmful [ <-- good read]
With my foray into the Pico stuff, I thought it would be a good idea to simplify (for my lazy benefit) the bit that is basically doing the 'new', or the 'instatiation management' or some other term... that you can find at the core of any Type3 IoC framework.
I've put together a little wrapper around pico to start with, and possibly other containers that provide 'instatiation management', and at joe's suggestion (and fear of hecklers) I'll share the source to you lot to play with.
This wrapper is not breaking new ground, in fact is only putting simple method names round existing methods in pico, and removing the knowledge of container from your code (for the simple stuff). But it has got me thinking about the general case of 'instatiation management' as a replacement for new, and my next wander around the javaverse could include looking into The Java Syntactic Extender to provide a new syntax for making this as easy to use as new (irrespective of container)
JavaDocs,source code, and the prebuilt easy.jar
EasyContainer pico = new EasyContainer(new DefaultPicoContainer());
pico.reg(Boy.class);
pico.reg(Girl.class);
Girl girl = (Girl)pico.get(Girl.class);
|
Any thoughts...
P.S. My own critic inside says "Oh my god, he's written commons-logging generic wrapper equivalent for type3 containers" - but I might as well publish this anyways ;-)