Class PropertySourceExtensionLoader<A extends java.lang.annotation.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 ofAnnotationmust meta-annotatePropertySourceExtensionEA- ThePropertySourceExtensionAttributesor 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 java.lang.annotation.Annotation,EA extends PropertySourceExtensionAttributes<A>> extends AnnotatedPropertySourceLoader<A> implements org.springframework.context.ApplicationContextAware
AbstractImportSelectorclass to load thePropertySourcewhen theconfigurationannotated the Enable annotation that meta-annotates@PropertySourceExtension- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
PropertySourceExtension,PropertySourceExtensionAttributes,ImportSelector
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPropertySourceExtensionLoader.PropertySourceResourceThe resource ofPropertySourceprotected static interfacePropertySourceExtensionLoader.ResourcePropertySourcesRefresherThe 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 Constructor Description PropertySourceExtensionLoader()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddPropertySource(EA extensionAttributes, org.springframework.core.env.MutablePropertySources propertySources, org.springframework.core.env.PropertySource<?> propertySource)protected EAbuildExtensionAttributes(java.lang.Class<A> annotationType, java.lang.Class<EA> extensionAttributesType, org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.env.ConfigurableEnvironment environment)Builds an instance ofPropertySourceExtensionLoaderprotected voidconfigureResourcePropertySourcesRefresher(EA extensionAttributes, java.util.List<PropertySourceExtensionLoader.PropertySourceResource> propertySourceResources, org.springframework.core.env.CompositePropertySource propertySource, PropertySourceExtensionLoader.ResourcePropertySourcesRefresher refresher)Configure thePropertySourceExtensionLoader.ResourcePropertySourcesRefresherofPropertySourceResourceswhenPropertySourceExtension.autoRefreshed()istrueprotected <T> TcreateInstance(EA extensionAttributes, java.util.function.Function<EA,java.lang.Class<T>> classFunction)protected org.springframework.core.io.support.PropertySourceFactorycreatePropertySourceFactory(EA extensionAttributes)Creates an instance ofPropertySourceFactoryprotected java.util.Comparator<org.springframework.core.io.Resource>createResourceComparator(EA extensionAttributes, java.lang.String propertySourceName)Creates an instance ofComparatorforResourceprotected io.microsphere.spring.config.context.annotation.PropertySourceExtensionLoader.ResourcePropertySourcecreateResourcePropertySource(EA extensionAttributes, java.lang.String propertySourceName, org.springframework.core.io.support.PropertySourceFactory factory, PropertySourceExtensionLoader.PropertySourceResource propertySourceResource)Create an instance ofPropertySourceExtensionLoader.ResourcePropertySourcefor the specifiedresourceprotected java.lang.StringcreateResourcePropertySourceName(java.lang.String propertySourceName, java.lang.String resourceValue, org.springframework.core.io.Resource resource)java.lang.Class<EA>getExtensionAttributesType()Get the type ofPropertySourceExtensionLoaderabstract booleanisResourcePattern(java.lang.String resourceValue)Test the resource value is pattern or notprotected org.springframework.core.env.PropertySource<?>loadPropertySource(EA extensionAttributes, java.lang.String propertySourceName)protected voidloadPropertySource(org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.type.AnnotationMetadata metadata, java.lang.String propertySourceName, org.springframework.core.env.MutablePropertySources propertySources)Load thePropertySourceprotected java.lang.Class<EA>resolveExtensionAttributesType()protected java.util.List<PropertySourceExtensionLoader.PropertySourceResource>resolvePropertySourceResources(EA extensionAttributes, java.lang.String propertySourceName, java.lang.String resourceValue, java.util.Comparator<org.springframework.core.io.Resource> resourceComparator)protected abstract org.springframework.core.io.Resource[]resolveResources(EA extensionAttributes, java.lang.String propertySourceName, java.lang.String resourceValue)Resolve the given resource value(s) to bePropertySourceExtensionLoader.PropertySourceResourcearray.voidsetApplicationContext(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
-
-
-
-
Method Detail
-
resolveExtensionAttributesType
protected java.lang.Class<EA> resolveExtensionAttributesType()
-
isResourcePattern
public abstract boolean isResourcePattern(java.lang.String resourceValue)
Test the resource value is pattern or not- Parameters:
resourceValue- theStringvalue presenting resource- Returns:
trueifresourceValueis a pattern value
-
getExtensionAttributesType
public final java.lang.Class<EA> getExtensionAttributesType()
Get the type ofPropertySourceExtensionLoader- Returns:
- non-null
- See Also:
PropertySourceExtensionAttributes
-
loadPropertySource
protected final 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.ThrowableDescription copied from class:AnnotatedPropertySourceLoaderLoad thePropertySource- Specified by:
loadPropertySourcein classAnnotatedPropertySourceLoader<A extends java.lang.annotation.Annotation>- Parameters:
attributes-AnnotationAttributesmetadata-AnnotationMetadatapropertySourceName- the name ofPropertySourcepropertySources-MutablePropertySourcesto be added- Throws:
java.lang.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 attributesofPropertySourceExtensionpropertySources- theMutablePropertySourcesto be addedpropertySource- thePropertySourceis about to add
-
buildExtensionAttributes
protected EA buildExtensionAttributes(java.lang.Class<A> annotationType, java.lang.Class<EA> extensionAttributesType, org.springframework.core.annotation.AnnotationAttributes attributes, org.springframework.core.env.ConfigurableEnvironment environment) throws java.lang.Throwable
Builds an instance ofPropertySourceExtensionLoader- Parameters:
annotationType- the type ofPropertySourceExtensionLoaderextensionAttributesType- the type ofPropertySourceExtensionLoaderattributes-AnnotationAttributesenvironment-ConfigurableEnvironment- Returns:
- non-null
- Throws:
java.lang.Throwable
-
loadPropertySource
protected final org.springframework.core.env.PropertySource<?> loadPropertySource(EA extensionAttributes, java.lang.String propertySourceName) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
resolvePropertySourceResources
protected java.util.List<PropertySourceExtensionLoader.PropertySourceResource> resolvePropertySourceResources(EA extensionAttributes, java.lang.String propertySourceName, java.lang.String resourceValue, java.util.Comparator<org.springframework.core.io.Resource> resourceComparator) throws java.lang.Throwable
- Throws:
java.lang.Throwable
-
createPropertySourceFactory
@Nonnull protected org.springframework.core.io.support.PropertySourceFactory createPropertySourceFactory(EA extensionAttributes)
Creates an instance ofPropertySourceFactory- Parameters:
extensionAttributes- theannotation attributesofPropertySourceExtension- Returns:
- See Also:
PropertySourceExtension.factory(),PropertySourceFactory
-
createResourceComparator
@Nonnull protected java.util.Comparator<org.springframework.core.io.Resource> createResourceComparator(EA extensionAttributes, java.lang.String propertySourceName)
Creates an instance ofComparatorforResource- Parameters:
extensionAttributes- theannotation attributesofPropertySourceExtensionpropertySourceName- the name of {PropertySource} declared byPropertySourceExtension.name()- Returns:
- an instance of
ComparatorforResource - See Also:
PropertySourceExtension.resourceComparator(),Comparator
-
createResourcePropertySourceName
protected java.lang.String createResourcePropertySourceName(java.lang.String propertySourceName, java.lang.String resourceValue, org.springframework.core.io.Resource resource)
-
createResourcePropertySource
protected final io.microsphere.spring.config.context.annotation.PropertySourceExtensionLoader.ResourcePropertySource createResourcePropertySource(EA extensionAttributes, java.lang.String propertySourceName, org.springframework.core.io.support.PropertySourceFactory factory, PropertySourceExtensionLoader.PropertySourceResource propertySourceResource) throws java.lang.Throwable
Create an instance ofPropertySourceExtensionLoader.ResourcePropertySourcefor the specifiedresource- Parameters:
extensionAttributes- theannotation attributesofPropertySourceExtensionpropertySourceName- the name of {PropertySource} declared byPropertySourceExtension.name()factory- the factory to thePropertySourcedeclared byPropertySourceExtension.factory()propertySourceResource- the source ofPropertySource- Returns:
- an instance of
PropertySourceExtensionLoader.ResourcePropertySource - Throws:
java.lang.Throwable
-
configureResourcePropertySourcesRefresher
protected void configureResourcePropertySourcesRefresher(EA extensionAttributes, java.util.List<PropertySourceExtensionLoader.PropertySourceResource> propertySourceResources, org.springframework.core.env.CompositePropertySource propertySource, PropertySourceExtensionLoader.ResourcePropertySourcesRefresher refresher) throws java.lang.Throwable
Configure thePropertySourceExtensionLoader.ResourcePropertySourcesRefresherofPropertySourceResourceswhenPropertySourceExtension.autoRefreshed()istrue- Parameters:
extensionAttributes- theannotation attributesofPropertySourceExtensionpropertySourceResources- The sorted list of the resolvedresourcespropertySource- Theproperty sourceof current loader to be added into the Spring'sproperty sourcesrefresher- The Refresher ofPropertySources'Resource- Throws:
java.lang.Throwable- any error
-
resolveResources
@Nullable protected abstract org.springframework.core.io.Resource[] resolveResources(EA extensionAttributes, java.lang.String propertySourceName, java.lang.String resourceValue) throws java.lang.Throwable
Resolve the given resource value(s) to bePropertySourceExtensionLoader.PropertySourceResourcearray.- Parameters:
extensionAttributes-PropertySourceExtensionLoaderpropertySourceName-PropertySourceExtension.name()resourceValue- the resource value to resolve- Returns:
- nullable
- Throws:
java.lang.Throwable
-
createInstance
protected <T> T createInstance(EA extensionAttributes, java.util.function.Function<EA,java.lang.Class<T>> classFunction)
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext context)
- Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
-