|
|||||
|
|||||
User DocumentationOne minute descriptionTwo minute tutorial Five minute introduction Advanced Topics FAQ Container Components Terminology Mock Objects Inversion of Control Types PatternsInversion of ControlDependency Injection Constructor Injection Setter Injection Interface Implementation Separation Lifecycle Antipatterns Developer DocumentationHow To Contribute Relative Volunteering Release Process Project InformationSloganMailing lists Source Repositories Open Issues Blog entries Statistics Team Sister Projects TShirts MiscellaneousDifferentiatorsNirvana Full SitemapFeeds
|
Authors: Jörg Schaible PicoContainer will look for the greediest constructor of your component. But if your component's constructor depends on primitive types you may set the values explicitly. public interface ThreadPool { void setSize(int); } public class MyComp { private ThreadPool threadPool; public MyComp(ThreadPool pool, int size) { threadPool = pool; threadPool.setSize(size); } } In this case you can set the parameters at registration time:
DefaultPicoContainer pico = new DefaultPicoContainer(); pico.registerComponentImplementation(ThreadPool.class, DefaultThreadPool.class); pico.registerComponentImplementation(MyComp.class, MyComp.class, new Parameters[] { new ComponentParameter(), new ConstantParameter(new Integer(5)); }) MyComp myComp = (MyComp)pico.getInstance(MyComp.class); Use ConstantParameter to set constant values and the ComponentParameter to let Pico resolve the dependency. |
||||
|