Home » Spring-Framework-090522 » org.springframework » beans » factory » [javadoc | source]
org.springframework.beans.factory
abstract public class: BeanFactoryUtils [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.BeanFactoryUtils
Convenience methods operating on bean factories, in particular on the ListableBeanFactory interface.

Returns bean counts, bean names or bean instances, taking into account the nesting hierarchy of a bean factory (which the methods defined on the ListableBeanFactory interface don't, in contrast to the methods defined on the BeanFactory interface).

Field Summary
public static final  String GENERATED_BEAN_NAME_SEPARATOR    Separator for generated bean names. If a class name or parent name is not unique, "#1", "#2" etc will be appended, until the name becomes unique. 
Method from org.springframework.beans.factory.BeanFactoryUtils Summary:
beanNamesForTypeIncludingAncestors,   beanNamesForTypeIncludingAncestors,   beanNamesIncludingAncestors,   beanOfType,   beanOfType,   beanOfTypeIncludingAncestors,   beanOfTypeIncludingAncestors,   beansOfTypeIncludingAncestors,   beansOfTypeIncludingAncestors,   countBeansIncludingAncestors,   isFactoryDereference,   isGeneratedBeanName,   originalBeanName,   transformedBeanName
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.BeanFactoryUtils Detail:
 public static String[] beanNamesForTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type) 
    Get all bean names for the given type, including those defined in ancestor factories. Will return unique names in case of overridden bean definitions.

    Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.

    This version of beanNamesForTypeIncludingAncestors automatically includes prototypes and FactoryBeans.

 public static String[] beanNamesForTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type,
    boolean includeNonSingletons,
    boolean allowEagerInit) 
    Get all bean names for the given type, including those defined in ancestor factories. Will return unique names in case of overridden bean definitions.

    Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean).

 public static String[] beanNamesIncludingAncestors(ListableBeanFactory lbf) 
    Return all bean names in the factory, including ancestor factories.
 public static Object beanOfType(ListableBeanFactory lbf,
    Class type) throws BeansException 
    Return a single bean of the given type or subtypes, not looking in ancestor factories. Useful convenience method when we expect a single bean and don't care about the bean name.

    Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.

    This version of beanOfType automatically includes prototypes and FactoryBeans.

 public static Object beanOfType(ListableBeanFactory lbf,
    Class type,
    boolean includeNonSingletons,
    boolean allowEagerInit) throws BeansException 
    Return a single bean of the given type or subtypes, not looking in ancestor factories. Useful convenience method when we expect a single bean and don't care about the bean name.

    Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean).

 public static Object beanOfTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type) throws BeansException 
    Return a single bean of the given type or subtypes, also picking up beans defined in ancestor bean factories if the current bean factory is a HierarchicalBeanFactory. Useful convenience method when we expect a single bean and don't care about the bean name.

    Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.

    This version of beanOfTypeIncludingAncestors automatically includes prototypes and FactoryBeans.

 public static Object beanOfTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type,
    boolean includeNonSingletons,
    boolean allowEagerInit) throws BeansException 
    Return a single bean of the given type or subtypes, also picking up beans defined in ancestor bean factories if the current bean factory is a HierarchicalBeanFactory. Useful convenience method when we expect a single bean and don't care about the bean name.

    Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean).

 public static Map beansOfTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type) throws BeansException 
    Return all beans of the given type or subtypes, also picking up beans defined in ancestor bean factories if the current bean factory is a HierarchicalBeanFactory. The returned Map will only contain beans of this type.

    Does consider objects created by FactoryBeans, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type.

 public static Map beansOfTypeIncludingAncestors(ListableBeanFactory lbf,
    Class type,
    boolean includeNonSingletons,
    boolean allowEagerInit) throws BeansException 
    Return all beans of the given type or subtypes, also picking up beans defined in ancestor bean factories if the current bean factory is a HierarchicalBeanFactory. The returned Map will only contain beans of this type.

    Does consider objects created by FactoryBeans if the "allowEagerInit" flag is set, which means that FactoryBeans will get initialized. If the object created by the FactoryBean doesn't match, the raw FactoryBean itself will be matched against the type. If "allowEagerInit" is not set, only raw FactoryBeans will be checked (which doesn't require initialization of each FactoryBean).

 public static int countBeansIncludingAncestors(ListableBeanFactory lbf) 
    Count all beans in any hierarchy in which this factory participates. Includes counts of ancestor bean factories.

    Beans that are "overridden" (specified in a descendant factory with the same name) are only counted once.

 public static boolean isFactoryDereference(String name) 
    Return whether the given name is a factory dereference (beginning with the factory dereference prefix).
 public static boolean isGeneratedBeanName(String name) 
    Return whether the given name is a bean name which has been generated by the default naming strategy (containing a "#..." part).
 public static String originalBeanName(String name) 
    Extract the "raw" bean name from the given (potentially generated) bean name, excluding any "#..." suffixes which might have been added for uniqueness.
 public static String transformedBeanName(String name) 
    Return the actual bean name, stripping out the factory dereference prefix (if any, also stripping repeated factory prefixes if found).