Package org.picocontainer.defaults

This package contains the default implementation of the PicoContainer API.

See:
          Description

Interface Summary
CollectionComponentParameterTestCase.Fish  
DefaultPicoContainerTestCase.A  
SetterInjectionComponentAdapterFactoryTestCase.Bean  
UserQuestionTestCase.ABC  
UserQuestionTestCase.Bar  
UserQuestionTestCase.Cheese  
UserQuestionTestCase.DEF  
UserQuestionTestCase.Foo  
UserQuestionTestCase.InterfaceX  
 

Class Summary
BeanPropertyComponentAdapterFactoryTestCase  
BeanPropertyComponentAdapterFactoryTestCase.A  
BeanPropertyComponentAdapterFactoryTestCase.B  
BeanPropertyComponentAdapterFactoryTestCase.Failing  
BeanPropertyComponentAdapterFactoryTestCase.Foo  
BeanPropertyComponentAdapterFactoryTestCase.Primitives Class that contains all types of Java primitives, to test if they are set correctly.
BeanPropertyComponentAdapterTestCase  
CachingComponentAdapterFactoryTestCase  
CachingComponentAdapterTestCase  
ChildContainerTestCase  
CollectionComponentParameterTestCase  
CollectionComponentParameterTestCase.AnotherGenericCollectionBowl  
CollectionComponentParameterTestCase.Bowl  
CollectionComponentParameterTestCase.Cod  
CollectionComponentParameterTestCase.CollectedBowl  
CollectionComponentParameterTestCase.DependsOnAll  
CollectionComponentParameterTestCase.MappedBowl  
CollectionComponentParameterTestCase.Shark  
CollectionComponentParameterTestCase.TouchableObserver  
CollectionComponentParameterTestCase.Truc  
CollectionComponentParameterTestCase.UngenericCollectionBowl  
ComponentAdapterTestCase Test AbstractComponentAdapter behaviour
ComponentKeysTestCase  
ConstantParameterTestCase test that constant parameter behaves well.
ConstructorInjectionComponentAdapterFactoryTestCase  
ConstructorInjectionComponentAdapterTestCase  
ConstructorInjectionComponentAdapterTestCase.A  
ConstructorInjectionComponentAdapterTestCase.B  
ConstructorInjectionComponentAdapterTestCase.C1  
ConstructorInjectionComponentAdapterTestCase.C2  
ConstructorInjectionComponentAdapterTestCase.Component201  
ConstructorInjectionComponentAdapterTestCase.Erroneous  
ConstructorInjectionComponentAdapterTestCase.NamedDependsOnTouchable  
ConstructorInjectionComponentAdapterTestCase.NormalExceptionThrowing  
ConstructorInjectionComponentAdapterTestCase.RuntimeThrowing  
CyclicDependencyGuardTestCase Test the CyclicDependecy.
DecoratingComponentAdapterTestCase  
DefaultComponentAdapterFactoryTestCase  
DefaultComponentRegistryTestCase  
DefaultLazyInstantiationTestCase  
DefaultLifecycleStrategyTestCase  
DefaultMultipleConstructorTestCase  
DefaultPicoContainerLifecycleTestCase This class tests the lifecycle aspects of DefaultPicoContainer.
DefaultPicoContainerLifecycleTestCase.FooRunnable  
DefaultPicoContainerLifecycleTestCase.NotStartable  
DefaultPicoContainerTestCase  
DefaultPicoContainerTestCase.DependsOnCollection  
DefaultPicoContainerTestCase.FailingLifecycleStrategy  
DefaultPicoContainerTestCase.MyPicoContainer  
DefaultPicoContainerTestCase.MyStartable  
DefaultPicoContainerTestCase.Service  
DefaultPicoContainerTestCase.SimpleA  
DefaultPicoContainerTestCase.Thingie  
DefaultPicoContainerTestCase.TransientComponent  
DefaultPicoContainerTestCase.WrappingA  
DefaultPicoContainerTreeSerializationTestCase  
DelegatingComponentMonitorTestCase  
DelegatingPicoContainerTestCase  
GenericsTestCase Uncomment all the tests in this class (as well as the obvious places in ConstructorInjectionComponentAdapter) in order to run with generics support Requires JDK 1.5 with generics enabled.
ImmutablePicoContainerProxyFactoryTest  
ImplementationHidingComponentAdapterTestCase  
InstanceComponentAdapterTestCase Test the InstanceComponentAdapter.
LifecycleVisitorTestCase  
LifecycleVisitorTestCase.Four  
LifecycleVisitorTestCase.One  
LifecycleVisitorTestCase.RecordingLifecycle  
LifecycleVisitorTestCase.Three  
LifecycleVisitorTestCase.Two  
MethodCallingVisitorTest  
NoneOfTheseTestsAffectCoverageMeaningTheyCouldGoTestCase  
NoneOfTheseTestsAffectCoverageMeaningTheyCouldGoTestCase.Dino  
NoneOfTheseTestsAffectCoverageMeaningTheyCouldGoTestCase.Dino2  
NoneOfTheseTestsAffectCoverageMeaningTheyCouldGoTestCase.Dino3  
NoneOfTheseTestsAffectCoverageMeaningTheyCouldGoTestCase.Dino4  
ParameterTestCase  
PicoExceptionsTestCase Unit tests for the several PicoException classes.
PicoVisitorTestCase Test general PicoVisitor behaviour.
SetterInjectionComponentAdapterFactoryTestCase  
SetterInjectionComponentAdapterFactoryTestCase.NamedBean  
SetterInjectionComponentAdapterFactoryTestCase.NamedBeanWithPossibleDefault  
SetterInjectionComponentAdapterFactoryTestCase.NoBean  
SetterInjectionComponentAdapterTestCase  
SetterInjectionComponentAdapterTestCase.A  
SetterInjectionComponentAdapterTestCase.B  
SetterInjectionComponentAdapterTestCase.C  
SetterInjectionComponentAdapterTestCase.DeadBody  
SetterInjectionComponentAdapterTestCase.Ghost  
SetterInjectionComponentAdapterTestCase.HidingPersion  
SetterInjectionComponentAdapterTestCase.MoneyPurse  
SetterInjectionComponentAdapterTestCase.WealthyPerson  
SetterInjectionComponentAdapterTestCase.Yang  
SetterInjectionComponentAdapterTestCase.Yin  
SetterIntrospectorTestCase  
SetterIntrospectorTestCase.TestBean  
SynchronizedComponentAdapterTestCase  
SynchronizedComponentAdapterTestCase.SlowCtor  
TraversalCheckingVisitorTestCase  
UserQuestionTestCase This class can be used to test out various things asked on the mailing list.
UserQuestionTestCase.ABCImpl  
UserQuestionTestCase.CheeseComponentAdapter  
UserQuestionTestCase.DEFImpl  
UserQuestionTestCase.Disabled  
UserQuestionTestCase.Enabled  
UserQuestionTestCase.FooBar  
UserQuestionTestCase.Gouda  
UserQuestionTestCase.NeedsBar  
UserQuestionTestCase.NeedsFoo  
UserQuestionTestCase.NeedsInterfaceX  
UserQuestionTestCase.Omelette  
UserQuestionTestCase.Roquefort  
UserQuestionTestCase.Something  
XStreamSerialisationTestCase  
 

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-2007 Codehaus. All Rights Reserved.