Skip to content

io microsphere spring cloud client actuator ConfigurationPropertyHasFeaturesAutoConfiguration

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

ConfigurationPropertyHasFeaturesAutoConfiguration

Type: Class | Module: microsphere-spring-cloud-commons | Package: io.microsphere.spring.cloud.client.actuator | Since: 1.0.0

Source: microsphere-spring-cloud-commons/src/main/java/io/microsphere/spring/cloud/client/actuator/ConfigurationPropertyHasFeaturesAutoConfiguration.java

Overview

Auto-registrar for Spring Cloud Client Actuator's HasFeatures based on configuration properties.

This class scans configuration properties under the prefix #PROPERTY_PREFIX to automatically register HasFeatures beans. It supports two types of feature definitions:

- **Abstract Features:** Defined by listing feature classes directly under a module name.
- **Named Features:** Defined by mapping a specific feature name to a feature class under a module name.

Configuration Examples

1. Abstract Features

`# Defines abstract features for the 'jdbc' module
microsphere.spring.cloud.features.jdbc=org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager
`

2. Named Features

`# Defines a named feature 'rest-template' for the 'web' module
microsphere.spring.cloud.features.web.rest-template=org.springframework.web.client.RestTemplate
`

Resulting Beans

For each module found in the configuration, a HasFeatures bean is registered with the name format: HasFeatures.{module-name} (e.g., jdbc.features, web.features).

Declaration

public class ConfigurationPropertyHasFeaturesAutoConfiguration implements BeanFactoryAware, BeanClassLoaderAware,

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.2.18-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

Example 1

# Defines abstract features for the 'jdbc' module
microsphere.spring.cloud.features.jdbc=org.springframework.jdbc.core.JdbcTemplate,org.springframework.transaction.PlatformTransactionManager

Example 2

# Defines a named feature 'rest-template' for the 'web' module
microsphere.spring.cloud.features.web.rest-template=org.springframework.web.client.RestTemplate

Method Examples

getAbstractFeaturePropertyName

// For module name "jdbc"
String propertyName = getAbstractFeaturePropertyName("jdbc");
// Result: "microsphere.spring.cloud.features.jdbc"

getNamedFeaturePropertyName

// For module name "web" and feature name "rest-template"
String propertyName = getNamedFeaturePropertyName("web", "rest-template");
// Result: "microsphere.spring.cloud.features.web.rest-template"

getBeanName

// For module name "jdbc"
String beanName = getBeanName("jdbc");
// Result: "jdbc.features"

getQualifierFeatureName

// For module name "web" and feature name "rest-template"
String qualifiedName = getQualifierFeatureName("web", "rest-template");
// Result: "microsphere.web.rest-template"

Usage

Maven Dependency

Add the following dependency to your pom.xml:

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

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

Import

import io.microsphere.spring.cloud.client.actuator.ConfigurationPropertyHasFeaturesAutoConfiguration;

API Reference

Public Methods

Method Description
getAbstractFeaturePropertyName The prefix of the configuration properties for HasFeatures : "microsphere.spring.cloud.features."
getNamedFeaturePropertyName Gets the configuration property name for a named feature of the specified module.
getBeanName Gets the bean name for HasFeatures of the specified module.
getQualifierFeatureName Gets the qualified feature name for a named feature of the specified module.

Method Details

getAbstractFeaturePropertyName

public static String getAbstractFeaturePropertyName(String moduleName)

The prefix of the configuration properties for HasFeatures : "microsphere.spring.cloud.features." / public static final String PROPERTY_PREFIX = MICROSPHERE_SPRING_CLOUD_PROPERTY_NAME_PREFIX + NAME + DOT;

/** The pattern of the configuration properties for abstract features: "microsphere.spring.cloud.features.{module-name}" / public static final String ABSTRACT_FEATURE_PROPERTY_NAME_PATTERN = PROPERTY_PREFIX + "{}";

/** The pattern of the configuration properties for named features: "microsphere.spring.cloud.features.{module-name}.{feature-name}" / public static final String NAMED_FEATURE_PROPERTY_NAME_PATTERN = ABSTRACT_FEATURE_PROPERTY_NAME_PATTERN + DOT + "{}";

/** The suffix of the bean name for HasFeatures : ".features" / public static final String BEAN_NAME_SUFFIX = DOT + NAME;

private ClassLoader classLoader;

private SingletonBeanRegistry singletonBeanRegistry;

private final Map moduleFeaturesMap = newLinkedHashMap();

getNamedFeaturePropertyName

public static String getNamedFeaturePropertyName(String moduleName, String featureName)

Gets the configuration property name for a named feature of the specified module.

Example Usage

`// For module name "web" and feature name "rest-template"
String propertyName = getNamedFeaturePropertyName("web", "rest-template");
// Result: "microsphere.spring.cloud.features.web.rest-template"
`

getBeanName

public static String getBeanName(String moduleName)

Gets the bean name for HasFeatures of the specified module.

Example Usage

`// For module name "jdbc"
String beanName = getBeanName("jdbc");
// Result: "jdbc.features"
`

getQualifierFeatureName

public static String getQualifierFeatureName(String moduleName, String featureName)

Gets the qualified feature name for a named feature of the specified module.

Example Usage

`// For module name "web" and feature name "rest-template"
String qualifiedName = getQualifierFeatureName("web", "rest-template");
// Result: "microsphere.web.rest-template"
`

See Also

  • HasFeatures
  • NamedFeature
  • AutoRegistrationBean

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

Home

spring-cloud-commons

spring-cloud-openfeign

Clone this wiki locally