org.apache.cocoon.spring.configurator.impl
Class BeanMap

java.lang.Object
  extended byorg.apache.cocoon.spring.configurator.impl.BeanMap
All Implemented Interfaces:
BeanFactoryAware, Map

public class BeanMap
extends Object
implements Map, BeanFactoryAware

This is a map implementation collecting all beans of a specific type (class) from a spring bean factory. The beans are available through their configured bean id. The map has a lazy implementation: the beans are not searched on instantiation but the first time the map is accessed. This avoids any startup ordering problems. By default the map searches in the bean factory it is used in and in all the parent bean factories (if there are any). This behaviour can be changed by calling the setCheckParent(boolean) method.

Since:
1.0.1
Version:
$Id: BeanMap.java 587750 2007-10-24 02:35:22Z vgritsenko $

Nested Class Summary
 
Nested classes inherited from class java.util.Map
Map.Entry
 
Field Summary
protected  Class beanClass
          The class for all beans in this map.
protected  ListableBeanFactory beanFactory
          The bean factory.
protected  Map beanMap
          The real map.
protected  boolean checkParent
          Do we check the parent factories?
protected  List hasProperties
          Do we check for properties?
protected  boolean initialized
          Is the map initialized?
protected  String keyProperty
          Which property should we use to key the map?
protected  boolean stripPrefix
          Do we strip the prefix from the bean name?
 
Constructor Summary
BeanMap()
           
 
Method Summary
protected  void checkInit()
          Check if the bean is already initialized.
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set entrySet()
           
 boolean equals(Object obj)
           
 Object get(Object key)
           
protected  void getBeanNames(ListableBeanFactory factory, Set beanNames)
          Get all bean names for the given type.
 int hashCode()
           
 boolean isEmpty()
           
 Set keySet()
           
protected  void load(Set beanNames)
          Get all the bean's from the bean factory and put them into a map using their id.
 Object put(Object key, Object value)
           
 void putAll(Map t)
           
 Object remove(Object key)
           
 void setBeanFactory(BeanFactory factory)
           
 void setCheckParent(boolean checkParent)
           
 void setHasProperties(String pHasProperties)
           
 void setKeyProperty(String pKeyProperty)
           
 void setStripPrefix(boolean stripPrefix)
           
 void setType(Class typeClass)
           
 int size()
           
 String toString()
           
 Collection values()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

beanMap

protected Map beanMap
The real map.


initialized

protected boolean initialized
Is the map initialized?


beanFactory

protected ListableBeanFactory beanFactory
The bean factory.


beanClass

protected Class beanClass
The class for all beans in this map.


stripPrefix

protected boolean stripPrefix
Do we strip the prefix from the bean name?


checkParent

protected boolean checkParent
Do we check the parent factories?


hasProperties

protected List hasProperties
Do we check for properties?


keyProperty

protected String keyProperty
Which property should we use to key the map?

Constructor Detail

BeanMap

public BeanMap()
Method Detail

load

protected void load(Set beanNames)
Get all the bean's from the bean factory and put them into a map using their id.

Parameters:
beanNames - The bean names to load.

checkInit

protected void checkInit()
Check if the bean is already initialized. If not, the bean's are searched in the bean factory.


getBeanNames

protected void getBeanNames(ListableBeanFactory factory,
                            Set beanNames)
Get all bean names for the given type.

Parameters:
factory - The bean factory.
beanNames - The set containing the resulting bean names.

setBeanFactory

public void setBeanFactory(BeanFactory factory)
                    throws BeansException
Specified by:
setBeanFactory in interface BeanFactoryAware
Throws:
BeansException
See Also:
BeanFactoryAware.setBeanFactory(org.springframework.beans.factory.BeanFactory)

setStripPrefix

public void setStripPrefix(boolean stripPrefix)

setCheckParent

public void setCheckParent(boolean checkParent)

setHasProperties

public void setHasProperties(String pHasProperties)

setKeyProperty

public void setKeyProperty(String pKeyProperty)

setType

public void setType(Class typeClass)

clear

public void clear()
Specified by:
clear in interface Map
See Also:
Map.clear()

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map
See Also:
Map.containsKey(java.lang.Object)

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map
See Also:
Map.containsValue(java.lang.Object)

entrySet

public Set entrySet()
Specified by:
entrySet in interface Map
See Also:
Map.entrySet()

get

public Object get(Object key)
Specified by:
get in interface Map
See Also:
Map.get(java.lang.Object)

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map
See Also:
Map.isEmpty()

keySet

public Set keySet()
Specified by:
keySet in interface Map
See Also:
Map.keySet()

put

public Object put(Object key,
                  Object value)
Specified by:
put in interface Map
See Also:
Map.put(java.lang.Object, java.lang.Object)

putAll

public void putAll(Map t)
Specified by:
putAll in interface Map
See Also:
Map.putAll(java.util.Map)

remove

public Object remove(Object key)
Specified by:
remove in interface Map
See Also:
Map.remove(java.lang.Object)

size

public int size()
Specified by:
size in interface Map
See Also:
Map.size()

values

public Collection values()
Specified by:
values in interface Map
See Also:
Map.values()

equals

public boolean equals(Object obj)
Specified by:
equals in interface Map
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Specified by:
hashCode in interface Map
See Also:
Object.hashCode()

toString

public String toString()
See Also:
Object.toString()


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.