|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.jguiraffe.di.impl.DefaultBeanStore
public class DefaultBeanStore
A simple yet fully functional default implementation of the
BeanStore interface.
This implementation is based on a HashMap.
BeanProvider objects can be added to this map using the
addBeanProvider() method. They can then be queried through the
getBeanProvider method.
Note: The underlying map is not synchronized. This does not cause any
problems when used read-only by the dependency injection framework. But if
bean providers should be concurrently added, manual synchronization is
required. The intended use case is that an instance is created and populated
with objects in an initialization phase.
Then it should only be accessed in a read-only fashion.
BeanProvider
| Constructor Summary | |
|---|---|
DefaultBeanStore()
Creates a new instance of DefaultBeanStore. |
|
DefaultBeanStore(java.lang.String name,
BeanStore parent)
Creates a new instance of DefaultBeanStore and sets the
name and the reference to the parent. |
|
| Method Summary | |
|---|---|
java.lang.String |
addAnonymousBeanProvider(int index,
BeanProvider provider)
Adds an anonymous BeanProvider. |
void |
addBeanProvider(java.lang.String name,
BeanProvider provider)
Adds the specified BeanProvider to this bean store under
the given name. |
void |
clear()
Removes all BeanProviders from this bean store. |
BeanProvider |
getBeanProvider(java.lang.String name)
Returns the BeanProvider with the specified name. |
java.lang.String |
getName()
Returns the name of this bean store. |
BeanStore |
getParent()
Returns the parent of this bean store or null if this is a top level store. |
java.util.Set<java.lang.String> |
providerNames()
Returns a set with the names of all contained bean providers. |
BeanProvider |
removeBeanProvider(java.lang.String name)
Removes the BeanProvider with the specified name from this
bean store. |
void |
setName(java.lang.String n)
Sets the name of this bean store. |
void |
setParent(BeanStore p)
Sets the parent for this bean store. |
java.lang.String |
toString()
Returns a string representation of this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultBeanStore()
DefaultBeanStore.
public DefaultBeanStore(java.lang.String name,
BeanStore parent)
DefaultBeanStore 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 addBeanProvider(java.lang.String name,
BeanProvider provider)
BeanProvider to this bean store under
the given name.
addBeanProvider in interface MutableBeanStorename - the name of the bean provider (must not be null)provider - the BeanProvider to be registered
java.lang.IllegalArgumentException - if the name or the provider is null
public java.lang.String addAnonymousBeanProvider(int index,
BeanProvider provider)
BeanProvider. This method will generate
a special name (which is mainly used internally) for the bean provider to
add and store it under this name. The name is returned.
addAnonymousBeanProvider in interface MutableBeanStoreindex - the index of the bean providerprovider - the BeanProvider to be added (must not be
null)
BeanProvider
java.lang.IllegalArgumentException - if the provider is nullpublic BeanProvider removeBeanProvider(java.lang.String name)
BeanProvider with the specified name from this
bean store. If this provider cannot be found, this operation has no
effect.
removeBeanProvider in interface MutableBeanStorename - the name of the provider to remove
public void clear()
BeanProviders from this bean store.
clear in interface MutableBeanStorepublic BeanProvider getBeanProvider(java.lang.String name)
BeanProvider with the specified name. If no
such element exists, null is returned.
getBeanProvider in interface BeanStorename - the name of the desired provider
BeanProvider with this namepublic java.lang.String getName()
getName in interface BeanStorepublic void setName(java.lang.String n)
setName in interface MutableBeanStoren - the new namepublic BeanStore getParent()
getParent in interface BeanStorepublic void setParent(BeanStore p)
setParent in interface MutableBeanStorep - the parentpublic java.util.Set<java.lang.String> providerNames()
providerNames in interface BeanStorepublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||