Class AnnotatedPropertySourceLoader<A extends java.lang.annotation.Annotation>

  • Type Parameters:
    A - The type of Annotation
    All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.context.annotation.ImportSelector, org.springframework.context.EnvironmentAware, org.springframework.context.ResourceLoaderAware
    Direct Known Subclasses:
    PropertySourceExtensionLoader

    public abstract class AnnotatedPropertySourceLoader<A extends java.lang.annotation.Annotation>
    extends BeanCapableImportCandidate
    implements org.springframework.context.annotation.ImportSelector
    Abstract ImportSelector class to load the PropertySource when the configuration annotated the specified annotation
    Since:
    1.0.0
    Author:
    Mercy
    See Also:
    ResourcePropertySourceLoader, PropertySourceExtensionLoader, ImportSelector
    • Field Detail

      • NAME_ATTRIBUTE_NAME

        protected static final java.lang.String NAME_ATTRIBUTE_NAME
        See Also:
        Constant Field Values
      • logger

        protected final org.slf4j.Logger logger
    • Constructor Detail

      • AnnotatedPropertySourceLoader

        public AnnotatedPropertySourceLoader()
    • Method Detail

      • resolveAnnotationType

        protected java.lang.Class<A> resolveAnnotationType()
      • selectImports

        public final java.lang.String[] selectImports​(org.springframework.core.type.AnnotationMetadata metadata)
        Specified by:
        selectImports in interface org.springframework.context.annotation.ImportSelector
      • resolvePropertySourceName

        @NonNull
        protected final java.lang.String resolvePropertySourceName​(org.springframework.core.annotation.AnnotationAttributes attributes,
                                                                   org.springframework.core.type.AnnotationMetadata metadata)
        Resolve the name of PropertySource
        Parameters:
        attributes - AnnotationAttributes
        metadata - AnnotationMetadata
        Returns:
        non-null
      • buildPropertySourceName

        @Nullable
        protected java.lang.String buildPropertySourceName​(org.springframework.core.annotation.AnnotationAttributes attributes,
                                                           org.springframework.core.type.AnnotationMetadata metadata)
        Build the name of PropertySource
        Parameters:
        attributes - AnnotationAttributes
        metadata - AnnotationMetadata
        Returns:
        the attribute value of annotation if the "name" attribute present, or null
      • buildDefaultPropertySourceName

        @NonNull
        protected java.lang.String buildDefaultPropertySourceName​(org.springframework.core.annotation.AnnotationAttributes attributes,
                                                                  org.springframework.core.type.AnnotationMetadata metadata)
        Build the default name of PropertySource
        Parameters:
        attributes - AnnotationAttributes
        metadata - AnnotationMetadata
        Returns:
        non-null
      • loadPropertySource

        @Nullable
        protected abstract void loadPropertySource​(org.springframework.core.annotation.AnnotationAttributes attributes,
                                                   org.springframework.core.type.AnnotationMetadata metadata,
                                                   java.lang.String propertySourceName,
                                                   org.springframework.core.env.MutablePropertySources propertySources)
                                            throws java.lang.Throwable
        Load the PropertySource
        Parameters:
        attributes - AnnotationAttributes
        metadata - AnnotationMetadata
        propertySourceName - the name of PropertySource
        propertySources - MutablePropertySources to be added
        Throws:
        java.lang.Throwable - the failure of the loading
      • getAnnotationType

        @NonNull
        public final java.lang.Class<A> getAnnotationType()
        The annotation type
        Returns:
        non-null
      • getPropertySourceName

        protected java.lang.String getPropertySourceName()