Pico Container

# About

- What is PicoContainer?
- Introduction
- Javadoc
- Downloads
- News
- FAQ
- Project Goals
- Support

# Core Concepts

- Component Lifecycle
- Dependency Injection
- Scoped Containers

# Dependency Injection

- Constructor Injection
- Setter Injection
- Annotated Field Injection
- Annotated Method Injection
- Typed Field Injection
- Named Field Injection
- Method Injection
- Multiple Injection
- Composite Injection
- Factory Injection
- Reinjection
- Injection via Providers

# Configuration

- Disambiguation

# Modifying Component Behaviors

- Modifying Behaviors
- Caching and Singletons
- Hiding Implementations
- Thread Safety Behaviors
- AOP Style Interception

# Advanced Concepts

- Fluent Style
- Arrays, Collections and Maps
- Leveraging Parameter Names
- Building Containers
- Component Properties
- Component Configuration
- Monitoring Component Events

# PicoContainer's Architecture

- Design Patterns
- Inversion of Control
- Component Adapters
- Mock Objects
- Terminology
- Container Comparisons
- Transparency

# Container Choices

- DefaultPicoContainer
- CommandLinePicoContainer
- PropertiesPicoContainer
- SystemPropertiesPicoContainer
- TransientPicoContainer
- TieringPicoContainer

# Dependant & Related

- Web Frameworks
- Scripting Support
- Persistence
- Logging

# Anti-patterns

- Propagating Dependency
- Long Constructor Argument List
- Container Dependency
- Unit Tests Use Container
- Singleton

# Help Pages

- Ambiguous Injectable
- Unprocessed Properties

# History

- Inversion of Control History

# Project Info

- Project
- Team

# Hosted by

# Tools

## News

Jan 20, 2008

PicoContainer 2.7 released (278K jar)

New (since 2.6):

- Provider added as a type of Injector. Subclasses of this supply one method called provide that takes dependencies and returns an instance of the type it is trying to provide
- ComponentMonitor: new method newBehavior
- ReflectionMethodInjection: new annotation @Nullable allows for individual parameters to be null
- Guarding behaviour : before components are injected, another seeming unrelated can be injected too and veto if it sees fit

Changes (versus 2.6):

- Reinjection changed to allow access to the result in the reinjection method invocation
- Method decorateComponentInstance on Injector changed to have a return value
- Scoped components stored in ThreadLocal can now can honor lifecycle concepts reliably
- ComponentMonitor: newInjectorFactory method renamed to newInjector
- Fix of issue where ImplementationHiding and Caching together on a component in threadlocal
- AnnotatedFieldInjection changed to traverse into parent classes for annotated fields to inject into
- Paranamer (included in PicoContainer jar) has had a couple of bugs fixed.
- Issued 343 fixed where generic collections were not not being injected correctly

October 14, 2008

PicoContainer 2.6 released (265K jar)

New (since 2.5.1):

- CompositeLifecycleStrategy supports a mix of LifecycleStrategies in one container tree
- Method Injection changed to also allow a specific reflection method to be implicated
- Reinjection added to allow components to be injected into a second time (reflection method injection only)

Changes (versus 2.5.1):

- Permissions fix for AdaptingInjection

Aug 14, 2008

PicoContainer 2.5.1 released (255K jar)

Changes (versus 2.5):

- makeChildContainer passes componentMonitor to the child container.

July 25, 2008

PicoContainer 2.5 released (255K jar)

New (since 2.4):

- Circular dependencies, while always supported via the implementation hiding behavior are now supported explicitly for individual components
- PicoBuilder improved in that it can add child containers to their parents if wanted. Refer PicoBuilder.addChildToParent()
- Components can now declare generic collections as dependencies to be Injected. It works the same was as an Array of the type in question always did.
- Concrete extensions of generic components can satisfy dependencies now. This is a way of beating type erasure.

Changes (versus 2.4):

- ConsoleComponentMonitor does need to be final, thus is not now.
- Attempts to chain a series of MutablePicoContainer.as() statements are blocked now. Instead users are directed towards the varargs feature of the same method.

July 02, 2008

PicoContainer Web, Script, Persistence and Logging 2.x released

See links above for respective news pages

June 26, 2008

PicoContainer 2.4 released (253K jar)

New (since 2.3):

- DefaultClassLoadingPicoContainer added. Components can now be referenced in different classloaders and by class name. This was formerly DefaultNanoContainer
- Locking behaviors are now characterizable as LOCK and NO_LOCK
- Synchronizing behaviors are now characterizable as SYNCHRONIZE and NO_SYNCHRONIZE
- Pooling behaviors are now characterizable as NO_POOL and POOL
- HotSwapping behaviors are now characterizable as HOT_SWAP and NO_HOT_SWAP

Changes (versus 2.3):

- Visitor for trees of PicoContainers, can issue a halt instruction now to stop the visitation early
- PICO-0316 fixed, whereby iterative injectors would not always find the dependencies to inject, when there were present
- AsmHiddenImplementation behavior in Gems replaces by HiddenImplementation
- CommandLinePicoContainer replaces by CommandLineArgumentsPicoContainer (now deprecated)
- ReflectionLifecycleStrategy can be subclassed now
- PICO-0314 fixed - StartableLifecycleStrategy can now have custom Disposable alternate classes correctly
- PICO-0303 fixed - ReflectionLifecycleStrategy was not bubbling lifecycle exceptions correctly

May 24, 2008

PicoContainer 2.3 released (241K jar)

New (since 2.2):

- FactoryInjector implementations for Log4J, Commons-logging, Java-Logging and SL4FJ
- JSR-250 compatible (@PreDestroy and @PostConstruct) lifecycle strategy
- Slf4j based component monitor
- Visitor for component factories (PICO-221)
- Thread local Storing behavior now has a mechanism to report the store size

Changes (versus 2.2):

- Implementation-hiding Behavior has a bug PICO-310 that has been fixed
- FactoryInjection bug fixed - PICO-311
- Embedded Paranamer now upgraded to 1.1.3
- Some of the monitors are now serializable when they were not formerly

May 9, 2008

PicoContainer 2.2 released (224K jar)

New (since 2.1):

- A new TieringPicoContainer that when used in a container tree, forbids children from seeking dependencies from their grandparents (they can only seek such from their parents)
- A new ReusablePicoContainer that is 2.5x faster for some niche usages where you are repeatedly discarding a container and then repopulating it (Gems)
- NamedFieldInjection allows named fields to be injected into (per component) - use when AnnotatedFieldInjection is not what you want
- TypedFieldInjection allows fields of a specified type to be injected into (per component) - use when AnnotatedFieldInjection is not what you want
- CompositeInjection allows a very custom setup of what injection-types you want your instance to support. Use when speed of execution is of the essence and AdaptiveInjection is not right for you.
- Decorating (behavior factory) - do something to a component instance immediately after its instantiation (and formal injection)
- FactoryAdapter - Allows for a custom instance to be injected into a component. E.g. 'new Logger(Foo.class)' for a Logger type and a Foo instance being the injectee

Changes (versus 2.1):

- Teams embedding PicoContainer and (completely hiding it from user communities) can extend StartableLifecycleStrategy and provide their own Startable interface (was buggy)

Mar 31, 2008

PicoContainer 2.1 released (194K jar)

New (since 2.0):

- A new ComponentMonitor method to allow allow for better mocking of select components during unit testing.

Jan 19, 2008

PicoContainer 2.0 released (190K jar)

New (since 2.0-beta-2):

- Binding Annotations support (disambiguation)
- Newer and rewritten properties backed containers
- Parameter names can be leveraged for all relevant types of injection

Changes (versus 2.0-beta-2):

- Yet More Java5 generics
- Build moved to JUnit 4.x and JMock 2.x (does not affect users of PicoContainer)
- Built-in parameter name access, as opposed jar dependency

August 26, 2007

PicoContainer 2.0 beta 2 released (152K jar)

New (versus 2.0-beta-1):

- Rudimentary AOP capability for components built in
- Method Injection (one method post-construction with multiple arguments)
- Automatic JNDI exposure
- Multi Injection (Setter and after Constructor injection)
- Store behavior (can extract/replace component store per thread)
- Automatic components (instantiate irrespective of need)
- Reentrant-Lock version of Synchronizing behavior

Changes (versus 2.0-beta-1):

- Better Java5 generics
- Renames of behaviors and injectors to more verb-like style
- Startable interface more easily overridden to own choice

July 15, 2007

PicoContainer 2.0 BETA-1 released (128K jar)

New:

- Properties for components as they are added to containers makes for increased flexibility
- Field and Method annotation types of injection in addition to traditional Constructor (recommended) and Setter types
- Parameters names for constructors can now drive otherwise ambiguous injections, as well as configuration
- Large sets of configuration can be taken from properties files and command line arguments
- PicoBuilder to make a container with desired behavior.

Changes:

- Java 5 style (use of generics, varargs, among others)
- Large scale Refactoring of packages and class names
- Fluent interface for adding of components to a container

April, 2007: Work begins on PicoContainer 2.x. It is substantially a refactoring of the PicoContainer 1.x codeline using the inbuilt features of Intellij IDEA and Eclipse. Using the existing unit tests as a guide, many small commits were made to the code-base to take PicoContainer in a more JDK 1.5 direction, and add in other features not seen in competing containers like parameter name access. Along the way, the API was simplified and parts of NanoContainer were bought closer to the core of PicoContainer.

Mar 18, 2007

PicoContainer 1.3 released (113K jar)

January 19, 2006

PicoContainer 1.2 released (112K jar)

November 4, 2004

PicoContainer 1.1 released (75K jar)

June 5, 2004

PicoContainer 1.0 released (49K jar)

February 21, 2004

PicoContainer 1.0 beta-5 (50K jar)

PicoContainer split into a core jar and 'gems' for things less often used

January 23, 2004

PicoContainer 1.0 beta-4 (64K jar)

November 03, 2003

PicoContainer 1.0 beta-3 (52K jar)

September 10, 2003

PicoContainer 1.0 beta-2 (44K jar)

August 14, 2003

PicoContainer 1.0 beta-1 (39K jar)

July 17, 2003

PicoContainer 1.0 alpha-2 (36K jar)

Setter Injection added (this was after the Pico team learned of the Spring-Framework project, Spring did not add Constructor Injection until the run up to 1.0-Milestone-3 in November '03 and 'autowiring' in the run up to 1-0-Milestone-4 in January of '04)

June 29, 2003

PicoContainer 1.0 alpha-1 (25K jar)

Generalized Constructor Injection available for the first time. This was very much PicoContainer's idiom. ATG Dynamo had something similar for web components, but Pico released this first as a general embedable API for the Java world. Goals for Pico are a) lightweight/embeddable, b) no XML or meta-data - 'autowiring' only, c) no lock-in, d) popularize Constructor Injection over Avalon and OSGi style of IoC, e) no dependencies for the container itself.

June 1, 2003

PicoContainer experimentation begins

Paul and Aslak pair on a precursor to PicoContainer called 'xContainer'. See the source