Class AnnotationBeanDefinitionRegistryPostProcessor

java.lang.Object
io.microsphere.spring.beans.factory.annotation.AnnotationBeanDefinitionRegistryPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware

public abstract class AnnotationBeanDefinitionRegistryPostProcessor extends Object implements org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware, org.springframework.beans.factory.BeanClassLoaderAware
An abstract class for the extension to BeanDefinitionRegistryPostProcessor, which will execute two main registration methods orderly:
  1. registerPrimaryBeanDefinitions(ExposingClassPathBeanDefinitionScanner, String[]) : Scan and register the primary BeanDefinitions that were annotated by the supported annotation types, and then return the Map with bean name plus aliases if present and primary AnnotatedBeanDefinitions, it's allowed to be override
  2. registerSecondaryBeanDefinitions(ExposingClassPathBeanDefinitionScanner, Map, String[]) : it's mandatory to be override by the sub-class to register secondary BeanDefinitions if required
Since:
1.0.0
Author:
Mercy
  • Field Details

    • logger

      protected final io.microsphere.logging.Logger logger
  • Constructor Details

    • AnnotationBeanDefinitionRegistryPostProcessor

      public AnnotationBeanDefinitionRegistryPostProcessor(Class<? extends Annotation> primaryAnnotationType, Class<?>... basePackageClasses)
    • AnnotationBeanDefinitionRegistryPostProcessor

      public AnnotationBeanDefinitionRegistryPostProcessor(Class<? extends Annotation> primaryAnnotationType, String... packagesToScan)
    • AnnotationBeanDefinitionRegistryPostProcessor

      public AnnotationBeanDefinitionRegistryPostProcessor(Class<? extends Annotation> primaryAnnotationType, Iterable<String> packagesToScan)
  • Method Details

    • addSupportedAnnotationType

      public void addSupportedAnnotationType(Class<? extends Annotation>... annotationTypes)
    • getAnnotation

      protected static Annotation getAnnotation(AnnotatedElement annotatedElement, Class<? extends Annotation> annotationType)
    • postProcessBeanDefinitionRegistry

      public final void postProcessBeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry registry) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanDefinitionRegistry in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • registerPrimaryBeanDefinitions

      protected Map<String,org.springframework.beans.factory.annotation.AnnotatedBeanDefinition> registerPrimaryBeanDefinitions(ExposingClassPathBeanDefinitionScanner scanner, String[] basePackages)
      Scan and register the primary BeanDefinitions that were annotated by the supported annotation types, and then return the Map with bean name plus aliases if present and primary AnnotatedBeanDefinitions.

      Current method is allowed to be override by the sub-class to change the registration logic

      Parameters:
      scanner - ExposingClassPathBeanDefinitionScanner
      basePackages - the base packages to scan
      Returns:
      the Map with bean name plus aliases if present and primary AnnotatedBeanDefinitions
    • registerSecondaryBeanDefinitions

      protected abstract void registerSecondaryBeanDefinitions(ExposingClassPathBeanDefinitionScanner scanner, Map<String,org.springframework.beans.factory.annotation.AnnotatedBeanDefinition> primaryBeanDefinitions, String[] basePackages)
      Register the secondary BeanDefinitions

      Current method is allowed to be override by the sub-class to change the registration logic

      Parameters:
      scanner - the ExposingClassPathBeanDefinitionScanner instance
      primaryBeanDefinitions - the Map with bean name plus aliases if present and primary AnnotatedBeanDefinitions, which may be empty
      basePackages - the base packages to scan
    • postProcessBeanFactory

      public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor
      Specified by:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • resolveBasePackages

      protected String[] resolveBasePackages(Set<String> packagesToScan)
      Resolve the placeholders for the raw scanned packages to scan
      Parameters:
      packagesToScan - the raw scanned packages to scan
      Returns:
      non-null
    • resolveBeanClass

      protected final Class<?> resolveBeanClass(org.springframework.beans.factory.config.BeanDefinitionHolder beanDefinitionHolder)
    • resolveBeanClass

      protected final Class<?> resolveBeanClass(org.springframework.beans.factory.config.BeanDefinition beanDefinition)
    • setBeanClassLoader

      public void setBeanClassLoader(ClassLoader classLoader)
      Specified by:
      setBeanClassLoader in interface org.springframework.beans.factory.BeanClassLoaderAware
    • getSupportedAnnotationTypes

      public Set<Class<? extends Annotation>> getSupportedAnnotationTypes()
    • getSupportedAnnotationTypeNames

      protected Set<String> getSupportedAnnotationTypeNames()
    • getPackagesToScan

      public Set<String> getPackagesToScan()
    • getBeanFactory

      public org.springframework.beans.factory.config.ConfigurableListableBeanFactory getBeanFactory()
    • setBeanFactory

      public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
      Throws:
      org.springframework.beans.BeansException
    • getEnvironment

      public org.springframework.core.env.ConfigurableEnvironment getEnvironment()
    • setEnvironment

      public void setEnvironment(org.springframework.core.env.Environment environment)
      Specified by:
      setEnvironment in interface org.springframework.context.EnvironmentAware
    • getResourceLoader

      public org.springframework.core.io.ResourceLoader getResourceLoader()
    • setResourceLoader

      public void setResourceLoader(org.springframework.core.io.ResourceLoader resourceLoader)
      Specified by:
      setResourceLoader in interface org.springframework.context.ResourceLoaderAware
    • getClassLoader

      public ClassLoader getClassLoader()
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)