首页 > 其他 > 详细

@ComponentScan源码学习

时间:2020-04-11 11:05:01      阅读:51      评论:0      收藏:0      [点我收藏+]
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package org.springframework.context.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.annotation.AliasFor;

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
//在一个类中可重复定义
@Repeatable(ComponentScans.class)
public @interface ComponentScan {

    //定义扫描的包
    @AliasFor("basePackages")
    String[] value() default {};

    //定义扫描的包
    @AliasFor("value")
    String[] basePackages() default {};

    //定义扫描的类
    Class<?>[] basePackageClasses() default {};

    //Bean name生成器
    Class<? extends BeanNameGenerator> nameGenerator() default BeanNameGenerator.class;

    //作用域解析器
    Class<? extends ScopeMetadataResolver> scopeResolver() default AnnotationScopeMetadataResolver.class;

    //作用域代理模式
    ScopedProxyMode scopedProxy() default ScopedProxyMode.DEFAULT;

    //资源匹配模式
    String resourcePattern() default "**/*.class";

    //是否启动默认的过滤器
    boolean useDefaultFilters() default true;

    //当满足过滤条件时扫描
    ComponentScan.Filter[] includeFilters() default {};

    //当不满足过滤条件时扫描
    ComponentScan.Filter[] excludeFilters() default {};

    //是否延迟初始化
    boolean lazyInit() default false;

    //自定义过滤器
    @Retention(RetentionPolicy.RUNTIME)
    @Target({})
    public @interface Filter {

        //过滤器类型,可以按注解类型或者正则式等过滤
        FilterType type() default FilterType.ANNOTATION;

        //定义过滤的类
        @AliasFor("classes")
        Class<?>[] value() default {};

        //定义过滤的类
        @AliasFor("value")
        Class<?>[] classes() default {};

        //匹配方式
        String[] pattern() default {};
    }
}

@ComponentScan源码学习

原文:https://www.cnblogs.com/xl4ng/p/12677821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!