One minute description

Authors: Paul Hammant, Aslak Hellesoy, 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.)
  • 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 a hash map.
  • 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 (but remember that third party components might rely on the default lifecycle).

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