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 ComponentAdapter component adapters.
ComponentMonitorStrategy Interface responsible for changing monitoring strategy.
CyclicDependencyGuard Interface for a guard implementation looking after cyclic dependencies.
LifecycleStrategy An interface which specifies the lifecyle strategy on the component instance.
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.
AbstractMonitoringLifecycleStrategy Abstract base class for lifecycle strategy implementation supporting a ComponentMonitor.
AbstractPicoVisitor Abstract PicoVisitor implementation.
BasicComponentParameter A BasicComponentParameter should be used to pass in a particular component as argument to a different component's constructor.
BeanPropertyComponentAdapter Decorating component adapter that can be used to set additional properties on a component in a bean style.
BeanPropertyComponentAdapterFactory A ComponentAdapterFactory that creates BeanPropertyComponentAdapter instances.
CachingComponentAdapter ComponentAdapter implementation that caches the component instance.
CachingComponentAdapterFactory  
CollectionComponentParameter A CollectionComponentParameter should be used to support inject an Array, a Collectionor Mapof components automatically.
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.
ConstructorInjectionComponentAdapter.Guard  
ConstructorInjectionComponentAdapterFactory  
CustomPermissionsURLClassLoader CustomPermissionsURLClassLoader extends URLClassLoader, adding the abilty to programatically add permissions easily.
DecoratingComponentAdapter Component adapter which decorates another adapter.
DecoratingComponentAdapterFactory  
DefaultComponentAdapterFactory Creates instances of ConstructorInjectionComponentAdapter decorated by CachingComponentAdapter.
DefaultLifecycleStrategy Default lifecycle strategy.
DefaultPicoContainer

The Standard PicoContainer/MutablePicoContainer implementation.

DelegatingComponentMonitor A monitor which delegates to another monitor.
ImmutablePicoContainerProxyFactory A factory for immutable PicoContainer proxies.
ImplementationHidingComponentAdapter This component adapter makes it possible to hide the implementation of a real subject (behind a proxy) provided the key is an interface.
ImplementationHidingComponentAdapterFactory  
InstanceComponentAdapter Component adapter which wraps a component instance.
InstantiatingComponentAdapter This ComponentAdapter will instantiate a new object for each call to ComponentAdapter.getComponentInstance(PicoContainer).
InstantiatingComponentAdapter.Guard The cycle guard for the verification.
LifecycleVisitor Deprecated. since 1.2 in favour of LifecycleManager
MapFactory A simple factory for ordered maps: use JDK1.4's java.util.LinkedHashMap if available, or commons-collection's LinkedMap, or defaults to unordered java.util.HashMap
MethodCallingVisitor A PicoVisitor implementation, that calls methods on the components of a specific type.
MonitoringComponentAdapter Abstract ComponentAdapter supporting a ComponentMonitorStrategy.
MonitoringComponentAdapterFactory Abstract ComponentAdapterFactory supporting a ComponentMonitorStrategy.
SetterInjectionComponentAdapter Instantiates components using empty constructors and Setter Injection.
SetterInjectionComponentAdapterFactory A ComponentAdapterFactory for JavaBeans.
SimpleReference  
SynchronizedComponentAdapter  
SynchronizedComponentAdapterFactory  
ThreadLocalCyclicDependencyGuard Abstract utility class to detect recursion cycles.
TraversalCheckingVisitor Concrete implementation of Visitor which simply checks traversals.
VerifyingVisitor Visitor to verify PicoContainer instances.
 

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  
PicoVisitorTraversalException Exception for a PicoVisitor, that is dependent on a defined starting point of the traversal.
TooManySatisfiableConstructorsException  
UnsatisfiableDependenciesException Exception thrown when some of the component's dependencies are not satisfiable.
 

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.