Authors: paul, Aslak Hellesøy, Jon Tirsen
What is PicoContainer?
- PicoContainer is a lightweight container.
- It is not not a replacement for a J2EE container, as it doesn't offer any infrastructure services out of the box.
- It can help you write better code.
What does PicoContainer do?
- Dependency Injection. A way of instantiating components and lacing them together with other dependent components.
- PicoContainer is non-intrusive. Components don't have to implement any funny APIs. They can be POJOs.
- Lifecycle support is built-in. Components' lifecycle can be managed easily by PicoContainer (the default lifecycle is simple, but can be extended or totally customized).
- Very extensible design enabling virtually any form of extensions to the core.
- It is embeddable inside other applications. A 50k jar that has no external dependencies except JDK 1.3.
How do I use PicoContainer?
- Components are implemented as ordinary Java classes and do typically not have to rely on any PicoContainer APIs.
- The components are assembled in the container using a simple Java API that is similar to an intelligent hash map utilizing the type of its values.
- If lifecycle callbacks are required the simple lifecycle interfaces can be implemented. If you prefer to use your own lifecycle interfaces you can do that.
- Use the monitor support of PicoContainer to react on internal events e.g. by logging.
Why should I use PicoContainer?
- To modularize how dependencies between parts of your application are laced up. It is common having this scattered all over.
- To improve the testability of your code.
- To improve how components are configured in application.
Next: Two minute tutorial