美文网首页
ListableBeanFactory源码解析

ListableBeanFactory源码解析

作者: 别拿爱情当饭吃 | 来源:发表于2019-04-28 10:06 被阅读0次

    Spring版本:4.X

    public interface ListableBeanFactory extends BeanFactory {
    
        //根据beanName,检查容器是否含有BeanDefinition
        boolean containsBeanDefinition(String beanName);
    
        //返回容器含有的BeanDefinition总数
        int getBeanDefinitionCount();
    
        //返回容器中所有bean的名字
        String[] getBeanDefinitionNames();
    
        //根据类型返回BeanNames
        String[] getBeanNamesForType(ResolvableType type);
    
        //根据类型(包括子类)返回BeanNames
        String[] getBeanNamesForType(Class<?> type);
    
        /**根据类型(包括子类)返回BeanNames
        *includeNonSingletons:false,代表只包含单例;true,代表包含多例、单例
        *allowEagerInit:是否懒加载(注意:FactoryBeans都是立即加载)
        */
        String[] getBeanNamesForType(Class<?> type, boolean includeNonSingletons, boolean allowEagerInit);
    
        //根据类型(包括子类)返回Map(BeanName,BeanInstance)
        <T> Map<String, T> getBeansOfType(Class<T> type) throws BeansException;
    
        /**根据类型(包括子类)返回Map(BeanNames,BeanInstance)
        *includeNonSingletons:false,代表只包含单例;true,代表包含多例、单例
        *allowEagerInit:是否懒加载(注意:FactoryBeans都是立即加载)
        */
        <T> Map<String, T> getBeansOfType(Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
                throws BeansException;
    
        //查找所有使用注解的类,返回BeanNames
        String[] getBeanNamesForAnnotation(Class<? extends Annotation> annotationType);
    
        //根据注解的类型,返回Map(BeanNames,BeanInstance)
        Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType) throws BeansException;
    
         //根据注解类型和BeanName来查找指定的Bean
        <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
                throws NoSuchBeanDefinitionException;
    
    }
    
    

    相关文章

      网友评论

          本文标题:ListableBeanFactory源码解析

          本文链接:https://www.haomeiwen.com/subject/jogrnqtx.html