Class PropertySourceExtensionLoader<A extends Annotation,EA extends PropertySourceExtensionAttributes<A>>
java.lang.Object
io.microsphere.spring.context.annotation.BeanCapableImportCandidate
io.microsphere.spring.config.context.annotation.AnnotatedPropertySourceLoader<A>
io.microsphere.spring.config.context.annotation.PropertySourceExtensionLoader<A,EA>
- Type Parameters:
A
- The type ofAnnotation
must meta-annotatePropertySourceExtension
EA
- ThePropertySourceExtensionAttributes
or its subtype
- 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.ApplicationContextAware
,org.springframework.context.EnvironmentAware
,org.springframework.context.ResourceLoaderAware
- Direct Known Subclasses:
ResourcePropertySourceLoader
public abstract class PropertySourceExtensionLoader<A extends Annotation,EA extends PropertySourceExtensionAttributes<A>>
extends AnnotatedPropertySourceLoader<A>
implements org.springframework.context.ApplicationContextAware
Abstract
ImportSelector
class to load the PropertySource
when the configuration
annotated the Enable annotation that meta-annotates @PropertySourceExtension
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
-
PropertySourceExtension
PropertySourceExtensionAttributes
ImportSelector
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
The resource ofPropertySource
protected static interface
The Refresher ofPropertySources'
forResource
-
Field Summary
Fields inherited from class io.microsphere.spring.config.context.annotation.AnnotatedPropertySourceLoader
logger, NAME_ATTRIBUTE_NAME
Fields inherited from class io.microsphere.spring.context.annotation.BeanCapableImportCandidate
beanFactory, classLoader, environment, resourceLoader
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPropertySource
(EA extensionAttributes, org.springframework.core.env.MutablePropertySources propertySources, org.springframework.core.env.PropertySource<?> propertySource) protected EA
buildExtensionAttributes
(Class<A> annotationType, Class<EA> extensionAttributesType, org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.env.ConfigurableEnvironment environment) Builds an instance ofPropertySourceExtensionLoader
protected void
configureResourcePropertySourcesRefresher
(EA extensionAttributes, List<PropertySourceExtensionLoader.PropertySourceResource> propertySourceResources, org.springframework.core.env.CompositePropertySource propertySource, PropertySourceExtensionLoader.ResourcePropertySourcesRefresher refresher) Configure thePropertySourceExtensionLoader.ResourcePropertySourcesRefresher
ofPropertySource
Resources
whenPropertySourceExtension.autoRefreshed()
istrue
protected <T> T
createInstance
(EA extensionAttributes, Function<EA, Class<T>> classFunction) protected org.springframework.core.io.support.PropertySourceFactory
createPropertySourceFactory
(EA extensionAttributes) Creates an instance ofPropertySourceFactory
protected Comparator<org.springframework.core.io.Resource>
createResourceComparator
(EA extensionAttributes, String propertySourceName) Creates an instance ofComparator
forResource
protected final io.microsphere.spring.config.context.annotation.PropertySourceExtensionLoader.ResourcePropertySource
createResourcePropertySource
(EA extensionAttributes, String propertySourceName, org.springframework.core.io.support.PropertySourceFactory factory, PropertySourceExtensionLoader.PropertySourceResource propertySourceResource) Create an instance ofPropertySourceExtensionLoader.ResourcePropertySource
for the specifiedresource
protected String
createResourcePropertySourceName
(String propertySourceName, String resourceValue, org.springframework.core.io.Resource resource) Get the type ofPropertySourceExtensionLoader
abstract boolean
isResourcePattern
(String resourceValue) Test the resource value is pattern or notprotected final org.springframework.core.env.PropertySource<?>
loadPropertySource
(EA extensionAttributes, String propertySourceName) protected final void
loadPropertySource
(org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.type.AnnotationMetadata metadata, String propertySourceName, org.springframework.core.env.MutablePropertySources propertySources) Load thePropertySource
resolvePropertySourceResources
(EA extensionAttributes, String propertySourceName, String resourceValue, Comparator<org.springframework.core.io.Resource> resourceComparator) protected abstract org.springframework.core.io.Resource[]
resolveResources
(EA extensionAttributes, String propertySourceName, String resourceValue) Resolve the given resource value(s) to bePropertySourceExtensionLoader.PropertySourceResource
array.void
setApplicationContext
(org.springframework.context.ApplicationContext context) Methods inherited from class io.microsphere.spring.config.context.annotation.AnnotatedPropertySourceLoader
buildDefaultPropertySourceName, buildPropertySourceName, getAnnotationType, getPropertySourceName, resolveAnnotationType, resolvePropertySourceName, selectImports
Methods inherited from class io.microsphere.spring.context.annotation.BeanCapableImportCandidate
getBeanFactory, getClassLoader, getEnvironment, getResourceLoader, setBeanClassLoader, setBeanFactory, setEnvironment, setResourceLoader
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.annotation.ImportSelector
getExclusionFilter
-
Constructor Details
-
PropertySourceExtensionLoader
public PropertySourceExtensionLoader()
-
-
Method Details
-
resolveExtensionAttributesType
-
isResourcePattern
Test the resource value is pattern or not- Parameters:
resourceValue
- theString
value presenting resource- Returns:
true
ifresourceValue
is a pattern value
-
getExtensionAttributesType
Get the type ofPropertySourceExtensionLoader
- Returns:
- non-null
- See Also:
-
loadPropertySource
protected final void loadPropertySource(org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.type.AnnotationMetadata metadata, String propertySourceName, org.springframework.core.env.MutablePropertySources propertySources) throws Throwable Description copied from class:AnnotatedPropertySourceLoader
Load thePropertySource
- Specified by:
loadPropertySource
in classAnnotatedPropertySourceLoader<A extends Annotation>
- Parameters:
attributes
-AnnotationAttributes
metadata
-AnnotationMetadata
propertySourceName
- the name ofPropertySource
propertySources
-MutablePropertySources
to be added- Throws:
Throwable
- the failure of the loading
-
addPropertySource
protected void addPropertySource(EA extensionAttributes, org.springframework.core.env.MutablePropertySources propertySources, org.springframework.core.env.PropertySource<?> propertySource) - Parameters:
extensionAttributes
- theannotation attributes
ofPropertySourceExtension
propertySources
- theMutablePropertySources
to be addedpropertySource
- thePropertySource
is about to add
-
buildExtensionAttributes
protected EA buildExtensionAttributes(Class<A> annotationType, Class<EA> extensionAttributesType, org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.env.ConfigurableEnvironment environment) throws Throwable Builds an instance ofPropertySourceExtensionLoader
- Parameters:
annotationType
- the type ofPropertySourceExtensionLoader
extensionAttributesType
- the type ofPropertySourceExtensionLoader
attributes
-AnnotationAttributes
environment
-ConfigurableEnvironment
- Returns:
- non-null
- Throws:
Throwable
-
loadPropertySource
protected final org.springframework.core.env.PropertySource<?> loadPropertySource(EA extensionAttributes, String propertySourceName) throws Throwable - Throws:
Throwable
-
resolvePropertySourceResources
protected List<PropertySourceExtensionLoader.PropertySourceResource> resolvePropertySourceResources(EA extensionAttributes, String propertySourceName, String resourceValue, Comparator<org.springframework.core.io.Resource> resourceComparator) throws Throwable - Throws:
Throwable
-
createPropertySourceFactory
@Nonnull protected org.springframework.core.io.support.PropertySourceFactory createPropertySourceFactory(EA extensionAttributes) Creates an instance ofPropertySourceFactory
- Parameters:
extensionAttributes
- theannotation attributes
ofPropertySourceExtension
- Returns:
- See Also:
-
PropertySourceExtension.factory()
PropertySourceFactory
-
createResourceComparator
@Nonnull protected Comparator<org.springframework.core.io.Resource> createResourceComparator(EA extensionAttributes, String propertySourceName) Creates an instance ofComparator
forResource
- Parameters:
extensionAttributes
- theannotation attributes
ofPropertySourceExtension
propertySourceName
- the name of {PropertySource} declared byPropertySourceExtension.name()
- Returns:
- an instance of
Comparator
forResource
- See Also:
-
createResourcePropertySourceName
-
createResourcePropertySource
protected final io.microsphere.spring.config.context.annotation.PropertySourceExtensionLoader.ResourcePropertySource createResourcePropertySource(EA extensionAttributes, String propertySourceName, org.springframework.core.io.support.PropertySourceFactory factory, PropertySourceExtensionLoader.PropertySourceResource propertySourceResource) throws Throwable Create an instance ofPropertySourceExtensionLoader.ResourcePropertySource
for the specifiedresource
- Parameters:
extensionAttributes
- theannotation attributes
ofPropertySourceExtension
propertySourceName
- the name of {PropertySource} declared byPropertySourceExtension.name()
factory
- the factory to thePropertySource
declared byPropertySourceExtension.factory()
propertySourceResource
- the source ofPropertySource
- Returns:
- an instance of
PropertySourceExtensionLoader.ResourcePropertySource
- Throws:
Throwable
-
configureResourcePropertySourcesRefresher
protected void configureResourcePropertySourcesRefresher(EA extensionAttributes, List<PropertySourceExtensionLoader.PropertySourceResource> propertySourceResources, org.springframework.core.env.CompositePropertySource propertySource, PropertySourceExtensionLoader.ResourcePropertySourcesRefresher refresher) throws Throwable Configure thePropertySourceExtensionLoader.ResourcePropertySourcesRefresher
ofPropertySource
Resources
whenPropertySourceExtension.autoRefreshed()
istrue
- Parameters:
extensionAttributes
- theannotation attributes
ofPropertySourceExtension
propertySourceResources
- The sorted list of the resolvedresources
propertySource
- Theproperty source
of current loader to be added into the Spring'sproperty sources
refresher
- The Refresher ofPropertySources'
Resource
- Throws:
Throwable
- any error
-
resolveResources
@Nullable protected abstract org.springframework.core.io.Resource[] resolveResources(EA extensionAttributes, String propertySourceName, String resourceValue) throws Throwable Resolve the given resource value(s) to bePropertySourceExtensionLoader.PropertySourceResource
array.- Parameters:
extensionAttributes
-PropertySourceExtensionLoader
propertySourceName
-PropertySourceExtension.name()
resourceValue
- the resource value to resolve- Returns:
- nullable
- Throws:
Throwable
-
createInstance
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext context) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-