ConfigurationConsider a component a that requires configuration : class Foo { public Foo(String fooName, Integer barNumber) { } } Clearly the two strings are not components. What we need is a way of passing in those parameters at runtime. Possibily interleaved with real components. PicoContainer pico = new HierarchicalPicoContainer.Default(); pico.registerComponent(Foo.class); pico.addParameterToComponent(Foo.class, String.class, "foo"); pico.addParameterToComponent(Foo.class, Integer.class, new Integer(33); pico.start(); Obviously you'd have some soft coded implementation rather than that hard coded above. We're trying to illustrate the intermingling of components and configuration. Well perhaps we are if you consider the follwoing component : class Foo { public Foo(Wilma wilma, String fooName, FredImpl fred, Integer barNumber) { } } .... PicoContainer pico = new HierarchicalPicoContainer.Default(); pico.registerComponent(Foo.class); pico.registerComponent(Wilma.class, WilmaImpl.class); pico.registerComponent(FredImpl.class); pico.addParameterToComponent(Foo.class, String.class, "foo"); pico.addParameterToComponent(Foo.class, Integer.class, new Integer(33); pico.start(); |