Class ClassPathScanningCandidateComponentProvider

  • java.lang.Object
    • org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider
    • Field Detail

      • logger

        protected final Log logger
    • Constructor Detail

      • ClassPathScanningCandidateComponentProvider

        protected ClassPathScanningCandidateComponentProvider()
        Protected constructor for flexible subclass initialization.
      • ClassPathScanningCandidateComponentProvider

        public ClassPathScanningCandidateComponentProvider(boolean useDefaultFilters,
                                                           Environment environment)
        Create a ClassPathScanningCandidateComponentProvider with the given Environment.
        useDefaultFilters - whether to register the default filters for the @Component, @Repository, @Service, and @Controller stereotype annotations
        environment - the Environment to use
        See Also:
    • Method Detail

      • addIncludeFilter

        public void addIncludeFilter(TypeFilter includeFilter)
        Add an include type filter to the end of the inclusion list.
      • addExcludeFilter

        public void addExcludeFilter(TypeFilter excludeFilter)
        Add an exclude type filter to the front of the exclusion list.
      • registerDefaultFilters

        protected void registerDefaultFilters()
        Register the default filter for @Component.

        This will implicitly register all annotations that have the @Component meta-annotation including the @Repository, @Service, and @Controller stereotype annotations.

        Also supports Java EE 6's ManagedBean and JSR-330's Named annotations, if available.

      • setEnvironment

        public void setEnvironment(Environment environment)
        Set the Environment to use when resolving placeholders and evaluating @Conditional-annotated component classes.

        The default is a StandardEnvironment.

        environment - the Environment to use
      • getResourceLoader

        public final ResourceLoader getResourceLoader()
        Return the ResourceLoader that this component provider uses.
      • getMetadataReaderFactory

        public final MetadataReaderFactory getMetadataReaderFactory()
        Return the MetadataReaderFactory used by this component provider.
      • findCandidateComponents

        public java.util.Set<BeanDefinition> findCandidateComponents(java.lang.String basePackage)
        Scan the class path for candidate components.
        basePackage - the package to check for annotated classes
        a corresponding Set of autodetected bean definitions
      • resolveBasePackage

        protected java.lang.String resolveBasePackage(java.lang.String basePackage)
        Resolve the specified base package into a pattern specification for the package search path.

        The default implementation resolves placeholders against system properties, and converts a "."-based package path to a "/"-based resource path.

        basePackage - the base package as specified by the user
        the pattern specification to be used for package searching
      • isCandidateComponent

        protected boolean isCandidateComponent(MetadataReader metadataReader)
        Determine whether the given class does not match any exclude filter and does match at least one include filter.
        metadataReader - the ASM ClassReader for the class
        whether the class qualifies as a candidate component
      • isCandidateComponent

        protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition)
        Determine whether the given bean definition qualifies as candidate.

        The default implementation checks whether the class is not an interface and not dependent on an enclosing class.

        Can be overridden in subclasses.

        beanDefinition - the bean definition to check
        whether the bean definition qualifies as a candidate component
      • clearCache

        public void clearCache()
        Clear the local metadata cache, if any, removing all cached class metadata.