Class BeanFactoryUtils


  • public abstract class BeanFactoryUtils
    extends io.microsphere.util.BaseUtils
    BeanFactory Utilities class
    Since:
    1.0.0
    Author:
    Mercy
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.springframework.beans.factory.config.AutowireCapableBeanFactory asAutowireCapableBeanFactory​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.support.BeanDefinitionRegistry asBeanDefinitionRegistry​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.config.ConfigurableBeanFactory asConfigurableBeanFactory​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.config.ConfigurableListableBeanFactory asConfigurableListableBeanFactory​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.support.DefaultListableBeanFactory asDefaultListableBeanFactory​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.HierarchicalBeanFactory asHierarchicalBeanFactory​(java.lang.Object beanFactory)  
      static org.springframework.beans.factory.ListableBeanFactory asListableBeanFactory​(java.lang.Object beanFactory)  
      static java.util.List<org.springframework.beans.factory.config.BeanPostProcessor> getBeanPostProcessors​(org.springframework.beans.factory.BeanFactory beanFactory)
      Get all instances of BeanPostProcessor in the specified BeanFactory
      static <T> java.util.List<T> getBeans​(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String[] beanNames, java.lang.Class<T> beanType)
      Gets name-matched Beans from BeanFactory
      static <T> T getOptionalBean​(org.springframework.beans.factory.ListableBeanFactory beanFactory, java.lang.String beanName, java.lang.Class<T> beanType)
      Get optional Bean
      static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Get the registered Resolvable Dependency Types
      static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes​(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
      Get the registered Resolvable Dependency Types
      static boolean isBeanDefinitionRegistry​(java.lang.Object beanFactory)  
      static boolean isDefaultListableBeanFactory​(java.lang.Object beanFactory)
      Is the given BeanFactory DefaultListableBeanFactory
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BeanFactoryUtils

        public BeanFactoryUtils()
    • Method Detail

      • getOptionalBean

        public static <T> T getOptionalBean​(org.springframework.beans.factory.ListableBeanFactory beanFactory,
                                            java.lang.String beanName,
                                            java.lang.Class<T> beanType)
        Get optional Bean
        Type Parameters:
        T - the type of Bean
        Parameters:
        beanFactory - ListableBeanFactory
        beanName - the name of Bean
        beanType - the type of Bean
        Returns:
        A bean if present , or null
      • getBeans

        public static <T> java.util.List<T> getBeans​(org.springframework.beans.factory.ListableBeanFactory beanFactory,
                                                     java.lang.String[] beanNames,
                                                     java.lang.Class<T> beanType)
        Gets name-matched Beans from BeanFactory
        Type Parameters:
        T - the type of Bean
        Parameters:
        beanFactory - BeanFactory
        beanNames - the names of Bean
        beanType - the type of Bean
        Returns:
        the read-only and non-null List of Bean names
      • isDefaultListableBeanFactory

        public static boolean isDefaultListableBeanFactory​(java.lang.Object beanFactory)
        Is the given BeanFactory DefaultListableBeanFactory
        Parameters:
        beanFactory - BeanFactory
        Returns:
        true if it's DefaultListableBeanFactory, false otherwise
      • isBeanDefinitionRegistry

        public static boolean isBeanDefinitionRegistry​(java.lang.Object beanFactory)
      • asBeanDefinitionRegistry

        public static org.springframework.beans.factory.support.BeanDefinitionRegistry asBeanDefinitionRegistry​(java.lang.Object beanFactory)
      • asListableBeanFactory

        public static org.springframework.beans.factory.ListableBeanFactory asListableBeanFactory​(java.lang.Object beanFactory)
      • asHierarchicalBeanFactory

        public static org.springframework.beans.factory.HierarchicalBeanFactory asHierarchicalBeanFactory​(java.lang.Object beanFactory)
      • asConfigurableBeanFactory

        public static org.springframework.beans.factory.config.ConfigurableBeanFactory asConfigurableBeanFactory​(java.lang.Object beanFactory)
      • asAutowireCapableBeanFactory

        public static org.springframework.beans.factory.config.AutowireCapableBeanFactory asAutowireCapableBeanFactory​(java.lang.Object beanFactory)
      • asConfigurableListableBeanFactory

        public static org.springframework.beans.factory.config.ConfigurableListableBeanFactory asConfigurableListableBeanFactory​(java.lang.Object beanFactory)
      • asDefaultListableBeanFactory

        public static org.springframework.beans.factory.support.DefaultListableBeanFactory asDefaultListableBeanFactory​(java.lang.Object beanFactory)
      • getResolvableDependencyTypes

        public static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes​(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
        Get the registered Resolvable Dependency Types
        Parameters:
        beanFactory - ConfigurableListableBeanFactory
        Returns:
        non-null read-only Set
      • getResolvableDependencyTypes

        public static java.util.Set<java.lang.Class<?>> getResolvableDependencyTypes​(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
        Get the registered Resolvable Dependency Types
        Parameters:
        beanFactory - DefaultListableBeanFactory
        Returns:
        non-null read-only Set
      • getBeanPostProcessors

        public static java.util.List<org.springframework.beans.factory.config.BeanPostProcessor> getBeanPostProcessors​(@Nullable
                                                                                                                       org.springframework.beans.factory.BeanFactory beanFactory)
        Get all instances of BeanPostProcessor in the specified BeanFactory
        Parameters:
        beanFactory - BeanFactory
        Returns:
        non-null List