Skip to content

io microsphere spring config context annotation PropertySourceExtensionAttributes

github-actions[bot] edited this page Jun 18, 2026 · 18 revisions

PropertySourceExtensionAttributes

Type: Class | Module: microsphere-spring-context | Package: io.microsphere.spring.config.context.annotation | Since: 1.0.0

Source: microsphere-spring-context/src/main/java/io/microsphere/spring/config/context/annotation/PropertySourceExtensionAttributes.java

Overview

AnnotationAttributes for the annotation meta-annotated PropertySourceExtension

Declaration

public class PropertySourceExtensionAttributes<A extends Annotation> extends ResolvablePlaceholderAnnotationAttributes<A>

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.27-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Method Examples

getName

AnnotationAttributes attrs = getAnnotationAttributes(MyConfig.class, ResourcePropertySource.class, environment, false);
  PropertySourceExtensionAttributes<ResourcePropertySource> extensionAttrs =
      new PropertySourceExtensionAttributes<>(attrs, ResourcePropertySource.class, environment);
// Given @ResourcePropertySource(name = "test-property-source", value = "classpath*:/META-INF/test/*.properties")
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  String name = attributes.getName(); // "test-property-source"

isAutoRefreshed

// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", autoRefreshed = true)
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  boolean autoRefreshed = attributes.isAutoRefreshed(); // true

isFirstPropertySource

// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", first = true)
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  boolean first = attributes.isFirstPropertySource(); // true

getBeforePropertySourceName

// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties",
  //     before = "systemEnvironment")
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  String before = attributes.getBeforePropertySourceName(); // "systemEnvironment"

getAfterPropertySourceName

// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties",
  //     after = "systemProperties")
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  String after = attributes.getAfterPropertySourceName(); // "systemProperties"

getAnnotationType

PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  Class<ResourcePropertySource> type = attributes.getAnnotationType();
  // type == ResourcePropertySource.class

getValue

// Given @ResourcePropertySource(value = {"classpath*:/META-INF/test/*.properties"})
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  String[] values = attributes.getValue(); // ["classpath*:/META-INF/test/*.properties"]

isIgnoreResourceNotFound

PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  Class<? extends Comparator<Resource>> comparatorClass = attributes.getResourceComparatorClass();
  // defaults to DefaultResourceComparator.class
// Given @ResourcePropertySource(value = "classpath*:/not-found.properties", ignoreResourceNotFound = true)
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  boolean ignore = attributes.isIgnoreResourceNotFound(); // true

getEncoding

// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", encoding = "UTF-8")
  PropertySourceExtensionAttributes<ResourcePropertySource> attributes = ...;
  String encoding = attributes.getEncoding(); // "UTF-8"

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-spring-context</artifactId>
    <version>${microsphere-spring.version}</version>
</dependency>

Tip: Use the BOM (microsphere-spring-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.spring.config.context.annotation.PropertySourceExtensionAttributes;

API Reference

Public Methods

Method Description
getName Constructs a new PropertySourceExtensionAttributes instance from the given annotation attributes map,
isAutoRefreshed Returns whether the property source should be automatically refreshed when the underlying
isFirstPropertySource Returns whether this property source should be placed first in the
getBeforePropertySourceName Returns the name of the property source before which this property source should be inserted.
getAfterPropertySourceName Returns the name of the property source after which this property source should be inserted.
getAnnotationType Returns the annotation type associated with these extension attributes.
getValue Returns the resource location values specified by the value attribute of the annotation.
isIgnoreResourceNotFound Returns the Comparator class used to sort the resolved Resource instances
getEncoding Returns the character encoding to use when reading the property source resources.

Method Details

getName

public final String getName()

Constructs a new PropertySourceExtensionAttributes instance from the given annotation attributes map, annotation type, and an optional PropertyResolver for resolving placeholders.

Example Usage

`AnnotationAttributes attrs = getAnnotationAttributes(MyConfig.class, ResourcePropertySource.class, environment, false);
  PropertySourceExtensionAttributes extensionAttrs =
      new PropertySourceExtensionAttributes<>(attrs, ResourcePropertySource.class, environment);
`

isAutoRefreshed

public final boolean isAutoRefreshed()

Returns whether the property source should be automatically refreshed when the underlying resource changes.

Example Usage

`// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", autoRefreshed = true)
  PropertySourceExtensionAttributes attributes = ...;
  boolean autoRefreshed = attributes.isAutoRefreshed(); // true
`

isFirstPropertySource

public final boolean isFirstPropertySource()

Returns whether this property source should be placed first in the org.springframework.core.env.MutablePropertySources list.

Example Usage

`// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", first = true)
  PropertySourceExtensionAttributes attributes = ...;
  boolean first = attributes.isFirstPropertySource(); // true
`

getBeforePropertySourceName

public final String getBeforePropertySourceName()

Returns the name of the property source before which this property source should be inserted.

Example Usage

`// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties",
  //     before = "systemEnvironment")
  PropertySourceExtensionAttributes attributes = ...;
  String before = attributes.getBeforePropertySourceName(); // "systemEnvironment"
`

getAfterPropertySourceName

public final String getAfterPropertySourceName()

Returns the name of the property source after which this property source should be inserted.

Example Usage

`// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties",
  //     after = "systemProperties")
  PropertySourceExtensionAttributes attributes = ...;
  String after = attributes.getAfterPropertySourceName(); // "systemProperties"
`

getAnnotationType

public final Class<A> getAnnotationType()

Returns the annotation type associated with these extension attributes.

Example Usage

`PropertySourceExtensionAttributes attributes = ...;
  Class type = attributes.getAnnotationType();
  // type == ResourcePropertySource.class
`

getValue

public final String[] getValue()

Returns the resource location values specified by the value attribute of the annotation. These are the resource paths from which properties will be loaded.

Example Usage

`// Given @ResourcePropertySource(value = {"classpath*:/META-INF/test/*.properties"`)
  PropertySourceExtensionAttributes attributes = ...;
  String[] values = attributes.getValue(); // ["classpath*:/META-INF/test/*.properties"]
}

isIgnoreResourceNotFound

public final boolean isIgnoreResourceNotFound()

Returns the Comparator class used to sort the resolved Resource instances before loading them into the property source.

Example Usage

`PropertySourceExtensionAttributes attributes = ...;
  Class> comparatorClass = attributes.getResourceComparatorClass();
  // defaults to DefaultResourceComparator.class
`

getEncoding

public final String getEncoding()

Returns the character encoding to use when reading the property source resources.

Example Usage

`// Given @ResourcePropertySource(value = "classpath*:/META-INF/test/*.properties", encoding = "UTF-8")
  PropertySourceExtensionAttributes attributes = ...;
  String encoding = attributes.getEncoding(); // "UTF-8"
`

See Also

  • PropertySourceExtension
  • ResolvablePlaceholderAnnotationAttributes

This documentation was auto-generated from the source code of microsphere-spring.

Home

spring-context

spring-guice

spring-jdbc

spring-test

spring-web

spring-webflux

spring-webmvc

Clone this wiki locally