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

## Leveraging Parameter Names

This is where the type alone is not enough to indicate which dependency should be put one or more constructor args. The following component has a need for two of the same type, with some subtly different characteristics.

    public class AppleProcessor {
      private Apple dessertApple;
      private Apple cookingApple;

      public inject(Apple dessertApple, Apple cookingApple) {
        this.dessertApple = dessertApple;
        this.cookingApple = cookingApple;
      }
      // other methods
    }

    pico.addComponent("dessertApple", GoldenDeliciousApple.class);
    pico.addComponent("cookingApple", BramleyApple.class);
    pico.as(Characteristics.USE_NAMES).addComponent(AppleProcessor.class);

    AppleProcessor appleProcessor = pico.getComponent(AppleProcessor.class);

In this case the constructor to AppleProcessor has carefully named parameters - 'dessertApple' and 'cookingApple'. This is picked up on for the two named components GoldenDeliciousApple and BramleyApple also set up in the container.

There are two ways for this to work:

- relying on the fact that your component classes have debug info compiled into them.
- post-processing component classes with Paranamer before placing them in their jar