The most important feature of PicoContainer is to instantiate any object into the class, you can return an instance object.
In the case of a large number of interfaces and objects with complex dependencies, PicoContainer is very useful.
PicoContainer identifies dependencies by looking at the constructors of registered classes (Constructor Injection). PicoContainer can also be though of as a generic factory that can be configured dynamically. PicoContainer is able to instantiate a complex graph of several interdependent objects.
PicoContainer provides a powerful alternative to the Singleton antipattern With container hierarchies you can create singleton-like objects where you have fine grained control over the visibility scope of the instance (The singleton pattern is static and global -.. It will not allow more than One Instance, And It Is Visible from anywhere. Not nice.
A Container (AND ITS Registered Components) Can Get Access To Components Registered In a Parent Container, But not vice-versa.
PicoContainer has support for Lifecycle. If your classes implement Startable, you can control the lifecycle of all your objects with a simple method call on the container. The container will figure out the correct order of invocation of start () / stop () all the Objects management by the container.
Calling start () on the container will call start () on all container managed objects in the order of their instantiation This means starting with the ones that have no dependencies, and ending with the ones that have dependencies on others.:
Lifecycle also works for hierarchies of containers. Calling start () on a container with child containers will start all the containers in a breadth-first order, starting with itself. Likewise, calling stop () will call stop () on all containers in the hierarchy in a depth-first order. The pictures below show what happens when start () and stop () are called on a container with children.Lifecycle also works for hierarchies of containers. Calling start () on a container with child containers will start All The Containers In a Breadth-First Order, Starting With Itself. Likewise, Calling Stop () Will Call Stop () on All Containers In The Hierarchy in a Depth-First Order.
In order for hierarchy-aware lifecycle to work, child containers must be registered as components in their parent container. Just creating a container with another one as a parent will not cause the parent container to know about the child container.
Propagating Dependency