ch.elca.el4j.core.beans
Class BeanLocator

java.lang.Object
  extended by ch.elca.el4j.core.beans.BeanLocator
All Implemented Interfaces:
InitializingBean, ApplicationContextAware

public class BeanLocator
extends Object
implements ApplicationContextAware, InitializingBean

Locates all beans in the application context that match the configured criteria.

For the excludeBeanNames and includeBeanNames properties wildcards xxx* and *xxx are allowed. If a bean is listed in includeBeanNames and excludeBeanNames it will be excluded. Beans which exist in application context and are listed in includeBeanNames but are not an instance of a listed class in classes will be also returned on invocation of method getBeans.

Author:
Andreas Pfenninger (APR)
File-location:
BeanLocator
Last check-in date:
2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) by swismer for revision 3873

Constructor Summary
BeanLocator()
           
 
Method Summary
 void afterPropertiesSet()
          
 Map<String,Object> getBeans()
          Returns all beans that match the specified search criteria.
protected  boolean isMatch(String beanName, String mappedName)
          Returns whether the given bean name matches the mapped name.
 void setApplicationContext(ApplicationContext applicationContext)
          
 void setClasses(String classes)
           
 void setExcludeBeanNames(String excludeBeanNames)
           
 void setIncludeBeanNames(String includeBeanNames)
           
 void setIncludeFactoryBeans(boolean includeFactoryBeans)
           
 void setIncludePrototypes(boolean includePrototypes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanLocator

public BeanLocator()
Method Detail

setClasses

public void setClasses(String classes)
Parameters:
classes - The comma-delimited String of all the classes whose instances have to be located.

setExcludeBeanNames

public void setExcludeBeanNames(String excludeBeanNames)
Parameters:
excludeBeanNames - The comma-delimited String of all bean names that have to be excluded from the result.

setIncludeBeanNames

public void setIncludeBeanNames(String includeBeanNames)
Parameters:
includeBeanNames - The comma-delimited String of all bean names that have to be included in the result.

setIncludeFactoryBeans

public void setIncludeFactoryBeans(boolean includeFactoryBeans)
Parameters:
includeFactoryBeans - Whether to include FactoryBeans too or just conventional beans.

setIncludePrototypes

public void setIncludePrototypes(boolean includePrototypes)
Parameters:
includePrototypes - Whether to include prototype beans too or just singletons (also applies to FactoryBeans).

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)

Specified by:
setApplicationContext in interface ApplicationContextAware

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

getBeans

public Map<String,Object> getBeans()
Returns all beans that match the specified search criteria.

Returns:
A map with the matching beans, containing the bean names as keys and the corresponding bean instances as values.

isMatch

protected boolean isMatch(String beanName,
                          String mappedName)
Returns whether the given bean name matches the mapped name. The default implementation checks for "xxx*", "*xxx" and exact matches. Can be overridden in subclasses.

Parameters:
beanName - The bean name to check.
mappedName - The name in the configured list of names.
Returns:
True if the names match, false otherwise.


Copyright © 2005-2011 ELCA. All Rights Reserved.