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

## Factory Injection

### Overview

This allows an instance to be injected via a factory that is aware of the thing it is injecting into and can make a custom instance just for that injectee. This type of injection is only possible if you add an Adapter for it directly that subclasses FactoryInjection<T>

    public class Apple {
        private final Log log;
        private final Orange orange;
        private final Pear pear;
        private final Banana banana;

        public Apple(Orange orange, Pear pear, Banana banana, Log log) {
            this.orange = orange;
            this.pear = pear;
            this.banana = banana;
            this.log = log;
        }

        // methods
    }

### Usage

    public class LogInjector extends FactoryInjector<Log> {
        public Log getComponentInstance(PicoContainer container, final Type into) throws PicoCompositionException {
            return LogFactory.getLog((Class) into);
        }
    }
    ...
    pico = new DefaultPicoContainer(new ConstructorInjection());
    pico.addComponent(Apple.class);
    pico.addAdapter(new LogInjector());
    // etc
    Apple apple = pico.getComponent(Apple.class);

We have implementations in this style for Log4j, Commons-Logging, Java-Logging and SLF4J. They are in the org.picocontainer.gems.injectors package.