|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.di.impl.SimpleBeanStoreImpl
public class SimpleBeanStoreImpl
A helper class that simplifies implementations of the BeanStore
interface.
The purpose of this class is to support BeanStore
implementations based on classes that are not aware of BeanProviders,
but provide a map-like interface for accessing their data. This is achieved
in the following ways:
ConstantBeanProvider objects are created for the
data objects to be managed. These providers are directly exposed through the
BeanStore methods.BeanContributor interface and register themselves at a
SimpleBeanStoreImpl instance. The BeanConstributor
interface is much easier to implement than the BeanStore
interface. The implementations of the BeanStore methods provided
by this class take the registered BeanContributors into account.
BeanStore interface that do not directly deal
with bean providers are already implemented by this class.Note: The class per se is not thread-safe. When used inside the dependency injection framework, proper synchronization is automatically applied. But during initialization or for other use cases the developer has to ensure that there are no concurrent accesses.
| Nested Class Summary | |
|---|---|
static interface |
SimpleBeanStoreImpl.BeanContributor
Definition of an interface for objects that can contribute beans for a SimpleBeanStoreImpl object. |
| Constructor Summary | |
|---|---|
SimpleBeanStoreImpl()
Creates a new instance of SimpleBeanStoreImpl. |
|
SimpleBeanStoreImpl(java.lang.String name,
BeanStore parent)
Creates a new instance of SimpleBeanStoreImpl and sets the
name and the reference to the parent. |
|
| Method Summary | |
|---|---|
void |
addBean(java.lang.String name,
java.lang.Object bean)
Adds the specified bean to this store. |
void |
addBeanContributor(SimpleBeanStoreImpl.BeanContributor contr)
Adds a new BeanContributor to this object. |
BeanProvider |
getBeanProvider(java.lang.String name)
Returns a BeanProvider for the bean with the given name. |
java.lang.String |
getName()
Returns the name of this bean store. |
BeanStore |
getParent()
Returns the parent bean store. |
protected BeanProvider |
providerFor(java.lang.Object bean)
Returns a bean provider for the specified bean. |
java.util.Set<java.lang.String> |
providerNames()
Returns a set with the names of the available bean providers. |
java.lang.Object |
removeBean(java.lang.String name)
Removes the bean with the given name. |
void |
removeBeanContributor(SimpleBeanStoreImpl.BeanContributor contr)
Removes the specified bean contributor from this object. |
void |
setName(java.lang.String name)
Sets the name of this bean store. |
void |
setParent(BeanStore parent)
Sets the parent bean store. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleBeanStoreImpl()
SimpleBeanStoreImpl.
public SimpleBeanStoreImpl(java.lang.String name,
BeanStore parent)
SimpleBeanStoreImpl and sets the
name and the reference to the parent.
name - the name of this bean storeparent - the reference to the parent bean store| Method Detail |
|---|
public void addBeanContributor(SimpleBeanStoreImpl.BeanContributor contr)
BeanContributor to this object. This
contributor will be triggered when this bean store is accessed.
contr - the contributor to be added (must not be null)
java.lang.IllegalArgumentException - if the contributor is nullpublic void removeBeanContributor(SimpleBeanStoreImpl.BeanContributor contr)
contr - the contributor to remove
public void addBean(java.lang.String name,
java.lang.Object bean)
getBeanProvider() method.
name - the name of the bean (must not be null)bean - the bean (must not be null)
java.lang.IllegalArgumentException - if the name or the bean is nullpublic java.lang.Object removeBean(java.lang.String name)
name - the name of the bean to be removed
public BeanProvider getBeanProvider(java.lang.String name)
BeanProvider for the bean with the given name.
This implementation checks whether such a bean was directly added using
the addBean() method. If not, the registered bean
contributors are consulted. If no such bean can be found, null is
returned.
getBeanProvider in interface BeanStorename - the name of the bean in question
BeanProvider for this beanpublic java.lang.String getName()
getName in interface BeanStorepublic void setName(java.lang.String name)
name - the new namepublic BeanStore getParent()
getParent in interface BeanStorepublic void setParent(BeanStore parent)
parent - the parent bean storepublic java.util.Set<java.lang.String> providerNames()
providerNames in interface BeanStoreprotected BeanProvider providerFor(java.lang.Object bean)
ConstantBeanProvider for the
passed in bean.
bean - the bean
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||