Paul Hammant's Blog: PicoConatiner 2.0 beta released
We have been working on this for a while, and its now in Maven2 repositories and ready for use. Lots of new features including the leveraging of parameter names for configuration and component disambiguation.
It is mostly a refactoring of Pico 1.3, with some new things. For the formal 2.0 release and onwards PicoContainer will be a JDK 5.0 technology. Releases < 2.0 will be JDK 1.2 to JDK 1.4.
What's new:
Fluent style
Foo foo = pico.addComponent(Foo.class).addComponent(Bar.class).getComponent(Foo.class);
Properties
pico.as(CACHE).addComponent(Foo.class); pico.as(HIDE_IML).addComponent(Foo.class);
Components marked with annotations
This is optional of course. CDI without annotation is still our recommended style. @Inject above a field or methods (like Guice) is now supported.
class Foo { @Inject public void registerDep (Bar bar) { } }
PicoBuilder
pico = new PicoBuilder().withCaching().withImplementationHiding() .withLifecycle().withConsoleMonitor().build();
Parameter name access for configuration and component disambiguation
Pico will instantiate the following with a Bar instance if a) that Bar instance is the only one that could, or b) there are more that one Bar instance to inject, but one of them has a key of "simpleBar")
class Foo { public Foo (Bar simpleBar) { } }
Config from a properties file or from the command line
class MyMain { public static void main (String[] args) { PicoContainer configContainer = new ArgumentativePicoContainer(args); MutablePicoContainer comps = new DefaultPicoContainer(configContainer); comps.addComponent(MyPersistenceTier.class); // etc } }
Class MyPersistenceTier takes two three strings in its constructor args. One is 'jdbcUrl', another is 'jdbcUser' and the last say 'jdbcPassword'. They are specified on the command like of course.
Read more on the PicoContainer site