Listing Details| ID: | 207 |
| Title: | PicoContainer |
| Pagerank: | 6 |
| Short Description: | PicoContainer is a highly embeddable, full-service, Inversion of Control (IoC) container for components honor the Dependency Injection pattern. The project started in 2003 and pioneered Constructor Injection auto-wiring. It is also Open Source and therefore free to use. The license is BSD and thus you can safely use this with commercial or other open source software. |
| Description: | You could use it as a lightweight alternative to Sun's J2EE patterns for web applications or general solutions. What is Dependency Injection? Martin Fowler has a good article from 2003, but here is another view: It is a good design pattern that, for large enterprise applications, facilitates:
•easy best practice unit testing vs little and difficult unit testing. •configuration given to componentsvs components reading their own scattered config •component reuse vs rewriting through ignorance or perceived needs •clean & declarative architecture vs a nest of singletons that nobody can make sense of •adaptability vs developers not knowing where to start to add features •maintainability vs developers having difficulties fixing bugs •transparency vs lots of framework code, with consequential lock in Dependency Injection is quite often, but not exclusively, used by Agile practitioners. It counters situations where enterprise applications:
•have grown to be thousands of classes, with dozens if not hundreds of Singletons •has made development staff looking after it miserable, and wanting to quit •draw similarities to Spaghetti, Hairballs or Balls of Mud •suffers repeated allegations of "it cannot be further developed without complete rewrite"
Despite it being very compact in size (the core is ~260K and it has no mandatory dependencies outside the JDK), PicoContainer supports different dependency injection types (Constructor, Setter, Annotated Field / Method) and offers multiple lifecycle and monitoring strategies. PicoContainer has originally been implemented in Java but is also available for other platforms and languages. PicoContainer's most important feature is its ability to instantiate arbitrary objects. This is done through its API, which is similar to a hash table. You can put java.lang.Class objects in and get object instances back.
Lifecycle:
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 managed 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. |
| Category: | IoC, Dependancy Injection |
| Link Owner: | |
| Date Added: | May 02, 2010 05:35:06 PM |
| Number Hits: | 0 |
| URL: | http://www.picocontainer.org/ |