Package org.picocontainer.defaults

This package contains the default implementation of the PicoContainer API.

See:
          Description

Interface Summary
ComponentAdapterFactory A component adapter factory is responsible for creating component adapters.
ObjectReference A way to refer to objects that are stored in "awkward" places (for example inside a HttpSession or ThreadLocal).
 

Class Summary
AbstractComponentAdapter Base class for a ComponentAdapter with general functionality.
BeanPropertyComponentAdapter Decorating component adapter that can be used to set additional properties on a component.
BeanPropertyComponentAdapterFactory  
CachingComponentAdapter This ComponentAdapter caches the instance.
CachingComponentAdapterFactory  
ComponentParameter A ComponentParameter should be used to pass in a particular component as argument to a different component's constructor.
ConstantParameter A ConstantParameter should be used to pass in "constant" arguments to constructors.
ConstructorInjectionComponentAdapter Instantiates components using Constructor Injection.
ConstructorInjectionComponentAdapterFactory  
DecoratingComponentAdapter  
DecoratingComponentAdapterFactory  
DefaultComponentAdapterFactory Creates instances of ConstructorInjectionComponentAdapter decorated by CachingComponentAdapter.
DefaultPicoContainer

The Standard PicoContainer/MutablePicoContainer implementation.

InstanceComponentAdapter  
InstantiatingComponentAdapter This ComponentAdapter will instantiate a new object for each call to ComponentAdapter.getComponentInstance().
SetterInjectionComponentAdapter Instantiates components using empty constructors and Setter Injection.
SetterInjectionComponentAdapterFactory A ComponentAdapterFactory for JavaBeans.
SimpleReference  
SynchronizedComponentAdapter  
SynchronizedComponentAdapterFactory  
 

Exception Summary
AmbiguousComponentResolutionException Exception that is thrown as part of the introspection.
AssignabilityRegistrationException A subclass of PicoRegistrationException that is thrown during component registration if the component's key is a type and the implementation is not assignable to.
CyclicDependencyException  
DuplicateComponentKeyRegistrationException  
NotConcreteRegistrationException  
PicoInvocationTargetInitializationException  
TooManySatisfiableConstructorsException  
UnsatisfiableDependenciesException  
 

Package org.picocontainer.defaults Description

This package contains the default implementation of the PicoContainer API. The main class in this package is DefaultPicoContainer, which satisfies both the PicoContainer and MutablePicoContainer contracts. In addition, it allows passing in of a ComponentAdapterFactory, which can be used to customize the type of ComponentAdapter that is used for components that are added to the container for which no component adapter is specified explicitly.

This page contains a brief low-level overview of the default picocontainer implementation package. Much more documentation is available on the PicoContainer website.

Buzzwords

The implementation provided in this package is very extensible, embeddable and lightweight, to get a few buzzwords out of the way.

Notes on Exceptions

Almost all exceptions thrown in this package are subclasses of PicoException, which is a subclass of RuntimeException. Furthermore, those exceptions are usually be subclasses of the basic pico exception types specified in the API. As an example, CyclicDependencyException is a specialization of PicoInitializationException.

It is not recommended that you catch the specific exceptions thrown in this package (except perhaps if you're developing your own container based on this package). Rather catch the broader exception classes defined as part of the core PicoContainer API, and minimize the ties your application has to the implementation package.

Notes on ComponentAdapters and ComponentAdapterFactories

Most of the ComponentAdapter implementations in this package are subclasses of either AbstractComponentAdapter or DecoratingComponentAdapter. Subclasses of the former can generally be used on their own, whereas subclasses of the latter wrap another ComponentAdapter, providing slightly different behaviour or additional functionality. For example, CachingComponentAdapter extends DecoratingComponentAdapter. It can wrap any other adapter to provide a singleton-like behaviour (where a single component instance is kept per container). Contrast this with ConstructorInjectionComponentAdapter (a subclass of AbstractComponentAdapter), which actually creates instances (using, in this case, constructor dependency injection).

All component adapters in this package include a matching ComponentAdapterFactory. The classnames of those factories can always be found simply by appending "Factory" to the name of the component adapter class. One adapter factory deserves special mention: DefaultComponentAdapterFactory is the factory that is used by DefaultPicoContainer if none is explicitly specified.

It is recommended that you follow similar patterns if you write your own component adapters. If you are not sure what type of adapter you need, it is often a good idea to start with a decorating component adapter, so that you can mix and match functionality from the existing adapters with your own. Also, always try to include a ComponentAdapterFactory for your custom adapter.

Notes on Parameters

Advanced PicoContainer users may need to have full control over what parameters are fed to components on instantiation, and the PicoContainer API provides this control via the Parameter class. The default implementation provides two commonly used parameter implementations: ConstantParameter for passing "constants" (like primitive types and strings) to components and ConstantParameter for passing a specific argument to the component by specifying the key that should be used in retrieving that argument from the container.



Copyright © 2003-2004 Codehaus. All Rights Reserved.