| java.lang.Object org.jicarilla.container.builder.DefaultBuilder
All known Subclasses: org.jicarilla.container.integration.builder.JicarillaBuilder,
DefaultBuilder | public class DefaultBuilder implements Builder(Code) | | A Builder implementation that's backed by a container itself. In essence,
we're using a container to help build a container. The documentation for the
builder API may be a bit complex, but the usage is actually quite easy.
Just take a look at the following example:
Resolver parentContainerResolver = getParentResolver();
Resolver resolver =
DefaultBuilder.newInstance()
.addComponent( HomerImpl.class )
.addComponent( YoungHomer.class )
.addComponent( new HomerImpl() )
.addComponent( new BartImpl() )
.addComponent(
new ClassSelector( Marge.class ),
new SingletonAdapter(
new ManualFactory(
new MargeImpl()
)
)
)
.addComponent( LisaImpl.class )
.addComponent( parentContainerResolver )
.create();
Note a Builder instance is single-use, and you should create a new
instance (using
DefaultBuilder.newInstance() every time you call
DefaultBuilder.create() .
author: Leo Simons version: $Id: DefaultBuilder.java,v 1.14 2004/03/23 15:59:52 lsimons Exp $ |
Inner Class :public static class Entry | |
m_componentProviders | protected List m_componentProviders(Code) | | The providers to populate the
m_container with.
|
m_helpers | protected Container m_helpers(Code) | | A container for the helpers we will use to populate
m_container with the providers from
m_componentProviders .
|
DefaultBuilder | protected DefaultBuilder(KeyRelayingContainer container)(Code) | | Create a new builder that will be used to populate the provided
container.
Parameters: container - the container to populate. |
addComponent | public Builder addComponent(Object provider)(Code) | | Add a new provider to the container. A provider can be lots of
things: another
Container container or a generic
ResolverProvider resolver provider
Resolver , an
Adapter ,
KeyAwareAdapter ,
Entry entry , a
Class , an
Object instance , and several other things.
The builder will figure out what to do with the provider. Subclasses
may add helpers for other kinds of providers.
Parameters: provider - the provider to add to the container. the current instance. |
addComponent | public Builder addComponent(Object selectionCriterion, Object provider)(Code) | | Add a new provider to the container. See
DefaultBuilder.addComponent(Object) for a description of the supported
providers. This method also allows you to specify the selection
criterion that the container should apply when determining whether
the provider can supply an instance. The selection criterion can be
a
Selector ,
Resolver ,
Class or
an
Object . Subclasses may add helpers that support other
kinds of selection criteria.
Parameters: selectionCriterion - the selection criterion the container shoulduse when determining whether the provider can supply an instance. Parameters: provider - the provider to add to the container. the current instance. |
addHelperHelpers | protected void addHelperHelpers()(Code) | | |
addHelpers | protected void addHelpers()(Code) | | |
create | public Resolver create() throws Exception(Code) | | Finish creation of the container and get access to it. After calling
this method, you should discard this instance.
the Resolver that's backed by the container we just created throws: Exception - if a problem occurs creating the container forwhatever reason |
newInstance | public static Builder newInstance()(Code) | | Create a new builder.
a new builder instance to be used in building a single newcontainer instance. |
|
|