From 2eb6c68ed12740f4f3412680190b0d09345014e6 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 5 Jun 2026 16:37:37 +0800
Subject: [PATCH 01/42] Group third-party dependencies in sentinel POMs
Standardize dependency ordering across sentinel plugin POMs.
- Add a "Third-Party Dependencies" section/comment in multiple POMs (alibaba-druid, hibernate-core, p6spy, redis) to clarify grouping.
- In microsphere-alibaba-sentinel-alibaba-druid/pom.xml: move com.alibaba:druid into the Third-Party section and remove the true from io.github.microsphere-projects:microsphere-alibaba-druid-core.
- In microsphere-alibaba-sentinel-mybatis/pom.xml: move io.github.microsphere-projects:microsphere-mybatis-core earlier (grouped with project dependencies) and remove the duplicate block later.
These changes are cosmetic/organizational to improve consistency and readability of dependency sections across the sentinel plugin modules.
---
.../pom.xml | 15 ++++++++-------
.../pom.xml | 2 ++
.../microsphere-alibaba-sentinel-mybatis/pom.xml | 14 ++++++++------
.../microsphere-alibaba-sentinel-p6spy/pom.xml | 2 ++
.../microsphere-alibaba-sentinel-redis/pom.xml | 2 ++
5 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
index aebdb1a..5977c77 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
@@ -31,7 +31,6 @@
io.github.microsphere-projects
microsphere-alibaba-druid-core
- true
@@ -41,12 +40,7 @@
true
-
-
- com.alibaba
- druid
- true
-
+
@@ -55,6 +49,13 @@
true
+
+
+ com.alibaba
+ druid
+ true
+
+
org.junit.jupiter
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
index 5bd131e..1f64a82 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
@@ -40,6 +40,8 @@
true
+
+
com.alibaba.csp
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
index 5c37edf..e003c1d 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
@@ -27,6 +27,12 @@
${revision}
+
+
+ io.github.microsphere-projects
+ microsphere-mybatis-core
+
+
io.github.microsphere-projects
@@ -34,6 +40,8 @@
true
+
+
com.alibaba.csp
@@ -41,12 +49,6 @@
true
-
-
- io.github.microsphere-projects
- microsphere-mybatis-core
-
-
org.mybatis
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
index bb034d6..77508b0 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
@@ -34,6 +34,8 @@
true
+
+
com.alibaba.csp
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
index 6162b87..31da05a 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
@@ -41,6 +41,8 @@
true
+
+
com.alibaba.csp
From 7ce916adb35ed91505c05dc97ba6394724163980 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 5 Jun 2026 16:39:26 +0800
Subject: [PATCH 02/42] Remove optional flag from redis dependency
In microsphere-alibaba-sentinel-redis/pom.xml remove the true element from the io.github.microsphere-projects:microsphere-redis-spring dependency so it is treated as a normal (non-optional) dependency and will be transitively included for consumers.
---
.../microsphere-alibaba-sentinel-redis/pom.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
index 31da05a..9716a24 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
@@ -31,7 +31,6 @@
io.github.microsphere-projects
microsphere-redis-spring
- true
From 31583986ed89caf0247bae4e9cb1a362b031efbe Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 5 Jun 2026 19:56:01 +0800
Subject: [PATCH 03/42] Rename plugin Constants/classes and update deps
Refactor multiple Sentinel plugin modules: rename generic Constants interfaces to specific Sentinel*Constants (alibaba-druid, hibernate, mybatis, p6spy, redis, spring-web) and update related imports and tests. Rename SentinelDruidFilter to SentinelAlibabaDruidFilter and update the service registration. Adjust usages across code and tests to match new class names, including callback and interceptor references. Update spring-boot module pom.xml to add dependencies for sentinel plugin modules, related optional integrations and test/libs (Hibernate, Druid, Redis, MyBatis, microsphere test modules, H2, Lettuce) and switch to JUnit Jupiter for testing. Enhance SentinelAutoConfiguration to import/register Redis and MyBatis configurations (add conditional annotations and imports) and add new tests for auto-configuration (RedisConfig and SentinelAutoConfigurationTest). Overall cleanup to align naming conventions and wire new module dependencies.
---
...ava => SentinelAlibabaDruidConstants.java} | 6 +-
...r.java => SentinelAlibabaDruidFilter.java} | 12 +-
.../services/com.alibaba.druid.filter.Filter | 2 +-
...=> SentinelAlibabaDruidConstantsTest.java} | 14 +--
...va => SentinelAlibabaDruidFilterTest.java} | 12 +-
...s.java => SentinelHibernateConstants.java} | 6 +-
.../SentinelHibernateEntityCallback.java | 6 +-
...va => SentinelHibernateConstantsTest.java} | 14 +--
...elHibernateEntityCallbackDisabledTest.java | 2 +-
...nts.java => SentinelMyBatisConstants.java} | 6 +-
.../SentinelMyBatisExecutorFilter.java | 6 +-
...java => SentinelMyBatisConstantsTest.java} | 14 +--
.../p6spy/SentinelJdbcEventListener.java | 6 +-
...tants.java => SentinelP6SpyConstants.java} | 6 +-
.../p6spy/SentinelJdbcEventListenerTest.java | 6 +-
...t.java => SentinelP6SpyConstantsTest.java} | 14 +--
...tants.java => SentinelRedisConstants.java} | 2 +-
.../SentinelRedisCommandInterceptor.java | 6 +-
...t.java => SentinelRedisConstantsTest.java} | 14 +--
.../SentinelRedisCommandInterceptorTest.java | 4 +-
.../web/SentinelHandlerMethodInterceptor.java | 6 +-
...s.java => SentinelSpringWebConstants.java} | 6 +-
...va => SentinelSpringWebConstantsTest.java} | 14 +--
.../pom.xml | 100 ++++++++++++++--
.../SentinelAutoConfiguration.java | 106 ++++++----------
.../boot/autoconfigure/RedisConfig.java | 58 +++++++++
.../SentinelAutoConfigurationTest.java | 113 ++++++++++++++++++
27 files changed, 387 insertions(+), 174 deletions(-)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/{Constants.java => SentinelAlibabaDruidConstants.java} (94%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/{SentinelDruidFilter.java => SentinelAlibabaDruidFilter.java} (87%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/{ConstantsTest.java => SentinelAlibabaDruidConstantsTest.java} (73%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/{SentinelDruidFilterTest.java => SentinelAlibabaDruidFilterTest.java} (81%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/{Constants.java => SentinelHibernateConstants.java} (94%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/{ConstantsTest.java => SentinelHibernateConstantsTest.java} (74%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/{Constants.java => SentinelMyBatisConstants.java} (94%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/{ConstantsTest.java => SentinelMyBatisConstantsTest.java} (75%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/{Constants.java => SentinelP6SpyConstants.java} (95%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/{ConstantsTest.java => SentinelP6SpyConstantsTest.java} (76%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/{Constants.java => SentinelRedisConstants.java} (98%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/{ConstantsTest.java => SentinelRedisConstantsTest.java} (76%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/{Constants.java => SentinelSpringWebConstants.java} (95%)
rename microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/{ConstantsTest.java => SentinelSpringWebConstantsTest.java} (74%)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
similarity index 94%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
index 34e6107..0db4b78 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
@@ -20,17 +20,17 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
- * The interface to declare the constants of Alibaba Druid
+ * The interface to declare the constants of Sentinel x Alibaba Druid
*
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelAlibabaDruidConstants {
/**
* The plugin name of Sentinel x Alibaba Druid
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
similarity index 87%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilter.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
index c4c2d33..7606702 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
@@ -30,9 +30,9 @@
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
@@ -45,17 +45,17 @@
* @since 1.0.0
*/
@AutoLoad
-public class SentinelDruidFilter extends AbstractStatementFilter implements SentinelPlugin {
+public class SentinelAlibabaDruidFilter extends AbstractStatementFilter implements SentinelPlugin {
private final SentinelPlugin delegate;
private final SentinelOperations sentinelOperations;
- public SentinelDruidFilter() {
+ public SentinelAlibabaDruidFilter() {
this(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
}
- public SentinelDruidFilter(String contextName, String origin) {
+ public SentinelAlibabaDruidFilter(String contextName, String origin) {
this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
install(this);
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/resources/META-INF/services/com.alibaba.druid.filter.Filter b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/resources/META-INF/services/com.alibaba.druid.filter.Filter
index 84de885..bab6855 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/resources/META-INF/services/com.alibaba.druid.filter.Filter
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/resources/META-INF/services/com.alibaba.druid.filter.Filter
@@ -1 +1 @@
-io.microsphere.alibaba.sentinel.alibaba.druid.SentinelDruidFilter
\ No newline at end of file
+io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstantsTest.java
similarity index 73%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstantsTest.java
index efed977..b364a7c 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstantsTest.java
@@ -19,21 +19,21 @@
import org.junit.jupiter.api.Test;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelAlibabaDruidConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelAlibabaDruidConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelAlibabaDruidConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilterTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
similarity index 81%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilterTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
index e8e8305..fdd7b44 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelDruidFilterTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
@@ -24,18 +24,18 @@
import java.util.List;
-import static io.microsphere.alibaba.sentinel.alibaba.druid.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link SentinelDruidFilter} Testt
+ * {@link SentinelAlibabaDruidFilter} Testt
*
* @author Mercy
- * @see SentinelDruidFilter
+ * @see SentinelAlibabaDruidFilter
* @see AbstractAlibabaDruidTest
* @since 1.0.0
*/
-class SentinelDruidFilterTest extends AbstractAlibabaDruidTest {
+class SentinelAlibabaDruidFilterTest extends AbstractAlibabaDruidTest {
@Test
void testEnable() throws Throwable {
@@ -53,8 +53,8 @@ void setEnable(boolean enabled) {
DruidDataSource dataSource = getDruidDataSource();
List proxyFilters = dataSource.getProxyFilters();
for (Filter proxyFilter : proxyFilters) {
- if (proxyFilter instanceof SentinelDruidFilter) {
- SentinelDruidFilter filter = (SentinelDruidFilter) proxyFilter;
+ if (proxyFilter instanceof SentinelAlibabaDruidFilter) {
+ SentinelAlibabaDruidFilter filter = (SentinelAlibabaDruidFilter) proxyFilter;
assertEquals(PLUGIN_NAME, filter.getName());
filter.setEnabled(enabled);
}
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
similarity index 94%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
index 6749e1e..700d3e5 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
@@ -20,17 +20,17 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
- * The interface to declare the constants of Hibernate
+ * The interface to declare the constants of Sentinel x Hibernate
*
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelHibernateConstants {
/**
* The plugin name of Sentinel x Hibernate
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
index 4a1f1bd..2c2e36a 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
@@ -34,9 +34,9 @@
import static io.microsphere.lang.function.ThrowableSupplier.execute;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
import static java.util.Optional.empty;
import static java.util.Optional.of;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
similarity index 74%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
index 0570565..9d7d047 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
@@ -19,21 +19,21 @@
import org.junit.jupiter.api.Test;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelHibernateConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelHibernateConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelHibernateConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackDisabledTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackDisabledTest.java
index d532649..6a5ba7c 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackDisabledTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackDisabledTest.java
@@ -21,7 +21,7 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
-import static io.microsphere.alibaba.sentinel.hibernate.Constants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.ENABLED_PROPERTY_NAME;
import static java.lang.System.setProperty;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
similarity index 94%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
index 2073df7..abfdff9 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
@@ -20,17 +20,17 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
- * The interface to declare the constants of MyBatis
+ * The interface to declare the constants of Sentinel x MyBatis
*
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelMyBatisConstants {
/**
* The plugin name of Sentinel x MyBatis
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
index 3174353..bb35b4a 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
@@ -33,9 +33,9 @@
import java.util.concurrent.Callable;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.PLUGIN_NAME;
import static io.microsphere.util.ExceptionUtils.throwTarget;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
similarity index 75%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
index 6cb2e77..4e5b3fc 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
@@ -19,21 +19,21 @@
import org.junit.jupiter.api.Test;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.mybatis.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelMyBatisConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelMyBatisConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelMyBatisConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
index 6efc21f..9503913 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
@@ -36,9 +36,9 @@
import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
/**
* P6Spy {@link JdbcEventListener} based on Alibaba Sentinel
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
similarity index 95%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
index b5cc51d..bac74c4 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
@@ -20,17 +20,17 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
- * The interface to declare the constants of P6Spy
+ * The interface to declare the constants of Sentinel x P6Spy
*
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelP6SpyConstants {
/**
* The plugin name of Sentinel x P6Spy
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
index f19c08a..3a76b8c 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
@@ -21,9 +21,9 @@
import io.microsphere.alibaba.druid.test.AbstractAlibabaDruidTest;
import org.junit.jupiter.api.Test;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
similarity index 76%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
index e92c112..2f7a87f 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
@@ -19,21 +19,21 @@
import org.junit.jupiter.api.Test;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.p6spy.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelP6SpyConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelP6SpyConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelP6SpyConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
similarity index 98%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
index 8021864..81253c6 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
@@ -31,7 +31,7 @@
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelRedisConstants {
/**
* The plugin name of Sentinel x Redis
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
index 1ec7b3d..f8f997f 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
@@ -36,9 +36,9 @@
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.SENTINEL_CONTEXT_ATTRIBUTE_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.buildResourceName;
-import static io.microsphere.alibaba.sentinel.redis.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.redis.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.redis.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.PLUGIN_NAME;
import static org.springframework.util.ClassUtils.getAllInterfacesForClass;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstantsTest.java
similarity index 76%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstantsTest.java
index cd09c76..2c0908f 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstantsTest.java
@@ -20,20 +20,20 @@
import org.junit.jupiter.api.Test;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
-import static io.microsphere.alibaba.sentinel.redis.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.redis.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.redis.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.redis.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.PLUGIN_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelRedisConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelRedisConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelRedisConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
index 8601348..c288950 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
@@ -17,7 +17,7 @@
package io.microsphere.alibaba.sentinel.redis.spring;
-import io.microsphere.alibaba.sentinel.redis.spring.test.RedisContextConfig;
+import io.microsphere.alibaba.sentinel.redis.spring.test.RedisConfig;
import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import io.microsphere.redis.spring.context.RedisContext;
import io.microsphere.redis.spring.interceptor.RedisMethodContext;
@@ -45,7 +45,7 @@
* @since 1.0.0
*/
@SpringJUnitConfig(classes = {
- RedisContextConfig.class,
+ RedisConfig.class,
SentinelRedisCommandInterceptorTest.class
})
@TestPropertySource(properties = {
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
index da36b8d..11b05e3 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
@@ -42,9 +42,9 @@
import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.SENTINEL_CONTEXT_ATTRIBUTE_NAME;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.PLUGIN_NAME;
import static io.microsphere.spring.web.util.WebScope.REQUEST;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/Constants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
similarity index 95%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/Constants.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
index c5e9def..e7862e9 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/Constants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
@@ -20,18 +20,18 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
- * The interface to declare the constants of Spring Web
+ * The interface to declare the constants of Sentinel x Spring Web
*
* @author Mercy
* @since 1.0.0
*/
-public interface Constants {
+public interface SentinelSpringWebConstants {
/**
* The plugin name of Sentinel x Spring Web
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/ConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstantsTest.java
similarity index 74%
rename from microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/ConstantsTest.java
rename to microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstantsTest.java
index 5b063b5..b12a8c1 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/ConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstantsTest.java
@@ -20,20 +20,20 @@
import org.junit.jupiter.api.Test;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.DEFAULT_CONTEXT_NAME;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.DEFAULT_ORIGIN;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.ENABLED_PROPERTY_NAME;
-import static io.microsphere.alibaba.sentinel.spring.web.Constants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_ORIGIN;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.PLUGIN_NAME;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
- * {@link Constants} Test
+ * {@link SentinelSpringWebConstants} Test
*
* @author Mercy
- * @see Constants
+ * @see SentinelSpringWebConstants
* @since 1.0.0
*/
-class ConstantsTest {
+class SentinelSpringWebConstantsTest {
@Test
void testConstants() {
diff --git a/microsphere-alibaba-sentinel-spring-boot/pom.xml b/microsphere-alibaba-sentinel-spring-boot/pom.xml
index f90ef66..e085b63 100644
--- a/microsphere-alibaba-sentinel-spring-boot/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-boot/pom.xml
@@ -33,16 +33,44 @@
microsphere-spring-boot-core
-
+
- org.springframework.boot
- spring-boot-autoconfigure
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-alibaba-druid
+ ${revision}
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-hibernate-core
+ ${revision}
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-mybatis
+ ${revision}
+
+
+
+ io.github.microsphere-projects
+ microsphere-mybatis-spring
true
+
- org.springframework.boot
- spring-boot-actuator
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-redis
+ ${revision}
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-redis-spring
true
@@ -55,10 +83,17 @@
true
-
+
- org.springframework.data
- spring-data-redis
+ com.alibaba
+ druid
+ true
+
+
+
+
+ org.hibernate
+ hibernate-core
true
@@ -81,11 +116,31 @@
true
+
+
+ org.springframework.data
+ spring-data-redis
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
- junit
- junit
- test
+ org.junit.jupiter
+ junit-jupiter
+ true
@@ -94,12 +149,35 @@
test
+
io.github.microsphere-projects
microsphere-spring-test
test
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-druid-spring-test
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-mybatis-spring-test
+ test
+
+
+
+
+ com.h2database
+ h2
+ test
+
+
+
io.lettuce
lettuce-core
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
index 5538176..cebaed8 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
@@ -1,7 +1,15 @@
package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelEnabled;
+import io.microsphere.mybatis.spring.annotation.EnableMyBatis;
+import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Import;
+
+import static io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelEnabled.PREFIX;
+import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
/**
* Microsphere Sentinel Spring Boot Auto-Configuration
@@ -16,78 +24,34 @@
"org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration",
"com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration",
})
+@Import(value = {
+ SentinelAutoConfiguration.RedisConfiguration.class,
+ SentinelAutoConfiguration.MyBatisConfiguration.class
+})
public class SentinelAutoConfiguration {
-// @ConditionalOnProperty(
-// prefix = PREFIX + "redis",
-// name = ENABLED_PROPERTY_NAME,
-// matchIfMissing = true
-// )
-// @ConditionalOnClass(name = {
-// "org.springframework.data.redis.connection.RedisConnection",
-// "io.microsphere.redis.spring.interceptor.RedisConnectionInterceptor"
-// })
-// static class RedisConfiguration {
-//
-// @Bean
-// @ConditionalOnMissingBean
-// public SentinelRedisCommandInterceptor sentinelRedisCommandInterceptor() {
-// return new SentinelRedisCommandInterceptor();
-// }
-// }
+ @ConditionalOnProperty(
+ prefix = PREFIX + "redis",
+ name = ENABLED_PROPERTY_NAME,
+ matchIfMissing = true
+ )
+ @ConditionalOnClass(name = {
+ "org.springframework.data.redis.connection.RedisConnection",
+ "io.microsphere.redis.spring.interceptor.RedisConnectionInterceptor"
+ })
+ @EnableRedisInterceptor
+ static class RedisConfiguration {
+ }
-// @ConditionalOnProperty(
-// prefix = PREFIX + "hibernate",
-// name = ENABLED_PROPERTY_NAME,
-// matchIfMissing = true
-// )
-// @ConditionalOnClass(name = {
-// "org.hibernate.SessionFactory", // Hibernate
-// "org.springframework.orm.hibernate5.LocalSessionFactoryBean" // Spring ORM
-// })
-// static class HibernateConfiguration {
-//
-// @Bean
-// @ConditionalOnMissingBean
-// public BeanPostProcessor sentinelHibernateInterceptorBeanPostProcessor() {
-// return new SentinelHibernateInterceptorBeanPostProcessor();
-// }
-// }
-//
-// @ConditionalOnProperty(
-// prefix = PREFIX + "druid",
-// name = ENABLED_PROPERTY_NAME,
-// matchIfMissing = true
-// )
-// @ConditionalOnClass(name = {
-// "com.alibaba.druid.pool.DruidDataSource"
-// })
-// static class DruidConfiguration {
-//
-// @Bean
-// @ConditionalOnMissingBean
-// public BeanPostProcessor sentinelDruidFilterBeanPostProcessor() {
-// return new SentinelDruidFilterBeanPostProcessor();
-// }
-// }
-//
-// @ConditionalOnProperty(
-// prefix = PREFIX + "mybatis",
-// name = ENABLED_PROPERTY_NAME,
-// matchIfMissing = true
-// )
-// @ConditionalOnClass(name = {
-// "org.apache.ibatis.executor.Executor"
-// })
-// static class MyBatisConfiguration {
-//
-// @Autowired
-// public void initSentinelMyBatisInterceptor(ObjectProvider sqlSessionFactoryProvider) {
-// SentinelMyBatisInterceptor interceptor = new SentinelMyBatisInterceptor();
-// SqlSessionFactory[] sqlSessionFactories = sqlSessionFactoryProvider.getIfAvailable();
-// for (SqlSessionFactory sqlSessionFactory : sqlSessionFactories) {
-// sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
-// }
-// }
-// }
+ @ConditionalOnProperty(
+ prefix = PREFIX + "mybatis",
+ name = ENABLED_PROPERTY_NAME,
+ matchIfMissing = true
+ )
+ @ConditionalOnClass(name = {
+ "org.apache.ibatis.executor.Executor"
+ })
+ @EnableMyBatis
+ static class MyBatisConfiguration {
+ }
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
new file mode 100644
index 0000000..b3f6047
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.core.StringRedisTemplate;
+
+/**
+ * The configuration class for Redis testing
+ *
+ * @author Mercy
+ * @see RedisTemplate
+ * @see StringRedisTemplate
+ * @see RedisConnectionFactory
+ * @since 1.0.0
+ */
+public class RedisConfig {
+
+ @Bean
+ public static RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ RedisTemplate redisTemplate = new RedisTemplate();
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
+ return redisTemplate;
+ }
+
+ @Bean
+ public static StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
+ stringRedisTemplate.setConnectionFactory(redisConnectionFactory);
+ return stringRedisTemplate;
+ }
+
+ @Bean
+ public static RedisConnectionFactory redisConnectionFactory() {
+ LettuceConnectionFactory redisConnectionFactory = new LettuceConnectionFactory("127.0.0.1", 6379);
+ redisConnectionFactory.afterPropertiesSet();
+ redisConnectionFactory.validateConnection();
+ return redisConnectionFactory;
+ }
+}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
new file mode 100644
index 0000000..90a84c1
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.druid.pool.DruidDataSource;
+import io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor;
+import io.microsphere.mybatis.spring.test.config.MyBatisDataBaseTestConfiguration;
+import io.microsphere.mybatis.test.mapper.UserMapper;
+import io.microsphere.redis.spring.context.RedisContext;
+import org.apache.ibatis.session.Configuration;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.data.redis.core.ValueOperations;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+
+import java.io.IOException;
+
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static io.microsphere.alibaba.druid.test.AlibabaDruidTestUtils.buildDefaultDruidDataSource;
+import static io.microsphere.mybatis.test.AbstractMapperTest.assertUserMapper;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+/**
+ * {@link SentinelAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelAutoConfiguration
+ * @since 1.0.0
+ */
+@SpringJUnitConfig(classes = {
+ MyBatisDataBaseTestConfiguration.class,
+ RedisConfig.class,
+ SentinelAutoConfigurationTest.class
+})
+@TestPropertySource(properties = {
+ "microsphere.redis.enabled=true",
+ "spring.application.name=test-app",
+ "mybatis.configLocation=META-INF/mybatis/config.xml"
+})
+@EnableAutoConfiguration
+class SentinelAutoConfigurationTest {
+
+ @Autowired
+ private RedisContext redisContext;
+
+ @Autowired
+ private StringRedisTemplate stringRedisTemplate;
+
+ @Autowired
+ private SentinelRedisCommandInterceptor interceptor;
+
+ @Autowired
+ private SqlSessionFactory sessionFactory;
+
+ @Bean(initMethod = "init", destroyMethod = "close")
+ public DruidDataSource dataSource() throws IOException {
+ return buildDefaultDruidDataSource();
+ }
+
+ @Test
+ void test() {
+ testAlibabaDruidAndMyBatisPlugin();
+ testRedisPlugin();
+ }
+
+ private void testAlibabaDruidAndMyBatisPlugin() {
+ Configuration configuration = this.sessionFactory.getConfiguration();
+ SqlSession sqlSession = this.sessionFactory.openSession();
+ UserMapper userMapper = configuration.getMapper(UserMapper.class, sqlSession);
+ assertUserMapper(userMapper);
+
+ Context context = enter("microsphere_sentinel_alibaba_druid_context", "Filter");
+ assertNotNull(context);
+
+ context = enter("microsphere_sentinel_mybatis_context", "Executor");
+ assertNotNull(context);
+ }
+
+ void testRedisPlugin() {
+ String key = "key";
+ String value = "value";
+ ValueOperations valueOperations = this.stringRedisTemplate.opsForValue();
+ valueOperations.set(key, value);
+ assertEquals(value, valueOperations.get(key));
+
+ Context context = enter("microsphere_sentinel_redis_context", "RedisConnection");
+ assertNotNull(context);
+ }
+}
\ No newline at end of file
From baeb3359b8dc0a66cd872aacb40365adae0705f8 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 5 Jun 2026 19:57:11 +0800
Subject: [PATCH 04/42] Remove RedisContextConfig test class
Delete RedisContextConfig.java from the microsphere-alibaba-sentinel-redis test sources. This removed the test configuration that declared RedisContext (bean name RedisContext.BEAN_NAME) and RedisConfiguration (bean name RedisConfiguration.BEAN_NAME).
---
.../redis/spring/test/RedisContextConfig.java | 45 -------------------
1 file changed, 45 deletions(-)
delete mode 100644 microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisContextConfig.java
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisContextConfig.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisContextConfig.java
deleted file mode 100644
index 5fe8ccf..0000000
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisContextConfig.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.microsphere.alibaba.sentinel.redis.spring.test;
-
-import io.microsphere.redis.spring.config.RedisConfiguration;
-import io.microsphere.redis.spring.context.RedisContext;
-import org.springframework.context.annotation.Bean;
-
-import static io.microsphere.redis.spring.context.RedisContext.BEAN_NAME;
-
-/**
- * The configuration class for testing RedisContext
- *
- * @author Mercy
- * @see RedisContext
- * @see RedisConfiguration
- * @since 1.0.0
- */
-public class RedisContextConfig extends RedisConfig {
-
- @Bean(BEAN_NAME)
- public static RedisContext redisContext() {
- return new RedisContext();
- }
-
- @Bean(RedisConfiguration.BEAN_NAME)
- public static RedisConfiguration redisConfiguration() {
- return new RedisConfiguration();
- }
-}
\ No newline at end of file
From fd3e649e11192538bdf3e0fc158f3334552def1d Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:05:45 +0800
Subject: [PATCH 05/42] Bump Microsphere Spring Cloud to 0.1.21
Update the root parent POM and the shared BOM version property to Microsphere Spring Cloud 0.1.21 so the project aligns with the newer upstream dependency set.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
pom.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index b4b9ce7..f9523e4 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -20,7 +20,7 @@
- 0.1.16
+ 0.1.21
0.1.16
0.1.9
0.1.5
diff --git a/pom.xml b/pom.xml
index 35ae772..2832c77 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.github.microsphere-projects
microsphere-spring-cloud-parent
- 0.1.16
+ 0.1.21
io.github.microsphere-projects
From 643a2cef3b4a207f9b6b719b57d0f68f5f2ffb6e Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:06:56 +0800
Subject: [PATCH 06/42] Bump microsphere-alibaba-druid to 0.1.24
Updates the parent POM BOM property for `microsphere-alibaba-druid` from `0.1.16` to `0.1.24` to align dependency management with the newer Druid integration release.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index f9523e4..1d4f44f 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -21,7 +21,7 @@
0.1.21
- 0.1.16
+ 0.1.24
0.1.9
0.1.5
0.1.8
From 17e7d97515746122bd1bc9a6c6c040bfc6785920 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:07:54 +0800
Subject: [PATCH 07/42] Bump microsphere-mybatis to 0.1.12
Update the parent BOM property in `microsphere-alibaba-sentinel-parent/pom.xml` to use `microsphere-mybatis` version `0.1.12` instead of `0.1.9`, aligning dependency management with the newer MyBatis integration release.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index 1d4f44f..04ffe4e 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -22,7 +22,7 @@
0.1.21
0.1.24
- 0.1.9
+ 0.1.12
0.1.5
0.1.8
From 8166e3e88db3a1fec0482a0b3b9a784c6a16a9a1 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:08:49 +0800
Subject: [PATCH 08/42] Bump microsphere-redis to 0.1.9
Update the parent POM to use microsphere-redis 0.1.9 so the project picks up the latest Redis integration changes and fixes from that dependency release.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index 04ffe4e..af6ef20 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -24,7 +24,7 @@
0.1.24
0.1.12
0.1.5
- 0.1.8
+ 0.1.9
1.8.10
2.0.62
From 63e4075942dc2000ac82babd628174f8a87728aa Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:13:12 +0800
Subject: [PATCH 09/42] Downgrade Alibaba Druid BOM version
Set `microsphere-alibaba-druid.version` back from `0.1.24` to `0.1.17` in the parent POM, aligning this module with the intended Druid dependency version.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index af6ef20..4bafb23 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -21,7 +21,7 @@
0.1.21
- 0.1.24
+ 0.1.17
0.1.12
0.1.5
0.1.9
From 7a031e7566a8b87ec895e20841226fb9cf220805 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:14:32 +0800
Subject: [PATCH 10/42] Bump microsphere-hibernate to 0.1.6
Update the parent Maven BOM to use microsphere-hibernate 0.1.6 so downstream modules pick up the latest Hibernate integration changes.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index 4bafb23..e47f05c 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -23,7 +23,7 @@
0.1.21
0.1.17
0.1.12
- 0.1.5
+ 0.1.6
0.1.9
1.8.10
From 8fc8cfff0ae02cf183687a8f6359d7630cfc8bd6 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:57:15 +0800
Subject: [PATCH 11/42] Refactor Sentinel enablement conditions
Centralized Sentinel enabled-property metadata in `SentinelConstants` (including a shared default value) and updated plugin constants to reuse it. Introduced `@ConditionalOnSentinelAvailiable` to separate classpath availability from property checks, then updated auto-configuration to use the new condition and explicit plugin property names for Redis/MyBatis toggles. Also added the optional microsphere annotation processor dependency required for configuration property annotations.
---
microsphere-alibaba-sentinel-commons/pom.xml | 7 +++
.../common/constants/SentinelConstants.java | 23 +++++++
.../druid/SentinelAlibabaDruidConstants.java | 3 +-
.../hibernate/SentinelHibernateConstants.java | 3 +-
.../mybatis/SentinelMyBatisConstants.java | 3 +-
.../p6spy/SentinelP6SpyConstants.java | 3 +-
.../redis/SentinelRedisConstants.java | 3 +-
.../pom.xml | 2 +
.../web/SentinelSpringWebConstants.java | 2 +-
.../SentinelAutoConfiguration.java | 15 ++---
.../ConditionalOnSentinelAvailiable.java | 60 +++++++++++++++++++
.../ConditionalOnSentinelEnabled.java | 15 +----
12 files changed, 112 insertions(+), 27 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java
diff --git a/microsphere-alibaba-sentinel-commons/pom.xml b/microsphere-alibaba-sentinel-commons/pom.xml
index 5fd3371..1948978 100644
--- a/microsphere-alibaba-sentinel-commons/pom.xml
+++ b/microsphere-alibaba-sentinel-commons/pom.xml
@@ -26,6 +26,13 @@
microsphere-java-core
+
+
+ io.github.microsphere-projects
+ microsphere-annotation-processor
+ true
+
+
com.alibaba.csp
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/constants/SentinelConstants.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/constants/SentinelConstants.java
index da4cefc..0162810 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/constants/SentinelConstants.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/constants/SentinelConstants.java
@@ -18,6 +18,11 @@
package io.microsphere.alibaba.sentinel.common.constants;
import io.microsphere.alibaba.sentinel.common.SentinelContext;
+import io.microsphere.annotation.ConfigurationProperty;
+import io.microsphere.constants.PropertyConstants;
+
+import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
+import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
/**
* The constants of Sentinel
@@ -52,6 +57,24 @@ public interface SentinelConstants {
*/
String PROPERTY_NAME_PREFIX = "microsphere.sentinel.";
+ /**
+ * The default value of enabled : "true"
+ */
+ String ENABLED_PROPERTY_VALUE = "true";
+
+ /**
+ * The Property Name of enabled : "microsphere.sentinel.enabled"
+ */
+ @ConfigurationProperty(
+ type = boolean.class,
+ defaultValue = ENABLED_PROPERTY_VALUE,
+ source = {
+ SYSTEM_PROPERTIES_SOURCE,
+ APPLICATION_SOURCE
+ }
+ )
+ String ENABLED_PROPERTY_NAME = PROPERTY_NAME_PREFIX + PropertyConstants.ENABLED_PROPERTY_NAME;
+
/**
* The attribute name of {@link SentinelContext}
*
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
index 0db4b78..513cc3c 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
@@ -52,7 +53,7 @@ public interface SentinelAlibabaDruidConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = SYSTEM_PROPERTIES_SOURCE
)
String ENABLED_PROPERTY_NAME = PROPERTY_NAME_PREFIX + PLUGIN_NAME + DOT + PropertyConstants.ENABLED_PROPERTY_NAME;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
index 700d3e5..431517d 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
@@ -52,7 +53,7 @@ public interface SentinelHibernateConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = SYSTEM_PROPERTIES_SOURCE
)
String ENABLED_PROPERTY_NAME = PROPERTY_NAME_PREFIX + PLUGIN_NAME + DOT + PropertyConstants.ENABLED_PROPERTY_NAME;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
index abfdff9..ea84256 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
@@ -52,7 +53,7 @@ public interface SentinelMyBatisConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = SYSTEM_PROPERTIES_SOURCE
)
String ENABLED_PROPERTY_NAME = PROPERTY_NAME_PREFIX + PLUGIN_NAME + DOT + PropertyConstants.ENABLED_PROPERTY_NAME;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
index bac74c4..3597c9d 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
@@ -52,7 +53,7 @@ public interface SentinelP6SpyConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = SYSTEM_PROPERTIES_SOURCE
)
String ENABLED_PROPERTY_NAME = PROPERTY_NAME_PREFIX + PLUGIN_NAME + DOT + PropertyConstants.ENABLED_PROPERTY_NAME;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
index 81253c6..c21c7e5 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
@@ -53,7 +54,7 @@ public interface SentinelRedisConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = {
SYSTEM_PROPERTIES_SOURCE,
APPLICATION_SOURCE
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
index 6b46314..e15b153 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
@@ -48,6 +48,8 @@
true
+
+
jakarta.servlet
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
index e7862e9..8166ea4 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
@@ -53,7 +53,7 @@ public interface SentinelSpringWebConstants {
*/
@ConfigurationProperty(
type = boolean.class,
- defaultValue = "true",
+ defaultValue = ENABLED_PROPERTY_VALUE,
source = {
SYSTEM_PROPERTIES_SOURCE,
APPLICATION_SOURCE
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
index cebaed8..e0338d1 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
@@ -1,6 +1,8 @@
package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
-import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelEnabled;
+import io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants;
+import io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailiable;
import io.microsphere.mybatis.spring.annotation.EnableMyBatis;
import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -8,9 +10,6 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Import;
-import static io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelEnabled.PREFIX;
-import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
-
/**
* Microsphere Sentinel Spring Boot Auto-Configuration
*
@@ -18,7 +17,7 @@
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
* @since 1.0.0
*/
-@ConditionalOnSentinelEnabled
+@ConditionalOnSentinelAvailiable
@AutoConfigureAfter(name = {
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration",
"org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration",
@@ -31,8 +30,7 @@
public class SentinelAutoConfiguration {
@ConditionalOnProperty(
- prefix = PREFIX + "redis",
- name = ENABLED_PROPERTY_NAME,
+ name = SentinelRedisConstants.ENABLED_PROPERTY_NAME,
matchIfMissing = true
)
@ConditionalOnClass(name = {
@@ -44,8 +42,7 @@ static class RedisConfiguration {
}
@ConditionalOnProperty(
- prefix = PREFIX + "mybatis",
- name = ENABLED_PROPERTY_NAME,
+ name = SentinelMyBatisConstants.ENABLED_PROPERTY_NAME,
matchIfMissing = true
)
@ConditionalOnClass(name = {
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java
new file mode 100644
index 0000000..bc6ded1
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.microsphere.alibaba.sentinel.spring.boot.condition;
+
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Indicates that a component is eligible for registration when Alibaba Sentinel is available.
+ *
+ * This annotation combines {@link ConditionalOnSentinelEnabled @ConditionalOnSentinelEnabled} and
+ * {@link ConditionalOnClass @ConditionalOnClass(name = "com.alibaba.csp.sentinel.SphU")},
+ * meaning the annotated component will be registered only if Sentinel is explicitly enabled
+ * and the Sentinel core classes are present on the classpath.
+ *
+ *
+ * Usage Example
+ * {@code
+ * @Configuration
+ * @ConditionalOnSentinelAvailiable
+ * public class MySentinelConfiguration {
+ * // This configuration will only be active if Sentinel is available
+ * }
+ * }
+ *
+ * @author Mercy
+ * @see SentinelAutoConfiguration
+ * @since 1.0.0
+ */
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+@Documented
+@ConditionalOnSentinelEnabled
+@ConditionalOnClass(name = {
+ "com.alibaba.csp.sentinel.SphU"
+})
+public @interface ConditionalOnSentinelAvailiable {
+}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
index c1051fc..1034e66 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
@@ -17,20 +17,19 @@
package io.microsphere.alibaba.sentinel.spring.boot.condition;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
-import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_NAME;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Alibaba Sentinel Spring Boot Condition
+ * {@link ConditionalOnProperty} based annotation for Alibaba Sentinel enabled property.
*
* @author Mercy
* @see SentinelAutoConfiguration
@@ -39,14 +38,6 @@
@Retention(RUNTIME)
@Target({TYPE, METHOD})
@Documented
-@ConditionalOnProperty(prefix = ConditionalOnSentinelEnabled.PREFIX, name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
-@ConditionalOnClass(name = {
- "com.alibaba.csp.sentinel.SphU"
-})
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
public @interface ConditionalOnSentinelEnabled {
-
- /**
- * The property name prefix for Alibaba Sentinel : "microsphere.sentinel."
- */
- String PREFIX = "microsphere.sentinel.";
}
\ No newline at end of file
From 11c6974434004acef31684aedfac37a9dc12e1b9 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Thu, 2 Jul 2026 22:58:05 +0800
Subject: [PATCH 12/42] Reorder imports across Sentinel modules
Clean up import and static import ordering in the commons and plugin modules to keep the codebase consistent with the project's formatting conventions. No functional behavior is changed.
---
.../alibaba/sentinel/common/SentinelPlugin.java | 2 +-
.../alibaba/sentinel/common/SentinelTemplate.java | 2 +-
.../alibaba/sentinel/common/util/SentinelUtils.java | 6 +++---
.../sentinel/jmx/JMXSentinelPluginRepository.java | 6 +++---
.../sentinel/common/util/SentinelUtilsTest.java | 2 +-
.../entity/SentinelHibernateEntityCallback.java | 6 +++---
.../hibernate/SentinelHibernateConstantsTest.java | 2 +-
.../executor/SentinelMyBatisExecutorFilter.java | 4 ++--
.../sentinel/mybatis/SentinelMyBatisConstantsTest.java | 2 +-
.../sentinel/p6spy/SentinelJdbcEventListener.java | 6 +++---
.../sentinel/p6spy/SentinelP6SpyConstantsTest.java | 2 +-
.../alibaba/sentinel/redis/SentinelRedisConstants.java | 2 +-
.../redis/spring/SentinelRedisCommandInterceptor.java | 10 +++++-----
.../spring/web/SentinelHandlerMethodInterceptor.java | 8 ++++----
14 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelPlugin.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelPlugin.java
index 7fee5bb..8d54764 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelPlugin.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelPlugin.java
@@ -19,9 +19,9 @@
import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.ResourceTypeConstants;
-import io.microsphere.annotation.Nonnull;
import io.microsphere.alibaba.sentinel.common.constants.SentinelConstants;
import io.microsphere.alibaba.sentinel.common.util.SentinelUtils;
+import io.microsphere.annotation.Nonnull;
import static io.microsphere.alibaba.sentinel.common.SentinelPluginRepository.INSTANCE;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getDefaultContextName;
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelTemplate.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelTemplate.java
index fa43826..2de3009 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelTemplate.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SentinelTemplate.java
@@ -27,9 +27,9 @@
import static com.alibaba.csp.sentinel.Tracer.traceEntry;
import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
-import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_ORIGIN;
+import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.util.StringUtils.isBlank;
/**
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
index cf05559..4d93cb0 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
@@ -13,14 +13,14 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_CONTEXT_NAME_PATTERN;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.FLOW_DATA_ID_PATTERN;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.collection.MapUtils.newFixedHashMap;
import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
import static io.microsphere.constants.SymbolConstants.DOT;
import static io.microsphere.reflect.FieldUtils.getFieldValue;
import static io.microsphere.reflect.FieldUtils.getStaticFieldValue;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_CONTEXT_NAME_PATTERN;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.FLOW_DATA_ID_PATTERN;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.text.FormatUtils.format;
import static io.microsphere.util.ClassUtils.getSimpleName;
import static io.microsphere.util.SystemUtils.getSystemProperty;
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/jmx/JMXSentinelPluginRepository.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/jmx/JMXSentinelPluginRepository.java
index ed9c3a9..c2a44f4 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/jmx/JMXSentinelPluginRepository.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/jmx/JMXSentinelPluginRepository.java
@@ -17,11 +17,11 @@
package io.microsphere.alibaba.sentinel.jmx;
-import io.microsphere.lang.Prioritized;
-import io.microsphere.lang.function.ThrowableBiFunction;
import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelPluginRepository;
import io.microsphere.alibaba.sentinel.common.SimpleSentinelPluginRepository;
+import io.microsphere.lang.Prioritized;
+import io.microsphere.lang.function.ThrowableBiFunction;
import javax.management.MBeanServer;
import javax.management.ObjectName;
@@ -29,8 +29,8 @@
import java.util.Collection;
import java.util.Set;
-import static io.microsphere.lang.function.ThrowableSupplier.execute;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
+import static io.microsphere.lang.function.ThrowableSupplier.execute;
import static io.microsphere.text.FormatUtils.format;
import static java.lang.management.ManagementFactory.getPlatformMBeanServer;
import static java.util.Collections.emptyList;
diff --git a/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java b/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
index 2fa9828..5bee64d 100644
--- a/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
+++ b/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
@@ -9,7 +9,6 @@
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_RPC;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_WEB;
-import static io.microsphere.reflect.MethodUtils.findMethod;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.buildResourceName;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.findSentinelMetricsTaskExecutor;
@@ -19,6 +18,7 @@
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getResourceTypeAsString;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getSentinelMetricsTaskExecutor;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.isPluginEnabled;
+import static io.microsphere.reflect.MethodUtils.findMethod;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
index 2c2e36a..1c16e19 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
@@ -18,25 +18,25 @@
package io.microsphere.alibaba.sentinel.hibernate.entity;
import com.alibaba.csp.sentinel.EntryType;
-import io.microsphere.annotation.Nonnull;
-import io.microsphere.hibernate.entity.EntityCallback;
import io.microsphere.alibaba.sentinel.common.SentinelContext;
import io.microsphere.alibaba.sentinel.common.SentinelOperations;
import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelTemplate;
import io.microsphere.alibaba.sentinel.common.SimpleSentinelPlugin;
+import io.microsphere.annotation.Nonnull;
+import io.microsphere.hibernate.entity.EntityCallback;
import org.hibernate.type.Type;
import java.util.Optional;
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
-import static io.microsphere.lang.function.ThrowableSupplier.execute;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
+import static io.microsphere.lang.function.ThrowableSupplier.execute;
import static java.util.Optional.empty;
import static java.util.Optional.of;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
index 9d7d047..1145b49 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/SentinelHibernateConstantsTest.java
@@ -19,11 +19,11 @@
import org.junit.jupiter.api.Test;
+import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.ENABLED_PROPERTY_NAME;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
-import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
index bb35b4a..e989b80 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilter.java
@@ -17,11 +17,11 @@
package io.microsphere.alibaba.sentinel.mybatis.executor;
-import io.microsphere.mybatis.executor.ExecutorFilter;
-import io.microsphere.mybatis.executor.ExecutorFilterChain;
import io.microsphere.alibaba.sentinel.common.AbstractSentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelOperations;
import io.microsphere.alibaba.sentinel.common.SentinelTemplate;
+import io.microsphere.mybatis.executor.ExecutorFilter;
+import io.microsphere.mybatis.executor.ExecutorFilterChain;
import org.apache.ibatis.cache.CacheKey;
import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
index 4e5b3fc..63e1e32 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstantsTest.java
@@ -19,11 +19,11 @@
import org.junit.jupiter.api.Test;
+import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.ENABLED_PROPERTY_NAME;
import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.PLUGIN_NAME;
-import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
index 9503913..2a10b1f 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
@@ -21,24 +21,24 @@
import com.p6spy.engine.common.StatementInformation;
import com.p6spy.engine.event.JdbcEventListener;
import com.p6spy.engine.event.SimpleJdbcEventListener;
-import io.microsphere.logging.Logger;
import io.microsphere.alibaba.sentinel.common.SentinelContext;
import io.microsphere.alibaba.sentinel.common.SentinelOperations;
import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelTemplate;
import io.microsphere.alibaba.sentinel.common.SimpleSentinelPlugin;
+import io.microsphere.logging.Logger;
import java.sql.SQLException;
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
-import static io.microsphere.lang.function.ThrowableAction.execute;
-import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
+import static io.microsphere.lang.function.ThrowableAction.execute;
+import static io.microsphere.logging.LoggerFactory.getLogger;
/**
* P6Spy {@link JdbcEventListener} based on Alibaba Sentinel
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
index 2f7a87f..48c6248 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelP6SpyConstantsTest.java
@@ -19,11 +19,11 @@
import org.junit.jupiter.api.Test;
+import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.ENABLED_PROPERTY_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
-import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getPluginEnabledPropertyName;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
index c21c7e5..3f7d3f2 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
@@ -21,10 +21,10 @@
import io.microsphere.constants.PropertyConstants;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
import static io.microsphere.constants.SymbolConstants.DOT;
-import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
/**
* The interface to declare the constants of Redis
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
index f8f997f..23dbf13 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptor.java
@@ -16,13 +16,13 @@
*/
package io.microsphere.alibaba.sentinel.redis.spring;
-import io.microsphere.logging.Logger;
-import io.microsphere.redis.spring.interceptor.RedisConnectionInterceptor;
-import io.microsphere.redis.spring.interceptor.RedisMethodContext;
import io.microsphere.alibaba.sentinel.common.AbstractSentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelContext;
import io.microsphere.alibaba.sentinel.common.SentinelOperations;
import io.microsphere.alibaba.sentinel.common.SentinelTemplate;
+import io.microsphere.logging.Logger;
+import io.microsphere.redis.spring.interceptor.RedisConnectionInterceptor;
+import io.microsphere.redis.spring.interceptor.RedisMethodContext;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.redis.connection.RedisClusterConnection;
@@ -31,14 +31,14 @@
import java.lang.reflect.Method;
import java.util.Map;
-import static io.microsphere.collection.MapUtils.newFixedHashMap;
-import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.SENTINEL_CONTEXT_ATTRIBUTE_NAME;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.buildResourceName;
import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.PLUGIN_NAME;
+import static io.microsphere.collection.MapUtils.newFixedHashMap;
+import static io.microsphere.logging.LoggerFactory.getLogger;
import static org.springframework.util.ClassUtils.getAllInterfacesForClass;
/**
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
index 11b05e3..aa3be6b 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptor.java
@@ -16,13 +16,13 @@
*/
package io.microsphere.alibaba.sentinel.spring.web;
-import io.microsphere.annotation.Nonnull;
-import io.microsphere.logging.Logger;
import io.microsphere.alibaba.sentinel.common.AbstractSentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelContext;
import io.microsphere.alibaba.sentinel.common.SentinelOperations;
import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
import io.microsphere.alibaba.sentinel.common.SentinelTemplate;
+import io.microsphere.annotation.Nonnull;
+import io.microsphere.logging.Logger;
import io.microsphere.spring.web.annotation.EnableWebExtension;
import io.microsphere.spring.web.event.WebEndpointMappingsReadyEvent;
import io.microsphere.spring.web.metadata.WebEndpointMapping;
@@ -38,13 +38,13 @@
import java.util.Map;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_WEB;
-import static io.microsphere.collection.MapUtils.newFixedHashMap;
-import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.SENTINEL_CONTEXT_ATTRIBUTE_NAME;
import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.PLUGIN_NAME;
+import static io.microsphere.collection.MapUtils.newFixedHashMap;
+import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.spring.web.util.WebScope.REQUEST;
/**
From 812f81e2a7edfaf15f1b524057845413bda9f3b7 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 3 Jul 2026 09:24:28 +0800
Subject: [PATCH 13/42] Bump microsphere-redis to 0.1.10
Update the parent POM to use microsphere-redis 0.1.10 instead of 0.1.9, aligning the project with the latest microsphere-redis release.
---
microsphere-alibaba-sentinel-parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index e47f05c..2899fdf 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -24,7 +24,7 @@
0.1.17
0.1.12
0.1.6
- 0.1.9
+ 0.1.10
1.8.10
2.0.62
From 6a4396c58a929a738b437b615c1ec0274ff77564 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 3 Jul 2026 09:29:55 +0800
Subject: [PATCH 14/42] Import shared enabled property constant
Add a static import for `ENABLED_PROPERTY_VALUE` in `SentinelSpringWebConstants` to align with common Sentinel constants usage and prepare/clean up centralized property value references.
---
.../alibaba/sentinel/spring/web/SentinelSpringWebConstants.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
index 8166ea4..55414f5 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
@@ -20,6 +20,7 @@
import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.constants.PropertyConstants;
+import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.ENABLED_PROPERTY_VALUE;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
import static io.microsphere.annotation.ConfigurationProperty.SYSTEM_PROPERTIES_SOURCE;
From 71c253f65d7b72b9a1d34931f78abbf3b2969787 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 3 Jul 2026 22:45:58 +0800
Subject: [PATCH 15/42] Fix typo in Sentinel conditional annotation
Rename `ConditionalOnSentinelAvailiable` to `ConditionalOnSentinelAvailable` and update `SentinelAutoConfiguration` imports/usages accordingly. This corrects the spelling in the public annotation type and keeps auto-configuration wiring aligned.
---
.../spring/boot/autoconfigure/SentinelAutoConfiguration.java | 4 ++--
...nelAvailiable.java => ConditionalOnSentinelAvailable.java} | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
rename microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/{ConditionalOnSentinelAvailiable.java => ConditionalOnSentinelAvailable.java} (97%)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
index e0338d1..3a12a37 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
@@ -2,7 +2,7 @@
import io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants;
import io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants;
-import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailiable;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
import io.microsphere.mybatis.spring.annotation.EnableMyBatis;
import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -17,7 +17,7 @@
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
* @since 1.0.0
*/
-@ConditionalOnSentinelAvailiable
+@ConditionalOnSentinelAvailable
@AutoConfigureAfter(name = {
"org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration",
"org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration",
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
similarity index 97%
rename from microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java
rename to microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
index bc6ded1..308d45c 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailiable.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
@@ -56,5 +56,5 @@
@ConditionalOnClass(name = {
"com.alibaba.csp.sentinel.SphU"
})
-public @interface ConditionalOnSentinelAvailiable {
+public @interface ConditionalOnSentinelAvailable {
}
\ No newline at end of file
From e3cce4b56e53a8c366d305696e2e3e4778e1793a Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Fri, 3 Jul 2026 23:35:53 +0800
Subject: [PATCH 16/42] Split Sentinel auto-config by integration module
Replaces the monolithic `SentinelAutoConfiguration` with dedicated Spring Boot auto-configurations for Alibaba Druid, MyBatis, and Redis, and updates auto-configuration registration files accordingly. The change also tightens Sentinel availability conditions, adds/aligns optional module dependencies in POMs, and updates related tests (including explicit Druid filter wiring) to match the new bootstrap model.
---
.../pom.xml | 13 ++--
.../druid/SentinelAlibabaDruidFilter.java | 2 -
.../druid/SentinelAlibabaDruidFilterTest.java | 5 ++
.../pom.xml | 13 ++--
.../pom.xml | 13 ++--
.../pom.xml | 12 ++--
.../pom.xml | 13 ++--
.../pom.xml | 35 ++++-----
.../pom.xml | 56 ++++++++++++++-
...SentinelAlibabaDruidAutoConfiguration.java | 64 +++++++++++++++++
.../SentinelAutoConfiguration.java | 54 --------------
.../SentinelMyBatisAutoConfiguration.java | 71 +++++++++++++++++++
.../SentinelRedisAutoConfiguration.java | 51 +++++++++++++
.../ConditionalOnSentinelAvailable.java | 13 ++--
.../ConditionalOnSentinelEnabled.java | 4 +-
.../main/resources/META-INF/spring.factories | 4 +-
...ot.autoconfigure.AutoConfiguration.imports | 4 +-
.../SentinelAutoConfigurationTest.java | 6 +-
18 files changed, 311 insertions(+), 122 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
delete mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
index 5977c77..a591751 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/pom.xml
@@ -20,6 +20,13 @@
+
+
+ io.github.microsphere-projects
+ microsphere-annotation-processor
+ true
+
+
io.github.microsphere-projects
@@ -31,12 +38,6 @@
io.github.microsphere-projects
microsphere-alibaba-druid-core
-
-
-
-
- io.github.microsphere-projects
- microsphere-annotation-processor
true
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
index 7606702..7fd5e32 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
@@ -17,7 +17,6 @@
package io.microsphere.alibaba.sentinel.alibaba.druid;
import com.alibaba.csp.sentinel.EntryType;
-import com.alibaba.druid.filter.AutoLoad;
import com.alibaba.druid.filter.Filter;
import com.alibaba.druid.filter.FilterAdapter;
import com.alibaba.druid.proxy.jdbc.StatementProxy;
@@ -44,7 +43,6 @@
* @see FilterAdapter
* @since 1.0.0
*/
-@AutoLoad
public class SentinelAlibabaDruidFilter extends AbstractStatementFilter implements SentinelPlugin {
private final SentinelPlugin delegate;
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
index fdd7b44..4dad1aa 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
@@ -37,6 +37,11 @@
*/
class SentinelAlibabaDruidFilterTest extends AbstractAlibabaDruidTest {
+ @Override
+ protected void customize(DruidDataSource dataSource) {
+ dataSource.getProxyFilters().add(new SentinelAlibabaDruidFilter());
+ }
+
@Test
void testEnable() throws Throwable {
setEnable(true);
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
index 1f64a82..773d404 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/pom.xml
@@ -20,6 +20,13 @@
+
+
+ io.github.microsphere-projects
+ microsphere-annotation-processor
+ true
+
+
io.github.microsphere-projects
@@ -31,12 +38,6 @@
io.github.microsphere-projects
microsphere-hibernate-core
-
-
-
-
- io.github.microsphere-projects
- microsphere-annotation-processor
true
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
index e003c1d..0629976 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/pom.xml
@@ -20,6 +20,13 @@
+
+
+ io.github.microsphere-projects
+ microsphere-annotation-processor
+ true
+
+
io.github.microsphere-projects
@@ -31,12 +38,6 @@
io.github.microsphere-projects
microsphere-mybatis-core
-
-
-
-
- io.github.microsphere-projects
- microsphere-annotation-processor
true
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
index 77508b0..8ca9f01 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/pom.xml
@@ -20,18 +20,18 @@
-
+
io.github.microsphere-projects
- microsphere-alibaba-sentinel-commons
- ${revision}
+ microsphere-annotation-processor
+ true
-
+
io.github.microsphere-projects
- microsphere-annotation-processor
- true
+ microsphere-alibaba-sentinel-commons
+ ${revision}
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
index 9716a24..4546736 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
@@ -20,6 +20,13 @@
+
+
+ io.github.microsphere-projects
+ microsphere-annotation-processor
+ true
+
+
io.github.microsphere-projects
@@ -31,12 +38,6 @@
io.github.microsphere-projects
microsphere-redis-spring
-
-
-
-
- io.github.microsphere-projects
- microsphere-annotation-processor
true
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
index e15b153..2fdcff7 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/pom.xml
@@ -20,18 +20,18 @@
-
+
io.github.microsphere-projects
- microsphere-alibaba-sentinel-commons
- ${revision}
+ microsphere-annotation-processor
+ true
-
+
io.github.microsphere-projects
- microsphere-spring-context
- true
+ microsphere-alibaba-sentinel-commons
+ ${revision}
@@ -41,20 +41,13 @@
true
-
-
- io.github.microsphere-projects
- microsphere-annotation-processor
- true
-
-
-
+
- jakarta.servlet
- jakarta.servlet-api
- provided
+ com.alibaba.csp
+ sentinel-core
+ true
@@ -64,11 +57,11 @@
true
-
+
- com.alibaba.csp
- sentinel-core
- true
+ javax.servlet
+ javax.servlet-api
+ provided
diff --git a/microsphere-alibaba-sentinel-spring-boot/pom.xml b/microsphere-alibaba-sentinel-spring-boot/pom.xml
index e085b63..5a5c163 100644
--- a/microsphere-alibaba-sentinel-spring-boot/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-boot/pom.xml
@@ -40,6 +40,13 @@
${revision}
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-druid-spring-boot
+ true
+
+
io.github.microsphere-projects
@@ -47,6 +54,13 @@
${revision}
+
+
+ io.github.microsphere-projects
+ microsphere-hibernate-core
+ true
+
+
io.github.microsphere-projects
@@ -54,9 +68,10 @@
${revision}
+
io.github.microsphere-projects
- microsphere-mybatis-spring
+ microsphere-mybatis-spring-boot
true
@@ -67,10 +82,31 @@
${revision}
-
+
io.github.microsphere-projects
- microsphere-redis-spring
+ microsphere-redis-spring-boot
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-spring-web
+ ${revision}
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webmvc
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webflux
true
@@ -163,6 +199,13 @@
test
+
+
+ io.github.microsphere-projects
+ microsphere-hibernate-test
+ test
+
+
io.github.microsphere-projects
@@ -170,6 +213,13 @@
test
+
+
+ io.github.microsphere-projects
+ microsphere-redis-spring-test
+ test
+
+
com.h2database
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
new file mode 100644
index 0000000..5e565e4
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable;
+import io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+
+import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.ENABLED_PROPERTY_NAME;
+
+/**
+ * The Auto-Configuration class of Sentinel x Alibaba Druid
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see io.microsphere.alibaba.druid.spring.boot.autoconfigure.AlibabaDruidAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnSentinelAvailable
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
+@ConditionalOnClass(name = {
+ "io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable", // Microsphere Alibaba Druid Spring Boot
+ "io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter" // Microsphere Alibaba Sentinel x Alibaba Druid
+})
+@AutoConfigureAfter(name = {
+ "com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration", // Spring Cloud Alibaba Sentinel
+ "io.microsphere.alibaba.druid.spring.boot.autoconfigure.AlibabaDruidAutoConfiguration" // Microsphere Alibaba Sentinel Spring Boot x Alibaba Druid
+})
+@Import(value = {
+ SentinelAlibabaDruidAutoConfiguration.Config.class
+})
+public class SentinelAlibabaDruidAutoConfiguration {
+
+ @ConditionalOnAlibabaDruidAvailable
+ static class Config {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SentinelAlibabaDruidFilter sentinelAlibabaDruidFilter() {
+ return new SentinelAlibabaDruidFilter();
+ }
+ }
+}
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
deleted file mode 100644
index 3a12a37..0000000
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfiguration.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
-
-import io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants;
-import io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants;
-import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
-import io.microsphere.mybatis.spring.annotation.EnableMyBatis;
-import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
-import org.springframework.boot.autoconfigure.AutoConfigureAfter;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.context.annotation.Import;
-
-/**
- * Microsphere Sentinel Spring Boot Auto-Configuration
- *
- * @author Mercy
- * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
- * @since 1.0.0
- */
-@ConditionalOnSentinelAvailable
-@AutoConfigureAfter(name = {
- "org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration",
- "org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration",
- "com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration",
-})
-@Import(value = {
- SentinelAutoConfiguration.RedisConfiguration.class,
- SentinelAutoConfiguration.MyBatisConfiguration.class
-})
-public class SentinelAutoConfiguration {
-
- @ConditionalOnProperty(
- name = SentinelRedisConstants.ENABLED_PROPERTY_NAME,
- matchIfMissing = true
- )
- @ConditionalOnClass(name = {
- "org.springframework.data.redis.connection.RedisConnection",
- "io.microsphere.redis.spring.interceptor.RedisConnectionInterceptor"
- })
- @EnableRedisInterceptor
- static class RedisConfiguration {
- }
-
- @ConditionalOnProperty(
- name = SentinelMyBatisConstants.ENABLED_PROPERTY_NAME,
- matchIfMissing = true
- )
- @ConditionalOnClass(name = {
- "org.apache.ibatis.executor.Executor"
- })
- @EnableMyBatis
- static class MyBatisConfiguration {
- }
-}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
new file mode 100644
index 0000000..a4b350f
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
+import io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension;
+import io.microsphere.mybatis.spring.boot.autoconfigure.condition.ConditionalOnMyBatisAvailable;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.ENABLED_PROPERTY_NAME;
+
+
+/**
+ * The Auto-Configuration class of Sentinel x MyBatis
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration
+ * @see com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration
+ * @see io.microsphere.mybatis.spring.boot.autoconfigure.MyBatisAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnSentinelAvailable
+@ConditionalOnMyBatisAvailable
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
+@ConditionalOnClass(name = {
+ "io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension", // Microsphere MyBatis Spring
+ "io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter" // Microsphere Alibaba Sentinel x Mybatis
+})
+@AutoConfigureAfter(name = {
+ "com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration", // Spring Cloud Alibaba Sentinel
+ "org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration", // MyBatis Spring Boot
+ "com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration", // MyBatis Plus Spring Boot
+ "io.microsphere.mybatis.spring.boot.autoconfigure.MyBatisAutoConfiguration" // Microsphere Alibaba Sentinel Spring Boot x Mybatis
+})
+@Import(value = {
+ SentinelMyBatisAutoConfiguration.Config.class
+})
+public class SentinelMyBatisAutoConfiguration {
+
+ @EnableMyBatisExtension
+ static class Config {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SentinelMyBatisExecutorFilter sentinelMyBatisExecutorFilter() {
+ return new SentinelMyBatisExecutorFilter();
+ }
+ }
+}
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
new file mode 100644
index 0000000..60d72b4
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -0,0 +1,51 @@
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
+import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
+import io.microsphere.redis.spring.boot.autoconfigure.condition.ConditionalOnRedisAvailable;
+import io.microsphere.redis.spring.boot.autoconfigure.condition.ConditionalOnRedisInterceptorEnabled;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.ENABLED_PROPERTY_NAME;
+
+/**
+ * Microsphere Sentinel Spring Boot Auto-Configuration
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnSentinelAvailable
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
+@ConditionalOnClass(name = {
+ "io.microsphere.redis.spring.annotation.EnableRedisInterceptor", // Microsphere Redis Spring
+ "io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor" // Microsphere Alibaba Sentinel x Redis
+})
+@AutoConfigureAfter(name = {
+ "com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration", // Spring Cloud Alibaba Sentinel
+ "org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration", // Spring Boot Redis
+})
+@Import(value = {
+ SentinelRedisAutoConfiguration.Config.class,
+})
+public class SentinelRedisAutoConfiguration {
+
+ @ConditionalOnRedisAvailable
+ @ConditionalOnRedisInterceptorEnabled
+ @EnableRedisInterceptor
+ static class Config {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SentinelRedisCommandInterceptor sentinelRedisCommandInterceptor() {
+ return new SentinelRedisCommandInterceptor();
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
index 308d45c..ec6be93 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
@@ -16,7 +16,7 @@
*/
package io.microsphere.alibaba.sentinel.spring.boot.condition;
-import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration;
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import java.lang.annotation.Documented;
@@ -31,9 +31,9 @@
* Indicates that a component is eligible for registration when Alibaba Sentinel is available.
*
* This annotation combines {@link ConditionalOnSentinelEnabled @ConditionalOnSentinelEnabled} and
- * {@link ConditionalOnClass @ConditionalOnClass(name = "com.alibaba.csp.sentinel.SphU")},
- * meaning the annotated component will be registered only if Sentinel is explicitly enabled
- * and the Sentinel core classes are present on the classpath.
+ * {@link ConditionalOnClass @ConditionalOnClass(name = {"com.alibaba.csp.sentinel.SphU" ,
+ * "io.microsphere.alibaba.sentinel.common.SentinelPlugin"})}, meaning the annotated component will be registered
+ * only if Sentinel is explicitly enabled and the Sentinel core classes are present on the classpath.
*
*
* Usage Example
@@ -46,7 +46,7 @@
* }
*
* @author Mercy
- * @see SentinelAutoConfiguration
+ * @see SentinelRedisAutoConfiguration
* @since 1.0.0
*/
@Retention(RUNTIME)
@@ -54,7 +54,8 @@
@Documented
@ConditionalOnSentinelEnabled
@ConditionalOnClass(name = {
- "com.alibaba.csp.sentinel.SphU"
+ "com.alibaba.csp.sentinel.SphU",
+ "io.microsphere.alibaba.sentinel.common.SentinelPlugin"
})
public @interface ConditionalOnSentinelAvailable {
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
index 1034e66..2096c4b 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelEnabled.java
@@ -16,7 +16,7 @@
*/
package io.microsphere.alibaba.sentinel.spring.boot.condition;
-import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration;
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import java.lang.annotation.Documented;
@@ -32,7 +32,7 @@
* {@link ConditionalOnProperty} based annotation for Alibaba Sentinel enabled property.
*
* @author Mercy
- * @see SentinelAutoConfiguration
+ * @see SentinelRedisAutoConfiguration
* @since 1.0.0
*/
@Retention(RUNTIME)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
index 0ede9fd..8b5bc27 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -1,2 +1,4 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration,\
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration,\
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 8344d3f..c845f5d 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1 +1,3 @@
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
index 90a84c1..1ea1ef3 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
@@ -45,10 +45,12 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
- * {@link SentinelAutoConfiguration} Test
+ * SentinelAutoConfiguration Test
*
* @author Mercy
- * @see SentinelAutoConfiguration
+ * @see SentinelAlibabaDruidAutoConfiguration
+ * @see SentinelMyBatisAutoConfiguration
+ * @see SentinelRedisAutoConfiguration
* @since 1.0.0
*/
@SpringJUnitConfig(classes = {
From 6b6b34ac802b61fd6a58b4a93e724ee6075f2f97 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 13:42:10 +0800
Subject: [PATCH 17/42] Add RedisAutoConfiguration Javadoc reference
Update SentinelRedisAutoConfiguration class documentation to include a @see link to Spring Boot's RedisAutoConfiguration, clarifying the related auto-configuration dependency context.
---
.../boot/autoconfigure/SentinelRedisAutoConfiguration.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
index 60d72b4..2b6dc43 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -19,6 +19,7 @@
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
* @since 1.0.0
*/
@ConditionalOnSentinelAvailable
From 5a9757447f3b8ea7b5e51dccd0a91e78455ba588 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 14:28:03 +0800
Subject: [PATCH 18/42] Add Sentinel web auto-configuration support
Introduce `SentinelWebAutoConfiguration` to auto-register `SentinelHandlerMethodInterceptor` for web applications when Sentinel is enabled and required classes are present. Register the new auto-configuration in both `spring.factories` and `AutoConfiguration.imports`, and update tests to use `@SpringBootTest` with a web environment so web auto-config can be loaded. The module POM now includes the Spring Boot web/testing and Microsphere web MVC/WebFlux test dependencies needed for this coverage.
---
.../pom.xml | 36 +++++++++++++++
.../SentinelWebAutoConfiguration.java | 45 +++++++++++++++++++
.../main/resources/META-INF/spring.factories | 3 +-
...ot.autoconfigure.AutoConfiguration.imports | 3 +-
.../SentinelAutoConfigurationTest.java | 34 +++++++-------
5 files changed, 104 insertions(+), 17 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java
diff --git a/microsphere-alibaba-sentinel-spring-boot/pom.xml b/microsphere-alibaba-sentinel-spring-boot/pom.xml
index 5a5c163..a89ac32 100644
--- a/microsphere-alibaba-sentinel-spring-boot/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-boot/pom.xml
@@ -179,12 +179,34 @@
true
+
org.springframework
spring-test
test
+
+
+ org.springframework.boot
+ spring-boot-test
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+ true
+
+
io.github.microsphere-projects
@@ -220,6 +242,20 @@
test
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webmvc
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webflux
+ test
+
+
com.h2database
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java
new file mode 100644
index 0000000..7896265
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java
@@ -0,0 +1,45 @@
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
+import io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
+import org.springframework.context.annotation.Bean;
+
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.ENABLED_PROPERTY_NAME;
+import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type.ANY;
+
+/**
+ * Microsphere Sentinel Spring Boot Auto-Configuration
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration
+ * @see io.microsphere.spring.boot.webmvc.autoconfigure.WebMvcAutoConfiguration
+ * @see org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration
+ * @see io.microsphere.spring.boot.webflux.autoconfigure.WebFluxAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnWebApplication(type = ANY)
+@ConditionalOnSentinelAvailable
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
+@ConditionalOnClass(name = {
+ "io.microsphere.spring.web.method.support.HandlerMethodInterceptor", // Microsphere Spring Web
+ "io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor" // Microsphere Alibaba Sentinel x Spring Web
+})
+@AutoConfigureAfter(name = {
+ "com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration", // Spring Cloud Alibaba Sentinel
+ "io.microsphere.spring.boot.webmvc.autoconfigure.WebMvcAutoConfiguration", // Microsphere Spring Boot WebMVC
+ "io.microsphere.spring.boot.webflux.autoconfigure.WebFluxAutoConfiguration" // Microsphere Spring Boot WebFlux
+})
+public class SentinelWebAutoConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SentinelHandlerMethodInterceptor sentinelHandlerMethodInterceptor() {
+ return new SentinelHandlerMethodInterceptor();
+ }
+}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
index 8b5bc27..a242dc9 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -1,4 +1,5 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration,\
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration,\
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration,\
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelWebAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index c845f5d..006e4bf 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,3 +1,4 @@
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelWebAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
index 1ea1ef3..f4ccfd8 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
@@ -30,11 +30,10 @@
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
-import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import java.io.IOException;
@@ -43,6 +42,7 @@
import static io.microsphere.mybatis.test.AbstractMapperTest.assertUserMapper;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
/**
* SentinelAutoConfiguration Test
@@ -53,16 +53,17 @@
* @see SentinelRedisAutoConfiguration
* @since 1.0.0
*/
-@SpringJUnitConfig(classes = {
+@SpringBootTest(classes = {
MyBatisDataBaseTestConfiguration.class,
RedisConfig.class,
- SentinelAutoConfigurationTest.class
-})
-@TestPropertySource(properties = {
- "microsphere.redis.enabled=true",
- "spring.application.name=test-app",
- "mybatis.configLocation=META-INF/mybatis/config.xml"
-})
+ SentinelAutoConfigurationTest.TestConfig.class
+},
+ webEnvironment = RANDOM_PORT,
+ properties = {
+ "microsphere.redis.enabled=true",
+ "spring.application.name=test-app",
+ "mybatis.configLocation=classpath:/META-INF/mybatis/config.xml"
+ })
@EnableAutoConfiguration
class SentinelAutoConfigurationTest {
@@ -78,11 +79,6 @@ class SentinelAutoConfigurationTest {
@Autowired
private SqlSessionFactory sessionFactory;
- @Bean(initMethod = "init", destroyMethod = "close")
- public DruidDataSource dataSource() throws IOException {
- return buildDefaultDruidDataSource();
- }
-
@Test
void test() {
testAlibabaDruidAndMyBatisPlugin();
@@ -112,4 +108,12 @@ void testRedisPlugin() {
Context context = enter("microsphere_sentinel_redis_context", "RedisConnection");
assertNotNull(context);
}
+
+ static class TestConfig {
+
+ @Bean(initMethod = "init", destroyMethod = "close")
+ public DruidDataSource dataSource() throws IOException {
+ return buildDefaultDruidDataSource();
+ }
+ }
}
\ No newline at end of file
From bb43caf41e684e5bb6662240c34bb22aae61e41d Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:16:26 +0800
Subject: [PATCH 19/42] Add Druid auto-config condition tests
Introduce `SentinelAlibabaDruidAutoConfigurationTest` to validate default bean creation and negative conditions for disabled properties and missing classes. Also add `assertj-core` as a test-scoped dependency in the Spring Boot module to support fluent assertions used by the new tests.
---
.../pom.xml | 7 ++
...inelAlibabaDruidAutoConfigurationTest.java | 97 +++++++++++++++++++
2 files changed, 104 insertions(+)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-spring-boot/pom.xml b/microsphere-alibaba-sentinel-spring-boot/pom.xml
index a89ac32..89ef900 100644
--- a/microsphere-alibaba-sentinel-spring-boot/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-boot/pom.xml
@@ -179,6 +179,13 @@
true
+
+
+ org.assertj
+ assertj-core
+ test
+
+
org.springframework
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
new file mode 100644
index 0000000..cc1e14a
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+
+import io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter;
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration.Config;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.FilteredClassLoader;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.boot.autoconfigure.AutoConfigurations.of;
+
+/**
+ * {@link SentinelAlibabaDruidAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelAlibabaDruidAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelAlibabaDruidAutoConfigurationTest {
+
+ ApplicationContextRunner applicationContextRunner;
+
+ @BeforeEach
+ void setUp() {
+ this.applicationContextRunner = new ApplicationContextRunner()
+ .withConfiguration(of(SentinelAlibabaDruidAutoConfiguration.class));
+ }
+
+ @Test
+ void testDefaults() {
+ this.applicationContextRunner.run(context -> {
+ assertThat(context).hasSingleBean(SentinelAlibabaDruidAutoConfiguration.class)
+ .hasSingleBean(SentinelAlibabaDruidFilter.class);
+ });
+ }
+
+ @Test
+ void tesOntDisabledProperty() {
+ assertDisabledProperty("microsphere.sentinel.enabled=false",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertDisabledProperty("microsphere.sentinel.alibaba-druid.enabled=false",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertDisabledProperty("microsphere.alibaba.druid.enabled=false",
+ Config.class, SentinelAlibabaDruidFilter.class);
+ }
+
+ @Test
+ void testOnMissingClass() {
+ assertFilteredClass("com.alibaba.csp.sentinel.SphU",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertFilteredClass("io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter",
+ SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ assertFilteredClass("com.alibaba.druid.pool.DruidDataSource",
+ Config.class, SentinelAlibabaDruidFilter.class);
+ }
+
+ void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
+ this.applicationContextRunner.withPropertyValues(propertyValue)
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+
+ void assertFilteredClass(String filteredClass, Class>... beanClasses) {
+ this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+}
\ No newline at end of file
From c57b0556412ca461fab4fb1bcf7d509ca148099f Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:33:50 +0800
Subject: [PATCH 20/42] Add MyBatis auto-config tests and base test class
Introduce a reusable `AutoConfigurationTest` base class for Spring Boot auto-configuration tests, including shared setup and helper assertions for disabled properties and missing classes. Refactor the Druid auto-configuration test to extend this base and also assert the nested `Config` bean by default. Add a new `SentinelMyBatisAutoConfigurationTest` covering default bean registration, property-based disablement, and classpath-conditional behavior.
---
.../autoconfigure/AutoConfigurationTest.java | 70 +++++++++++++++
...inelAlibabaDruidAutoConfigurationTest.java | 32 +------
.../SentinelMyBatisAutoConfigurationTest.java | 87 +++++++++++++++++++
3 files changed, 159 insertions(+), 30 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
new file mode 100644
index 0000000..41ac400
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.springframework.boot.test.context.FilteredClassLoader;
+import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.springframework.boot.autoconfigure.AutoConfigurations.of;
+import static org.springframework.core.ResolvableType.forClass;
+
+/**
+ * Abstract class for auto-configuration tests
+ *
+ * @param the type of auto-configuration class
+ * @author Mercy
+ * @see ApplicationContextRunner
+ * @since 1.0.0
+ */
+abstract class AutoConfigurationTest {
+
+ ApplicationContextRunner applicationContextRunner;
+
+ final Class autoConfigurationClass;
+
+ AutoConfigurationTest() {
+ this.autoConfigurationClass = (Class) forClass(getClass())
+ .as(AutoConfigurationTest.class).resolveGeneric(0);
+ }
+
+ @BeforeEach
+ void setUp() {
+ this.applicationContextRunner = new ApplicationContextRunner()
+ .withConfiguration(of(autoConfigurationClass));
+ }
+
+ void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
+ this.applicationContextRunner.withPropertyValues(propertyValue)
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+
+ void assertFilteredClass(String filteredClass, Class>... beanClasses) {
+ this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+}
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
index cc1e14a..acb25a5 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
@@ -20,13 +20,9 @@
import io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration.Config;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.FilteredClassLoader;
-import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.springframework.boot.autoconfigure.AutoConfigurations.of;
/**
* {@link SentinelAlibabaDruidAutoConfiguration} Test
@@ -35,20 +31,13 @@
* @see SentinelAlibabaDruidAutoConfiguration
* @since 1.0.0
*/
-class SentinelAlibabaDruidAutoConfigurationTest {
-
- ApplicationContextRunner applicationContextRunner;
-
- @BeforeEach
- void setUp() {
- this.applicationContextRunner = new ApplicationContextRunner()
- .withConfiguration(of(SentinelAlibabaDruidAutoConfiguration.class));
- }
+class SentinelAlibabaDruidAutoConfigurationTest extends AutoConfigurationTest {
@Test
void testDefaults() {
this.applicationContextRunner.run(context -> {
assertThat(context).hasSingleBean(SentinelAlibabaDruidAutoConfiguration.class)
+ .hasSingleBean(Config.class)
.hasSingleBean(SentinelAlibabaDruidFilter.class);
});
}
@@ -77,21 +66,4 @@ void testOnMissingClass() {
Config.class, SentinelAlibabaDruidFilter.class);
}
- void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
- this.applicationContextRunner.withPropertyValues(propertyValue)
- .run(context -> {
- for (Class> beanClass : beanClasses) {
- assertThat(context).doesNotHaveBean(beanClass);
- }
- });
- }
-
- void assertFilteredClass(String filteredClass, Class>... beanClasses) {
- this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
- .run(context -> {
- for (Class> beanClass : beanClasses) {
- assertThat(context).doesNotHaveBean(beanClass);
- }
- });
- }
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
new file mode 100644
index 0000000..8d81c3d
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+
+import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration.Config;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.FilteredClassLoader;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * {@link SentinelMyBatisAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelMyBatisAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelMyBatisAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Test
+ void testDefaults() {
+ this.applicationContextRunner.run(context -> {
+ assertThat(context).hasSingleBean(SentinelMyBatisAutoConfiguration.class)
+ .hasSingleBean(Config.class)
+ .hasSingleBean(SentinelMyBatisExecutorFilter.class);
+ });
+ }
+
+ @Test
+ void tesOntDisabledProperty() {
+ assertDisabledProperty("microsphere.sentinel.enabled=false",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertDisabledProperty("microsphere.mybatis.enabled=false",
+ Config.class, SentinelMyBatisExecutorFilter.class);
+ assertDisabledProperty("microsphere.sentinel.mybatis.enabled=false",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ }
+
+ @Test
+ void testOnMissingClass() {
+ assertFilteredClass("com.alibaba.csp.sentinel.SphU",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertFilteredClass("org.apache.ibatis.session.SqlSessionFactory",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertFilteredClass("io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter",
+ SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ }
+
+ void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
+ this.applicationContextRunner.withPropertyValues(propertyValue)
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+
+ void assertFilteredClass(String filteredClass, Class>... beanClasses) {
+ this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
+ }
+}
\ No newline at end of file
From aa061866249003ac70afad14522f8381110b9631 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:34:19 +0800
Subject: [PATCH 21/42] Clarify MyBatis plugin enable property docs
Update the JavaDoc for `SENTINEL_MYBATIS_ENABLED_PROPERTY_NAME` to explicitly include the full configuration key (`microsphere.sentinel.mybatis.enabled`), making the plugin enablement property easier to identify.
---
.../alibaba/sentinel/mybatis/SentinelMyBatisConstants.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
index ea84256..e487daf 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/main/java/io/microsphere/alibaba/sentinel/mybatis/SentinelMyBatisConstants.java
@@ -49,7 +49,7 @@ public interface SentinelMyBatisConstants {
String DEFAULT_ORIGIN = "Executor";
/**
- * The property name of the plugin of Sentinel x MyBatis enabled
+ * The property name of the plugin of Sentinel x MyBatis enabled : "microsphere.sentinel.mybatis.enabled"
*/
@ConfigurationProperty(
type = boolean.class,
From b839a7dcb266da3c79e6c2b6b2b514d9594de55f Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:36:40 +0800
Subject: [PATCH 22/42] Remove redundant MyBatis test helpers
Clean up `SentinelMyBatisAutoConfigurationTest` by deleting locally duplicated helper methods for disabled-property and filtered-class assertions. The test now relies on shared support from the base test infrastructure, and the now-unused `FilteredClassLoader` import is removed.
---
.../SentinelMyBatisAutoConfigurationTest.java | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
index 8d81c3d..31d7979 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
@@ -21,7 +21,6 @@
import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration.Config;
import org.junit.jupiter.api.Test;
-import org.springframework.boot.test.context.FilteredClassLoader;
import static org.assertj.core.api.Assertions.assertThat;
@@ -66,22 +65,4 @@ void testOnMissingClass() {
assertFilteredClass("io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter",
SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
}
-
- void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
- this.applicationContextRunner.withPropertyValues(propertyValue)
- .run(context -> {
- for (Class> beanClass : beanClasses) {
- assertThat(context).doesNotHaveBean(beanClass);
- }
- });
- }
-
- void assertFilteredClass(String filteredClass, Class>... beanClasses) {
- this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
- .run(context -> {
- for (Class> beanClass : beanClasses) {
- assertThat(context).doesNotHaveBean(beanClass);
- }
- });
- }
}
\ No newline at end of file
From bc518e397a86f64c120f2ed679bb0372dc1f9388 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:39:26 +0800
Subject: [PATCH 23/42] Use base autoConfig class in auto-config tests
Updated the Druid and MyBatis Spring Boot auto-configuration tests to reference `this.autoConfigurationClass` instead of hardcoding concrete auto-configuration classes in assertions. This keeps the tests aligned with the shared `AutoConfigurationTest` base contract and reduces duplication when validating disabled properties and missing-class conditions.
---
...entinelAlibabaDruidAutoConfigurationTest.java | 14 +++++++-------
.../SentinelMyBatisAutoConfigurationTest.java | 16 ++++++++--------
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
index acb25a5..1778aa3 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
@@ -36,7 +36,7 @@ class SentinelAlibabaDruidAutoConfigurationTest extends AutoConfigurationTest {
- assertThat(context).hasSingleBean(SentinelAlibabaDruidAutoConfiguration.class)
+ assertThat(context).hasSingleBean(this.autoConfigurationClass)
.hasSingleBean(Config.class)
.hasSingleBean(SentinelAlibabaDruidFilter.class);
});
@@ -45,9 +45,9 @@ void testDefaults() {
@Test
void tesOntDisabledProperty() {
assertDisabledProperty("microsphere.sentinel.enabled=false",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertDisabledProperty("microsphere.sentinel.alibaba-druid.enabled=false",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertDisabledProperty("microsphere.alibaba.druid.enabled=false",
Config.class, SentinelAlibabaDruidFilter.class);
}
@@ -55,13 +55,13 @@ void tesOntDisabledProperty() {
@Test
void testOnMissingClass() {
assertFilteredClass("com.alibaba.csp.sentinel.SphU",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertFilteredClass("io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertFilteredClass("io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter",
- SentinelAlibabaDruidAutoConfiguration.class, Config.class, SentinelAlibabaDruidFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertFilteredClass("com.alibaba.druid.pool.DruidDataSource",
Config.class, SentinelAlibabaDruidFilter.class);
}
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
index 31d7979..e9b8ddd 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
@@ -36,7 +36,7 @@ class SentinelMyBatisAutoConfigurationTest extends AutoConfigurationTest {
- assertThat(context).hasSingleBean(SentinelMyBatisAutoConfiguration.class)
+ assertThat(context).hasSingleBean(this.autoConfigurationClass)
.hasSingleBean(Config.class)
.hasSingleBean(SentinelMyBatisExecutorFilter.class);
});
@@ -45,24 +45,24 @@ void testDefaults() {
@Test
void tesOntDisabledProperty() {
assertDisabledProperty("microsphere.sentinel.enabled=false",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
assertDisabledProperty("microsphere.mybatis.enabled=false",
Config.class, SentinelMyBatisExecutorFilter.class);
assertDisabledProperty("microsphere.sentinel.mybatis.enabled=false",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
}
@Test
void testOnMissingClass() {
assertFilteredClass("com.alibaba.csp.sentinel.SphU",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
assertFilteredClass("org.apache.ibatis.session.SqlSessionFactory",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
assertFilteredClass("io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
assertFilteredClass("io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter",
- SentinelMyBatisAutoConfiguration.class, Config.class, SentinelMyBatisExecutorFilter.class);
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
}
}
\ No newline at end of file
From 733ecc81abbd843c071ad953fedd651160bcb2d0 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:40:23 +0800
Subject: [PATCH 24/42] Clarify Redis enabled property JavaDoc
Update `SentinelRedisConstants` JavaDoc to explicitly include the full property key (`microsphere.sentinel.redis.enabled`) for the Redis plugin enabled flag, improving discoverability and configuration clarity.
---
.../alibaba/sentinel/redis/SentinelRedisConstants.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
index 3f7d3f2..17bc442 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/main/java/io/microsphere/alibaba/sentinel/redis/SentinelRedisConstants.java
@@ -50,7 +50,7 @@ public interface SentinelRedisConstants {
String DEFAULT_ORIGIN = "RedisConnection";
/**
- * The property name of the plugin of Sentinel x Redis enabled
+ * The property name of the plugin of Sentinel x Redis enabled : "microsphere.sentinel.redis.enabled"
*/
@ConfigurationProperty(
type = boolean.class,
From efbca3623924135cf55ff2e325e468de1fdd8455 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 17:49:16 +0800
Subject: [PATCH 25/42] Scope Redis availability to auto-config class
Move `@ConditionalOnRedisAvailable` from the nested `Config` class to `SentinelRedisAutoConfiguration` so the entire auto-configuration is gated when Redis is unavailable. This prevents loading the auto-config container when Redis conditions are not met.
---
.../boot/autoconfigure/SentinelRedisAutoConfiguration.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
index 2b6dc43..417d51d 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -23,6 +23,7 @@
* @since 1.0.0
*/
@ConditionalOnSentinelAvailable
+@ConditionalOnRedisAvailable
@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
@ConditionalOnClass(name = {
"io.microsphere.redis.spring.annotation.EnableRedisInterceptor", // Microsphere Redis Spring
@@ -37,7 +38,6 @@
})
public class SentinelRedisAutoConfiguration {
- @ConditionalOnRedisAvailable
@ConditionalOnRedisInterceptorEnabled
@EnableRedisInterceptor
static class Config {
From b43e3d17264b58f9e7fd4802aa697d0149c06843 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 18:59:14 +0800
Subject: [PATCH 26/42] Decouple Redis auto-config from interceptor enable
Removes the direct `@EnableRedisInterceptor` annotation and class-condition dependency from `SentinelRedisAutoConfiguration`, so activation relies on existing conditional checks instead of explicit interceptor enabling. Adds `SentinelRedisAutoConfigurationTest` to cover default bean registration, disabling properties, and missing-class scenarios for Redis Sentinel auto-configuration.
---
.../SentinelRedisAutoConfiguration.java | 4 -
.../SentinelRedisAutoConfigurationTest.java | 75 +++++++++++++++++++
2 files changed, 75 insertions(+), 4 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
index 417d51d..7bdf156 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -2,7 +2,6 @@
import io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor;
import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
-import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import io.microsphere.redis.spring.boot.autoconfigure.condition.ConditionalOnRedisAvailable;
import io.microsphere.redis.spring.boot.autoconfigure.condition.ConditionalOnRedisInterceptorEnabled;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
@@ -26,7 +25,6 @@
@ConditionalOnRedisAvailable
@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
@ConditionalOnClass(name = {
- "io.microsphere.redis.spring.annotation.EnableRedisInterceptor", // Microsphere Redis Spring
"io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor" // Microsphere Alibaba Sentinel x Redis
})
@AutoConfigureAfter(name = {
@@ -39,7 +37,6 @@
public class SentinelRedisAutoConfiguration {
@ConditionalOnRedisInterceptorEnabled
- @EnableRedisInterceptor
static class Config {
@Bean
@@ -48,5 +45,4 @@ public SentinelRedisCommandInterceptor sentinelRedisCommandInterceptor() {
return new SentinelRedisCommandInterceptor();
}
}
-
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
new file mode 100644
index 0000000..1ddab4d
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+
+import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
+import io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor;
+import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration.Config;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * {@link SentinelRedisAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelRedisAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelRedisAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Test
+ void testDefaults() {
+ this.applicationContextRunner.run(context -> {
+ assertThat(context).hasSingleBean(this.autoConfigurationClass)
+ .hasSingleBean(Config.class)
+ .hasSingleBean(SentinelRedisCommandInterceptor.class);
+ });
+ }
+
+ @Test
+ void tesOntDisabledProperty() {
+ assertDisabledProperty("microsphere.sentinel.enabled=false",
+ this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
+ assertDisabledProperty("microsphere.redis.enabled=false",
+ Config.class, SentinelRedisCommandInterceptor.class);
+ assertDisabledProperty("microsphere.sentinel.redis.enabled=false",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertDisabledProperty("microsphere.redis.interceptor.enabled=false",
+ Config.class, SentinelRedisCommandInterceptor.class);
+ }
+
+ @Test
+ void testOnMissingClass() {
+ assertFilteredClass("com.alibaba.csp.sentinel.SphU",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("org.springframework.data.redis.connection.RedisConnection",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("io.microsphere.redis.metadata.RedisMetadataLoader",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("io.microsphere.redis.spring.interceptor.RedisMethodInterceptor",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("io.microsphere.redis.spring.annotation.EnableRedisInterceptor",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ assertFilteredClass("io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor",
+ this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ }
+}
\ No newline at end of file
From 9dbbee2503b1749d21351c20c118656ca03ac6bb Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 20:31:00 +0800
Subject: [PATCH 27/42] Rename Spring Web auto-config and tighten tests
Renames `SentinelWebAutoConfiguration` to `SentinelSpringWebAutoConfiguration`, fixes it to use the Spring Web enable property, and adds a Spring Web class guard so it only activates in valid web contexts. Updates both auto-configuration registration files and introduces a dedicated `SentinelSpringWebAutoConfigurationTest`.
Refactors the shared auto-configuration test base to cover both regular and web application contexts with common global disabled-property and missing-class assertions, then adapts the Druid/MyBatis/Redis tests to the new extension points. Minor constant/autoconfiguration Javadoc text was also clarified.
---
.../druid/SentinelAlibabaDruidConstants.java | 2 +-
.../web/SentinelSpringWebConstants.java | 2 +-
...SentinelAlibabaDruidAutoConfiguration.java | 2 +-
.../SentinelMyBatisAutoConfiguration.java | 2 +-
.../SentinelRedisAutoConfiguration.java | 2 +-
...> SentinelSpringWebAutoConfiguration.java} | 12 +--
.../main/resources/META-INF/spring.factories | 2 +-
...ot.autoconfigure.AutoConfiguration.imports | 2 +-
.../autoconfigure/AutoConfigurationTest.java | 83 +++++++++++++++++++
...inelAlibabaDruidAutoConfigurationTest.java | 42 +++++-----
.../SentinelMyBatisAutoConfigurationTest.java | 45 ++++------
.../SentinelRedisAutoConfigurationTest.java | 55 +++++-------
...entinelSpringWebAutoConfigurationTest.java | 68 +++++++++++++++
13 files changed, 222 insertions(+), 97 deletions(-)
rename microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/{SentinelWebAutoConfiguration.java => SentinelSpringWebAutoConfiguration.java} (82%)
create mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
index 513cc3c..fa73e3d 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidConstants.java
@@ -49,7 +49,7 @@ public interface SentinelAlibabaDruidConstants {
String DEFAULT_ORIGIN = "Filter";
/**
- * The property name of the plugin of Sentinel x Alibaba Druid enabled
+ * The property name of the plugin of Sentinel x Alibaba Druid enabled : "microsphere.sentinel.alibaba-druid.enabled"
*/
@ConfigurationProperty(
type = boolean.class,
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
index 55414f5..a8f0e30 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/main/java/io/microsphere/alibaba/sentinel/spring/web/SentinelSpringWebConstants.java
@@ -50,7 +50,7 @@ public interface SentinelSpringWebConstants {
String DEFAULT_ORIGIN = "HandlerMethod";
/**
- * The property name of the plugin of Sentinel x Spring Web enabled
+ * The property name of the plugin of Sentinel x Spring Web enabled : "microsphere.sentinel.spring-web.enabled"
*/
@ConfigurationProperty(
type = boolean.class,
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
index 5e565e4..9fd0cb2 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
@@ -30,7 +30,7 @@
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.ENABLED_PROPERTY_NAME;
/**
- * The Auto-Configuration class of Sentinel x Alibaba Druid
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Alibaba Druid
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
index a4b350f..f9c5ee2 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
@@ -32,7 +32,7 @@
/**
- * The Auto-Configuration class of Sentinel x MyBatis
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x MyBatis
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
index 7bdf156..62357b7 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -14,7 +14,7 @@
import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.ENABLED_PROPERTY_NAME;
/**
- * Microsphere Sentinel Spring Boot Auto-Configuration
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Redis
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfiguration.java
similarity index 82%
rename from microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java
rename to microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfiguration.java
index 7896265..8c59be5 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelWebAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfiguration.java
@@ -9,11 +9,12 @@
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
-import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.ENABLED_PROPERTY_NAME;
+
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.ENABLED_PROPERTY_NAME;
import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type.ANY;
/**
- * Microsphere Sentinel Spring Boot Auto-Configuration
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Spring Web
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
@@ -27,15 +28,16 @@
@ConditionalOnSentinelAvailable
@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
@ConditionalOnClass(name = {
- "io.microsphere.spring.web.method.support.HandlerMethodInterceptor", // Microsphere Spring Web
- "io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor" // Microsphere Alibaba Sentinel x Spring Web
+ "org.springframework.web.method.HandlerMethod", // Spring Web
+ "io.microsphere.spring.web.method.support.HandlerMethodInterceptor", // Microsphere Spring Web
+ "io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor" // Microsphere Alibaba Sentinel x Spring Web
})
@AutoConfigureAfter(name = {
"com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration", // Spring Cloud Alibaba Sentinel
"io.microsphere.spring.boot.webmvc.autoconfigure.WebMvcAutoConfiguration", // Microsphere Spring Boot WebMVC
"io.microsphere.spring.boot.webflux.autoconfigure.WebFluxAutoConfiguration" // Microsphere Spring Boot WebFlux
})
-public class SentinelWebAutoConfiguration {
+public class SentinelSpringWebAutoConfiguration {
@Bean
@ConditionalOnMissingBean
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
index a242dc9..cbc2b17 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -2,4 +2,4 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration,\
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration,\
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration,\
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelWebAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelSpringWebAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 006e4bf..36775aa 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,4 +1,4 @@
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration
io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
-io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelWebAutoConfiguration
\ No newline at end of file
+io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelSpringWebAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
index 41ac400..8ce5a32 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
@@ -17,10 +17,18 @@
package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+import com.alibaba.csp.sentinel.SphU;
+import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
+import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
+import java.util.Set;
+
+import static io.microsphere.collection.SetUtils.newLinkedHashSet;
+import static io.microsphere.util.ArrayUtils.EMPTY_CLASS_ARRAY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.boot.autoconfigure.AutoConfigurations.of;
import static org.springframework.core.ResolvableType.forClass;
@@ -37,6 +45,8 @@ abstract class AutoConfigurationTest {
ApplicationContextRunner applicationContextRunner;
+ WebApplicationContextRunner webApplicationContextRunner;
+
final Class autoConfigurationClass;
AutoConfigurationTest() {
@@ -48,8 +58,67 @@ abstract class AutoConfigurationTest {
void setUp() {
this.applicationContextRunner = new ApplicationContextRunner()
.withConfiguration(of(autoConfigurationClass));
+ this.webApplicationContextRunner = new WebApplicationContextRunner()
+ .withConfiguration(of(this.autoConfigurationClass));
+ }
+
+ @Test
+ void testAutoConfiguredClasses() {
+ this.applicationContextRunner.run(context -> {
+ for (Class> beanClass : getAutoConfiguredClasses()) {
+ assertThat(context).hasSingleBean(beanClass);
+ }
+ });
+
+ this.webApplicationContextRunner.run(context -> {
+ for (Class> beanClass : getAutoConfiguredClasses()) {
+ assertThat(context).hasSingleBean(beanClass);
+ }
+ });
+ }
+
+ @Test
+ void testOnGlobalDisabledProperty() {
+ for (String propertyValue : getGlobalDisabledPropertyValues()) {
+ assertDisabledProperty(propertyValue, getAutoConfiguredClasses());
+ }
+ }
+
+ @Test
+ void testOnGlobalMissingClass() {
+ for (Class> missingClass : getGlobalMissingClasses()) {
+ assertFilteredClass(missingClass.getName(), getAutoConfiguredClasses());
+ }
+ }
+
+ protected final Class>[] getAutoConfiguredClasses() {
+ Set> autoConfiguredClasses = newLinkedHashSet();
+ autoConfiguredClasses.add(this.autoConfigurationClass);
+ configureAutoConfiguredClasses(autoConfiguredClasses);
+ return autoConfiguredClasses.toArray(EMPTY_CLASS_ARRAY);
+ }
+
+ protected final Set getGlobalDisabledPropertyValues() {
+ Set globalDisabledPropertyValues = newLinkedHashSet();
+ globalDisabledPropertyValues.add("microsphere.sentinel.enabled=false");
+ configureGlobalDisabledPropertyValues(globalDisabledPropertyValues);
+ return globalDisabledPropertyValues;
+ }
+
+ protected final Set> getGlobalMissingClasses() {
+ Set> globalMissingClasses = newLinkedHashSet();
+ globalMissingClasses.add(SphU.class);
+ globalMissingClasses.add(SentinelPlugin.class);
+ configureGlobalMissingClasses(globalMissingClasses);
+ return globalMissingClasses;
}
+ protected abstract void configureAutoConfiguredClasses(Set> autoConfiguredClasses);
+
+ protected abstract void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues);
+
+ protected abstract void configureGlobalMissingClasses(Set> globalMissingClasses);
+
void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
this.applicationContextRunner.withPropertyValues(propertyValue)
.run(context -> {
@@ -57,6 +126,13 @@ void assertDisabledProperty(String propertyValue, Class>... beanClasses) {
assertThat(context).doesNotHaveBean(beanClass);
}
});
+
+ this.webApplicationContextRunner.withPropertyValues(propertyValue)
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
}
void assertFilteredClass(String filteredClass, Class>... beanClasses) {
@@ -66,5 +142,12 @@ void assertFilteredClass(String filteredClass, Class>... beanClasses) {
assertThat(context).doesNotHaveBean(beanClass);
}
});
+
+ this.webApplicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
+ .run(context -> {
+ for (Class> beanClass : beanClasses) {
+ assertThat(context).doesNotHaveBean(beanClass);
+ }
+ });
}
}
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
index 1778aa3..61f28b1 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
@@ -18,11 +18,12 @@
package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+import io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable;
import io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration.Config;
import org.junit.jupiter.api.Test;
-import static org.assertj.core.api.Assertions.assertThat;
+import java.util.Set;
/**
* {@link SentinelAlibabaDruidAutoConfiguration} Test
@@ -34,36 +35,31 @@
class SentinelAlibabaDruidAutoConfigurationTest extends AutoConfigurationTest {
@Test
- void testDefaults() {
- this.applicationContextRunner.run(context -> {
- assertThat(context).hasSingleBean(this.autoConfigurationClass)
- .hasSingleBean(Config.class)
- .hasSingleBean(SentinelAlibabaDruidFilter.class);
- });
- }
-
- @Test
- void tesOntDisabledProperty() {
- assertDisabledProperty("microsphere.sentinel.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
- assertDisabledProperty("microsphere.sentinel.alibaba-druid.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
+ void tesOnDisabledProperty() {
assertDisabledProperty("microsphere.alibaba.druid.enabled=false",
Config.class, SentinelAlibabaDruidFilter.class);
}
@Test
void testOnMissingClass() {
- assertFilteredClass("com.alibaba.csp.sentinel.SphU",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
- assertFilteredClass("io.microsphere.alibaba.druid.spring.boot.condition.ConditionalOnAlibabaDruidAvailable",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidFilter",
- this.autoConfigurationClass, Config.class, SentinelAlibabaDruidFilter.class);
assertFilteredClass("com.alibaba.druid.pool.DruidDataSource",
Config.class, SentinelAlibabaDruidFilter.class);
}
+ @Override
+ protected void configureAutoConfiguredClasses(Set> autoConfiguredClasses) {
+ autoConfiguredClasses.add(Config.class);
+ autoConfiguredClasses.add(SentinelAlibabaDruidFilter.class);
+ }
+
+ @Override
+ protected void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues) {
+ globalDisabledPropertyValues.add("microsphere.sentinel.alibaba-druid.enabled=false");
+ }
+
+ @Override
+ protected void configureGlobalMissingClasses(Set> globalMissingClasses) {
+ globalMissingClasses.add(ConditionalOnAlibabaDruidAvailable.class);
+ globalMissingClasses.add(SentinelAlibabaDruidFilter.class);
+ }
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
index e9b8ddd..d8f1348 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
@@ -20,9 +20,10 @@
import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration.Config;
-import org.junit.jupiter.api.Test;
+import io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension;
+import org.apache.ibatis.session.SqlSessionFactory;
-import static org.assertj.core.api.Assertions.assertThat;
+import java.util.Set;
/**
* {@link SentinelMyBatisAutoConfiguration} Test
@@ -33,36 +34,22 @@
*/
class SentinelMyBatisAutoConfigurationTest extends AutoConfigurationTest {
- @Test
- void testDefaults() {
- this.applicationContextRunner.run(context -> {
- assertThat(context).hasSingleBean(this.autoConfigurationClass)
- .hasSingleBean(Config.class)
- .hasSingleBean(SentinelMyBatisExecutorFilter.class);
- });
+ @Override
+ protected void configureAutoConfiguredClasses(Set> autoConfiguredClasses) {
+ autoConfiguredClasses.add(Config.class);
+ autoConfiguredClasses.add(SentinelMyBatisExecutorFilter.class);
}
- @Test
- void tesOntDisabledProperty() {
- assertDisabledProperty("microsphere.sentinel.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertDisabledProperty("microsphere.mybatis.enabled=false",
- Config.class, SentinelMyBatisExecutorFilter.class);
- assertDisabledProperty("microsphere.sentinel.mybatis.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
+ @Override
+ protected void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues) {
+ globalDisabledPropertyValues.add("microsphere.mybatis.enabled=false");
+ globalDisabledPropertyValues.add("microsphere.sentinel.mybatis.enabled=false");
}
- @Test
- void testOnMissingClass() {
- assertFilteredClass("com.alibaba.csp.sentinel.SphU",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertFilteredClass("org.apache.ibatis.session.SqlSessionFactory",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertFilteredClass("io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
+ @Override
+ protected void configureGlobalMissingClasses(Set> globalMissingClasses) {
+ globalMissingClasses.add(SqlSessionFactory.class);
+ globalMissingClasses.add(EnableMyBatisExtension.class);
+ globalMissingClasses.add(SentinelMyBatisExecutorFilter.class);
}
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
index 1ddab4d..52a2d75 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.java
@@ -18,12 +18,14 @@
package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
-import io.microsphere.alibaba.sentinel.mybatis.executor.SentinelMyBatisExecutorFilter;
import io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor;
import io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration.Config;
+import io.microsphere.redis.metadata.RedisMetadataLoader;
+import io.microsphere.redis.spring.interceptor.RedisMethodInterceptor;
import org.junit.jupiter.api.Test;
+import org.springframework.data.redis.connection.RedisConnection;
-import static org.assertj.core.api.Assertions.assertThat;
+import java.util.Set;
/**
* {@link SentinelRedisAutoConfiguration} Test
@@ -34,42 +36,29 @@
*/
class SentinelRedisAutoConfigurationTest extends AutoConfigurationTest {
- @Test
- void testDefaults() {
- this.applicationContextRunner.run(context -> {
- assertThat(context).hasSingleBean(this.autoConfigurationClass)
- .hasSingleBean(Config.class)
- .hasSingleBean(SentinelRedisCommandInterceptor.class);
- });
- }
-
@Test
void tesOntDisabledProperty() {
- assertDisabledProperty("microsphere.sentinel.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelMyBatisExecutorFilter.class);
- assertDisabledProperty("microsphere.redis.enabled=false",
- Config.class, SentinelRedisCommandInterceptor.class);
- assertDisabledProperty("microsphere.sentinel.redis.enabled=false",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
assertDisabledProperty("microsphere.redis.interceptor.enabled=false",
Config.class, SentinelRedisCommandInterceptor.class);
}
- @Test
- void testOnMissingClass() {
- assertFilteredClass("com.alibaba.csp.sentinel.SphU",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.common.SentinelPlugin",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("org.springframework.data.redis.connection.RedisConnection",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("io.microsphere.redis.metadata.RedisMetadataLoader",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("io.microsphere.redis.spring.interceptor.RedisMethodInterceptor",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("io.microsphere.redis.spring.annotation.EnableRedisInterceptor",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
- assertFilteredClass("io.microsphere.alibaba.sentinel.redis.spring.SentinelRedisCommandInterceptor",
- this.autoConfigurationClass, Config.class, SentinelRedisCommandInterceptor.class);
+ @Override
+ protected void configureAutoConfiguredClasses(Set> autoConfiguredClasses) {
+ autoConfiguredClasses.add(Config.class);
+ autoConfiguredClasses.add(SentinelRedisCommandInterceptor.class);
+ }
+
+ @Override
+ protected void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues) {
+ globalDisabledPropertyValues.add("microsphere.redis.enabled=false");
+ globalDisabledPropertyValues.add("microsphere.sentinel.redis.enabled=false");
+ }
+
+ @Override
+ protected void configureGlobalMissingClasses(Set> globalMissingClasses) {
+ globalMissingClasses.add(RedisConnection.class);
+ globalMissingClasses.add(RedisMetadataLoader.class);
+ globalMissingClasses.add(RedisMethodInterceptor.class);
+ globalMissingClasses.add(SentinelRedisCommandInterceptor.class);
}
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfigurationTest.java
new file mode 100644
index 0000000..b46290e
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfigurationTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
+
+
+import io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor;
+import io.microsphere.spring.web.method.support.HandlerMethodInterceptor;
+import org.junit.jupiter.api.Test;
+import org.springframework.web.method.HandlerMethod;
+
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * {@link SentinelSpringWebAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelSpringWebAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelSpringWebAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Test
+ void testAutoConfiguredClasses() {
+ this.applicationContextRunner.run(context -> {
+ assertThat(context).doesNotHaveBean(this.autoConfigurationClass)
+ .doesNotHaveBean(SentinelHandlerMethodInterceptor.class);
+ });
+
+ this.webApplicationContextRunner.run(context -> {
+ assertThat(context).hasSingleBean(this.autoConfigurationClass)
+ .hasSingleBean(SentinelHandlerMethodInterceptor.class);
+ });
+ }
+
+ @Override
+ protected void configureAutoConfiguredClasses(Set> autoConfiguredClasses) {
+ autoConfiguredClasses.add(SentinelHandlerMethodInterceptor.class);
+ }
+
+ @Override
+ protected void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues) {
+ globalDisabledPropertyValues.add("microsphere.sentinel.spring-web.enabled=false");
+ }
+
+ @Override
+ protected void configureGlobalMissingClasses(Set> globalMissingClasses) {
+ globalMissingClasses.add(HandlerMethod.class);
+ globalMissingClasses.add(HandlerMethodInterceptor.class);
+ globalMissingClasses.add(SentinelHandlerMethodInterceptor.class);
+ }
+}
\ No newline at end of file
From 9efbb7f48f7e28bf077f9f6a235bcce018992289 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 20:33:18 +0800
Subject: [PATCH 28/42] Use shared Redis test config
Remove the local RedisConfig test class and switch SentinelAutoConfigurationTest to import io.microsphere.redis.spring.test.config.RedisConfig. This deduplicates Redis test setup and aligns the test with the common Redis test configuration.
---
.../boot/autoconfigure/RedisConfig.java | 58 -------------------
.../SentinelAutoConfigurationTest.java | 1 +
2 files changed, 1 insertion(+), 58 deletions(-)
delete mode 100644 microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
deleted file mode 100644
index b3f6047..0000000
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/RedisConfig.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.microsphere.alibaba.sentinel.spring.boot.autoconfigure;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.StringRedisTemplate;
-
-/**
- * The configuration class for Redis testing
- *
- * @author Mercy
- * @see RedisTemplate
- * @see StringRedisTemplate
- * @see RedisConnectionFactory
- * @since 1.0.0
- */
-public class RedisConfig {
-
- @Bean
- public static RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
- RedisTemplate redisTemplate = new RedisTemplate();
- redisTemplate.setConnectionFactory(redisConnectionFactory);
- return redisTemplate;
- }
-
- @Bean
- public static StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
- StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
- stringRedisTemplate.setConnectionFactory(redisConnectionFactory);
- return stringRedisTemplate;
- }
-
- @Bean
- public static RedisConnectionFactory redisConnectionFactory() {
- LettuceConnectionFactory redisConnectionFactory = new LettuceConnectionFactory("127.0.0.1", 6379);
- redisConnectionFactory.afterPropertiesSet();
- redisConnectionFactory.validateConnection();
- return redisConnectionFactory;
- }
-}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
index f4ccfd8..f09de87 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
@@ -24,6 +24,7 @@
import io.microsphere.mybatis.spring.test.config.MyBatisDataBaseTestConfiguration;
import io.microsphere.mybatis.test.mapper.UserMapper;
import io.microsphere.redis.spring.context.RedisContext;
+import io.microsphere.redis.spring.test.config.RedisConfig;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
From 258a9fcf01476d694609649f99f7c1794a3841c6 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 4 Jul 2026 20:33:49 +0800
Subject: [PATCH 29/42] Normalize Javadoc spacing in auto-configs
Clean up Javadoc formatting in the Sentinel Alibaba Druid and Sentinel MyBatis auto-configuration classes by removing extra leading whitespace in the class descriptions. This keeps comment style consistent across Spring Boot auto-config sources.
---
.../autoconfigure/SentinelAlibabaDruidAutoConfiguration.java | 2 +-
.../boot/autoconfigure/SentinelMyBatisAutoConfiguration.java | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
index 9fd0cb2..d3b429d 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfiguration.java
@@ -30,7 +30,7 @@
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.ENABLED_PROPERTY_NAME;
/**
- * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Alibaba Druid
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Alibaba Druid
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
index f9c5ee2..9de6a42 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfiguration.java
@@ -32,7 +32,7 @@
/**
- * The Spring Boot Auto-Configuration class of Alibaba Sentinel x MyBatis
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x MyBatis
*
* @author Mercy
* @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
From 6ef3d9a0facb93aaa30b052aaf766f34cc8c13e3 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 09:40:06 +0800
Subject: [PATCH 30/42] Auto-install Sentinel DB integration plugins
Switch Druid, Hibernate, and P6Spy integrations to use `SimpleSentinelPlugin` auto-installation by passing `autoInstalled=true`, and remove redundant manual `install(this)` calls. Also rename the constructor flag in `SimpleSentinelPlugin` from `autoRegisterMBean` to `autoInstalled` to align with the behavior.
---
.../alibaba/sentinel/common/SimpleSentinelPlugin.java | 5 +++--
.../sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java | 4 +---
.../hibernate/entity/SentinelHibernateEntityCallback.java | 4 +---
.../alibaba/sentinel/p6spy/SentinelJdbcEventListener.java | 4 +---
4 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SimpleSentinelPlugin.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SimpleSentinelPlugin.java
index 82576de..b6374fa 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SimpleSentinelPlugin.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/SimpleSentinelPlugin.java
@@ -48,7 +48,8 @@ public SimpleSentinelPlugin(String name, String contextName, String origin, int
super(name, contextName, origin, resourceType, trafficType);
}
- public SimpleSentinelPlugin(String name, String contextName, String origin, int resourceType, EntryType trafficType, boolean autoRegisterMBean) {
- super(name, contextName, origin, resourceType, trafficType, autoRegisterMBean);
+ public SimpleSentinelPlugin(String name, String contextName, String origin, int resourceType, EntryType trafficType,
+ boolean autoInstalled) {
+ super(name, contextName, origin, resourceType, trafficType, autoInstalled);
}
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
index 7fd5e32..9e3fcfc 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
@@ -33,7 +33,6 @@
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
-import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
/**
* Sentinel x Alibaba Druid {@link Filter}
@@ -54,9 +53,8 @@ public SentinelAlibabaDruidFilter() {
}
public SentinelAlibabaDruidFilter(String contextName, String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
- install(this);
}
@Override
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
index 1c16e19..e7555d6 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
@@ -32,7 +32,6 @@
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
-import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
@@ -58,9 +57,8 @@ public SentinelHibernateEntityCallback() {
}
public SentinelHibernateEntityCallback(@Nonnull String contextName, @Nonnull String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
- install(this);
}
@Override
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
index 2a10b1f..067c77b 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
@@ -33,7 +33,6 @@
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
-import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
@@ -59,9 +58,8 @@ public SentinelJdbcEventListener() {
}
public SentinelJdbcEventListener(String contextName, String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
- install(this);
}
@Override
From f0647539bc8b5537d29bfd36dbd030f969c5aacc Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 11:34:27 +0800
Subject: [PATCH 31/42] Fix plugin init and Sentinel context cleanup
Switch Druid, Hibernate, and P6Spy integrations to explicit plugin installation by constructing `SimpleSentinelPlugin` with auto-install disabled and then calling `SentinelPlugin.install(this)`. Add `SentinelUtils.resetContextMap()` (via `ContextUtil.resetContextMap`) and register shutdown cleanup, then update tests to reset Sentinel context between runs and assert Druid context behavior consistently when enabled or disabled.
---
.../sentinel/common/util/SentinelUtils.java | 28 +++++++++++++++++++
.../common/util/SentinelUtilsTest.java | 6 ++++
.../druid/SentinelAlibabaDruidFilter.java | 4 ++-
.../druid/SentinelAlibabaDruidFilterTest.java | 22 +++++++++++++--
.../SentinelHibernateEntityCallback.java | 4 ++-
.../p6spy/SentinelJdbcEventListener.java | 4 ++-
6 files changed, 62 insertions(+), 6 deletions(-)
diff --git a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
index 4d93cb0..8f02fe9 100644
--- a/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
+++ b/microsphere-alibaba-sentinel-commons/src/main/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtils.java
@@ -2,9 +2,11 @@
import com.alibaba.csp.sentinel.ResourceTypeConstants;
import com.alibaba.csp.sentinel.concurrent.NamedThreadFactory;
+import com.alibaba.csp.sentinel.context.ContextUtil;
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
import io.microsphere.annotation.Nonnull;
+import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
@@ -17,12 +19,16 @@
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.FLOW_DATA_ID_PATTERN;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.PROPERTY_NAME_PREFIX;
import static io.microsphere.collection.MapUtils.newFixedHashMap;
+import static io.microsphere.concurrent.ExecutorUtils.shutdownOnExit;
import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
import static io.microsphere.constants.SymbolConstants.DOT;
+import static io.microsphere.invoke.MethodHandleUtils.findStatic;
+import static io.microsphere.lang.function.ThrowableAction.execute;
import static io.microsphere.reflect.FieldUtils.getFieldValue;
import static io.microsphere.reflect.FieldUtils.getStaticFieldValue;
import static io.microsphere.text.FormatUtils.format;
import static io.microsphere.util.ClassUtils.getSimpleName;
+import static io.microsphere.util.ShutdownHookUtils.addShutdownHookCallback;
import static io.microsphere.util.SystemUtils.getSystemProperty;
import static java.lang.reflect.Modifier.isStatic;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
@@ -37,8 +43,20 @@ public abstract class SentinelUtils {
private static final Map resourceTypeToLabelMapping = initResourceTypeToLabelMapping();
+ /**
+ * The {@link MethodHandle} of {@link ContextUtil#resetContextMap()}
+ *
+ * @see ContextUtil#resetContextMap()
+ */
+ private static final MethodHandle resetContextMapMethodHandle = findStatic(ContextUtil.class, "resetContextMap");
+
private static volatile ScheduledExecutorService sentinelMetricsTaskExecutor;
+ static {
+ shutdownOnExit(sentinelMetricsTaskExecutor);
+ addShutdownHookCallback(() -> execute(SentinelUtils::resetContextMap));
+ }
+
private static Map initResourceTypeToLabelMapping() {
Field[] fields = ResourceTypeConstants.class.getFields();
Map resourceTypeToLabelMapping = newFixedHashMap(fields.length);
@@ -153,6 +171,16 @@ public static ScheduledExecutorService getSentinelMetricsTaskExecutor() {
return scheduledExecutorService;
}
+ /**
+ * Reset the {@link ContextUtil#resetContextMap() context map} of Sentinel
+ *
+ * @throws Throwable if any exception occurred
+ * @see ContextUtil#resetContextMap()
+ */
+ public static void resetContextMap() throws Throwable {
+ resetContextMapMethodHandle.invokeExact();
+ }
+
static ScheduledExecutorService getSentinelMetricsTaskExecutor(ScheduledExecutorService defaultScheduledExecutorService) {
return defaultScheduledExecutorService == null ?
newSingleThreadScheduledExecutor(new NamedThreadFactory("sentinel-metrics-task", true)) :
diff --git a/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java b/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
index 5bee64d..3dafe8a 100644
--- a/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
+++ b/microsphere-alibaba-sentinel-commons/src/test/java/io/microsphere/alibaba/sentinel/common/util/SentinelUtilsTest.java
@@ -19,6 +19,7 @@
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.getSentinelMetricsTaskExecutor;
import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.isPluginEnabled;
import static io.microsphere.reflect.MethodUtils.findMethod;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -82,4 +83,9 @@ void testGetSentinelMetricsTaskExecutor() {
assertSame(findSentinelMetricsTaskExecutor(), getSentinelMetricsTaskExecutor());
assertNotEquals(findSentinelMetricsTaskExecutor(), getSentinelMetricsTaskExecutor(null));
}
+
+ @Test
+ void testResetContextMap() {
+ assertDoesNotThrow(SentinelUtils::resetContextMap);
+ }
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
index 9e3fcfc..7fd5e32 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/main/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilter.java
@@ -33,6 +33,7 @@
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
+import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
/**
* Sentinel x Alibaba Druid {@link Filter}
@@ -53,8 +54,9 @@ public SentinelAlibabaDruidFilter() {
}
public SentinelAlibabaDruidFilter(String contextName, String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
+ install(this);
}
@Override
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
index 4dad1aa..000d7fc 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
@@ -17,14 +17,18 @@
package io.microsphere.alibaba.sentinel.alibaba.druid;
+import com.alibaba.csp.sentinel.context.Context;
import com.alibaba.druid.filter.Filter;
import com.alibaba.druid.pool.DruidDataSource;
import io.microsphere.alibaba.druid.test.AbstractAlibabaDruidTest;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.List;
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
import static io.microsphere.alibaba.sentinel.alibaba.druid.SentinelAlibabaDruidConstants.PLUGIN_NAME;
+import static io.microsphere.alibaba.sentinel.common.util.SentinelUtils.resetContextMap;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
@@ -37,29 +41,41 @@
*/
class SentinelAlibabaDruidFilterTest extends AbstractAlibabaDruidTest {
+ private final SentinelAlibabaDruidFilter filter = new SentinelAlibabaDruidFilter();
+
+ @BeforeEach
+ void setUp() throws Throwable {
+ resetContextMap();
+ }
+
@Override
protected void customize(DruidDataSource dataSource) {
- dataSource.getProxyFilters().add(new SentinelAlibabaDruidFilter());
+ dataSource.getProxyFilters().add(filter);
}
@Test
void testEnable() throws Throwable {
setEnable(true);
super.test();
+
+ Context context = enter(filter.getContextName(), filter.getOrigin());
+ assertEquals("microsphere_sentinel_alibaba_druid_context", context.getName());
}
@Test
void testDisable() throws Throwable {
setEnable(false);
super.test();
+
+ Context context = enter(filter.getContextName(), filter.getOrigin());
+ assertEquals("microsphere_sentinel_alibaba_druid_context", context.getName());
}
void setEnable(boolean enabled) {
DruidDataSource dataSource = getDruidDataSource();
List proxyFilters = dataSource.getProxyFilters();
for (Filter proxyFilter : proxyFilters) {
- if (proxyFilter instanceof SentinelAlibabaDruidFilter) {
- SentinelAlibabaDruidFilter filter = (SentinelAlibabaDruidFilter) proxyFilter;
+ if (proxyFilter instanceof SentinelAlibabaDruidFilter filter) {
assertEquals(PLUGIN_NAME, filter.getName());
filter.setEnabled(enabled);
}
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
index e7555d6..1c16e19 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/main/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallback.java
@@ -32,6 +32,7 @@
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
+import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.PLUGIN_NAME;
@@ -57,8 +58,9 @@ public SentinelHibernateEntityCallback() {
}
public SentinelHibernateEntityCallback(@Nonnull String contextName, @Nonnull String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
+ install(this);
}
@Override
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
index 067c77b..2a10b1f 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/main/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListener.java
@@ -33,6 +33,7 @@
import static com.alibaba.csp.sentinel.EntryType.IN;
import static com.alibaba.csp.sentinel.ResourceTypeConstants.COMMON_DB_SQL;
import static io.microsphere.alibaba.sentinel.common.SentinelContext.doInContext;
+import static io.microsphere.alibaba.sentinel.common.SentinelPlugin.install;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
@@ -58,8 +59,9 @@ public SentinelJdbcEventListener() {
}
public SentinelJdbcEventListener(String contextName, String origin) {
- this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, true);
+ this.delegate = new SimpleSentinelPlugin(PLUGIN_NAME, contextName, origin, COMMON_DB_SQL, IN, false);
this.sentinelOperations = new SentinelTemplate(getResourceType(), getTrafficType());
+ install(this);
}
@Override
From d2172d0d831f6a2df9ae1dd2ec1cd30ade476fb8 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 11:53:32 +0800
Subject: [PATCH 32/42] Assert Sentinel context node in Hibernate test
Update `SentinelHibernateEntityCallbackTest` to add an `@AfterEach` check that enters the default Sentinel context, verifies the entrance node is created, and exits the context. This strengthens test coverage around Sentinel context initialization/cleanup behavior in Hibernate integration tests.
---
.../SentinelHibernateEntityCallbackTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackTest.java
index ad0e38f..a65b3bf 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-hibernate-core/src/test/java/io/microsphere/alibaba/sentinel/hibernate/entity/SentinelHibernateEntityCallbackTest.java
@@ -17,7 +17,16 @@
package io.microsphere.alibaba.sentinel.hibernate.entity;
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.csp.sentinel.node.DefaultNode;
import io.microsphere.hibernate.test.AbstractHibernateH2Test;
+import org.junit.jupiter.api.AfterEach;
+
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.hibernate.SentinelHibernateConstants.DEFAULT_ORIGIN;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* {@link SentinelHibernateEntityCallback} Test
@@ -27,4 +36,12 @@
* @since 1.0.0
*/
class SentinelHibernateEntityCallbackTest extends AbstractHibernateH2Test {
+
+ @AfterEach
+ void postTest() {
+ Context context = enter(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
+ DefaultNode entranceNode = context.getEntranceNode();
+ assertNotNull(entranceNode);
+ exit();
+ }
}
\ No newline at end of file
From 9e2eb802a9586db57e13d5339f1294637c1d666a Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 11:58:04 +0800
Subject: [PATCH 33/42] Add Sentinel context assertion in MyBatis test
Enhance `SentinelMyBatisExecutorFilterTest` with an `@AfterEach` check that enters the default Sentinel context and asserts the entrance node has child nodes. This validates that mapper execution is producing Sentinel node records across test runs, including when toggling filter enablement.
---
.../SentinelMyBatisExecutorFilterTest.java | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilterTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilterTest.java
index 908a99a..53e8587 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilterTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-mybatis/src/test/java/io/microsphere/alibaba/sentinel/mybatis/executor/SentinelMyBatisExecutorFilterTest.java
@@ -17,12 +17,23 @@
package io.microsphere.alibaba.sentinel.mybatis.executor;
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.csp.sentinel.node.DefaultNode;
+import com.alibaba.csp.sentinel.node.Node;
import io.microsphere.mybatis.plugin.InterceptingExecutorInterceptor;
import io.microsphere.mybatis.test.AbstractMapperTest;
import org.apache.ibatis.session.Configuration;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import java.util.Set;
+
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.mybatis.SentinelMyBatisConstants.DEFAULT_ORIGIN;
import static io.microsphere.util.ArrayUtils.ofArray;
+import static org.junit.jupiter.api.Assertions.assertFalse;
/**
* {@link SentinelMyBatisExecutorFilter} Test
@@ -47,4 +58,13 @@ void testDisabled() throws Throwable {
this.filter.setEnabled(false);
super.testMapper();
}
+
+ @AfterEach
+ void postTest() {
+ Context context = enter(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
+ DefaultNode entranceNode = context.getEntranceNode();
+ Set childList = entranceNode.getChildList();
+ assertFalse(childList.isEmpty());
+ exit();
+ }
}
\ No newline at end of file
From b48337aefdb6576bdd05d4e57faa0e5b20e46a0e Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 12:00:26 +0800
Subject: [PATCH 34/42] Add post-test Sentinel context assertion
Extend `SentinelJdbcEventListenerTest` with an `@AfterEach` check that enters the default Sentinel context/origin and verifies the entrance node has child nodes. This strengthens the test by asserting JDBC listener execution leaves expected Sentinel node state, then exits the context to keep cleanup explicit.
---
.../p6spy/SentinelJdbcEventListenerTest.java | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
index 3a76b8c..83a97e5 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-p6spy/src/test/java/io/microsphere/alibaba/sentinel/p6spy/SentinelJdbcEventListenerTest.java
@@ -17,10 +17,18 @@
package io.microsphere.alibaba.sentinel.p6spy;
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.csp.sentinel.node.DefaultNode;
+import com.alibaba.csp.sentinel.node.Node;
import com.alibaba.druid.pool.DruidDataSource;
import io.microsphere.alibaba.druid.test.AbstractAlibabaDruidTest;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import java.util.Set;
+
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_CONTEXT_NAME;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.DEFAULT_ORIGIN;
import static io.microsphere.alibaba.sentinel.p6spy.SentinelP6SpyConstants.PLUGIN_NAME;
@@ -64,4 +72,13 @@ void testDisabled() {
listener.onAfterAnyExecute(null, 0L, null);
assertFalse(listener.isEnabled());
}
+
+ @AfterEach
+ void postTest() {
+ Context context = enter(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
+ DefaultNode entranceNode = context.getEntranceNode();
+ Set childList = entranceNode.getChildList();
+ assertFalse(childList.isEmpty());
+ exit();
+ }
}
\ No newline at end of file
From 6c7c6034968df1fc27369508b91d63a9c0faa3c7 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 12:07:15 +0800
Subject: [PATCH 35/42] Refactor Redis tests to shared test config
Replace the module-local Redis test configuration with `microsphere-redis-spring-test` by adding it as a test dependency and updating imports accordingly, then remove the duplicated `RedisConfig` class. The interceptor test also now asserts Sentinel context node creation after Redis operations, strengthening verification that command interception is being recorded in Sentinel.
---
.../pom.xml | 7 +++
.../SentinelRedisCommandInterceptorTest.java | 19 +++++-
.../redis/spring/test/RedisConfig.java | 58 -------------------
3 files changed, 25 insertions(+), 59 deletions(-)
delete mode 100644 microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisConfig.java
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
index 4546736..5b74a6b 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/pom.xml
@@ -78,6 +78,13 @@
test
+
+
+ io.github.microsphere-projects
+ microsphere-redis-spring-test
+ test
+
+
org.springframework
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
index c288950..65a9318 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/SentinelRedisCommandInterceptorTest.java
@@ -17,10 +17,13 @@
package io.microsphere.alibaba.sentinel.redis.spring;
-import io.microsphere.alibaba.sentinel.redis.spring.test.RedisConfig;
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.csp.sentinel.node.DefaultNode;
+import com.alibaba.csp.sentinel.node.Node;
import io.microsphere.redis.spring.annotation.EnableRedisInterceptor;
import io.microsphere.redis.spring.context.RedisContext;
import io.microsphere.redis.spring.interceptor.RedisMethodContext;
+import io.microsphere.redis.spring.test.config.RedisConfig;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -29,8 +32,13 @@
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import java.lang.reflect.Method;
+import java.util.Set;
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
import static io.microsphere.alibaba.sentinel.common.constants.SentinelConstants.DEFAULT_PRIORITY;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.redis.SentinelRedisConstants.DEFAULT_ORIGIN;
import static io.microsphere.util.ArrayUtils.ofArray;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -72,6 +80,7 @@ void test() {
valueOperations.set(key, value);
assertEquals(value, valueOperations.get(key));
assertEquals(DEFAULT_PRIORITY, interceptor.getOrder());
+ postTest();
}
@Test
@@ -90,4 +99,12 @@ void testResourceNotFound() {
assertDoesNotThrow(() -> this.interceptor.beforeExecute(context));
assertDoesNotThrow(() -> this.interceptor.afterExecute(context, null, null));
}
+
+ void postTest() {
+ Context context = enter(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
+ DefaultNode entranceNode = context.getEntranceNode();
+ Set childList = entranceNode.getChildList();
+ assertFalse(childList.isEmpty());
+ exit();
+ }
}
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisConfig.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisConfig.java
deleted file mode 100644
index 1bc8d10..0000000
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-redis/src/test/java/io/microsphere/alibaba/sentinel/redis/spring/test/RedisConfig.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.microsphere.alibaba.sentinel.redis.spring.test;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.core.StringRedisTemplate;
-
-/**
- * The configuration class for Redis testing
- *
- * @author Mercy
- * @see RedisTemplate
- * @see StringRedisTemplate
- * @see RedisConnectionFactory
- * @since 1.0.0
- */
-public class RedisConfig {
-
- @Bean
- public static RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
- RedisTemplate redisTemplate = new RedisTemplate();
- redisTemplate.setConnectionFactory(redisConnectionFactory);
- return redisTemplate;
- }
-
- @Bean
- public static StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
- StringRedisTemplate stringRedisTemplate = new StringRedisTemplate();
- stringRedisTemplate.setConnectionFactory(redisConnectionFactory);
- return stringRedisTemplate;
- }
-
- @Bean
- public static RedisConnectionFactory redisConnectionFactory() {
- LettuceConnectionFactory redisConnectionFactory = new LettuceConnectionFactory("127.0.0.1", 6379);
- redisConnectionFactory.afterPropertiesSet();
- redisConnectionFactory.validateConnection();
- return redisConnectionFactory;
- }
-}
\ No newline at end of file
From 03e5d6c005c23520065eb87c3a9b3a9defdd8c59 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 12:12:00 +0800
Subject: [PATCH 36/42] Add post-check for Sentinel context nodes
Extend `SentinelHandlerMethodInterceptorTest` with a post-test assertion that enters the default Sentinel web context and verifies the entrance node has child nodes. This strengthens coverage by confirming requests create Sentinel node links and that context lifecycle cleanup still works.
---
.../SentinelHandlerMethodInterceptorTest.java | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptorTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptorTest.java
index 9f22c0a..5a29918 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptorTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-spring-web/src/test/java/io/microsphere/alibaba/sentinel/spring/web/SentinelHandlerMethodInterceptorTest.java
@@ -17,6 +17,9 @@
package io.microsphere.alibaba.sentinel.spring.web;
+import com.alibaba.csp.sentinel.context.Context;
+import com.alibaba.csp.sentinel.node.DefaultNode;
+import com.alibaba.csp.sentinel.node.Node;
import io.microsphere.spring.test.web.context.request.MockServletWebRequest;
import io.microsphere.spring.test.webmvc.AbstractWebMvcTest;
import io.microsphere.spring.webmvc.annotation.EnableWebMvcExtension;
@@ -27,8 +30,14 @@
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
+import java.util.Set;
+
+import static com.alibaba.csp.sentinel.context.ContextUtil.enter;
+import static com.alibaba.csp.sentinel.context.ContextUtil.exit;
import static io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor.BEAN_NAME;
import static io.microsphere.alibaba.sentinel.spring.web.SentinelHandlerMethodInterceptor.getSentinelContext;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_CONTEXT_NAME;
+import static io.microsphere.alibaba.sentinel.spring.web.SentinelSpringWebConstants.DEFAULT_ORIGIN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -67,6 +76,7 @@ public void setUp() {
void test() throws Exception {
this.testHelloWorld();
this.testGreeting();
+ postTest();
}
@Test
@@ -84,4 +94,12 @@ void testAfterExecuteWithoutSentinelContext() {
this.interceptor.afterExecute(null, null, null, null, request);
assertNull(getSentinelContext(request));
}
+
+ void postTest() {
+ Context context = enter(DEFAULT_CONTEXT_NAME, DEFAULT_ORIGIN);
+ DefaultNode entranceNode = context.getEntranceNode();
+ Set childList = entranceNode.getChildList();
+ assertFalse(childList.isEmpty());
+ exit();
+ }
}
\ No newline at end of file
From 564e2b0e265470f197f23469db4b46aa3b1f16e5 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 13:43:08 +0800
Subject: [PATCH 37/42] Add spring-cloud module for Sentinel integration
Introduce a new `microsphere-alibaba-sentinel-spring-cloud` module and register it in the root reactor build. The new module centralizes Spring Cloud-related Sentinel dependencies (including optional integrations for Druid, Hibernate, MyBatis, Redis, WebMVC, and WebFlux) and adds Spring Boot auto-configuration metadata placeholders. As part of the split, WebMVC/WebFlux test dependencies were removed from the Spring Boot module to align responsibilities.
---
.../pom.xml | 14 --
.../pom.xml | 237 ++++++++++++++++++
.../main/resources/META-INF/spring.factories | 0
...ot.autoconfigure.AutoConfiguration.imports | 0
pom.xml | 1 +
5 files changed, 238 insertions(+), 14 deletions(-)
create mode 100644 microsphere-alibaba-sentinel-spring-cloud/pom.xml
create mode 100644 microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories
create mode 100644 microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
diff --git a/microsphere-alibaba-sentinel-spring-boot/pom.xml b/microsphere-alibaba-sentinel-spring-boot/pom.xml
index 89ef900..6d541cb 100644
--- a/microsphere-alibaba-sentinel-spring-boot/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-boot/pom.xml
@@ -249,20 +249,6 @@
test
-
-
- io.github.microsphere-projects
- microsphere-spring-boot-webmvc
- test
-
-
-
-
- io.github.microsphere-projects
- microsphere-spring-boot-webflux
- test
-
-
com.h2database
diff --git a/microsphere-alibaba-sentinel-spring-cloud/pom.xml b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
new file mode 100644
index 0000000..15d7768
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
@@ -0,0 +1,237 @@
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-parent
+ ${revision}
+ ../microsphere-alibaba-sentinel-parent/pom.xml
+
+ 4.0.0
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-spring-cloud
+ ${revision}
+ jar
+
+ Microsphere :: Alibaba Sentinel :: Spring Cloud
+ Microsphere Alibaba Sentinel Spring Cloud
+
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-sentinel-spring-boot
+ ${revision}
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-cloud-commons
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-druid-spring-cloud
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-hibernate-core
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-mybatis-spring-cloud
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-redis-spring-cloud
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webmvc
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-boot-webflux
+ true
+
+
+
+
+
+
+ com.alibaba.csp
+ sentinel-core
+ true
+
+
+
+
+ com.alibaba
+ druid
+ true
+
+
+
+
+ org.hibernate.orm
+ hibernate-core
+ true
+
+
+
+
+ org.mybatis
+ mybatis
+ true
+
+
+
+ org.mybatis
+ mybatis-spring
+ true
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ true
+
+
+
+
+ org.springframework.data
+ spring-data-redis
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-actuator
+ true
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ true
+
+
+
+
+ org.assertj
+ assertj-core
+ test
+
+
+
+
+ org.springframework
+ spring-test
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-test
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+ true
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-spring-test
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-alibaba-druid-spring-test
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-hibernate-test
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-mybatis-spring-test
+ test
+
+
+
+
+ io.github.microsphere-projects
+ microsphere-redis-spring-test
+ test
+
+
+
+
+ com.h2database
+ h2
+ test
+
+
+
+
+ io.lettuce
+ lettuce-core
+ test
+
+
+
+ org.apache.commons
+ commons-pool2
+ test
+
+
+
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories
new file mode 100644
index 0000000..e69de29
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 0000000..e69de29
diff --git a/pom.xml b/pom.xml
index 2832c77..010d7ff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
microsphere-alibaba-sentinel-plugins
microsphere-alibaba-sentinel-spring
microsphere-alibaba-sentinel-spring-boot
+ microsphere-alibaba-sentinel-spring-cloud
microsphere-alibaba-sentinel-dependencies
From 8933e4a78354a9892b8f7fbcbdc9de1ec7b8c8d9 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 13:46:20 +0800
Subject: [PATCH 38/42] Fix Hibernate core groupId in spring-cloud module
Update `microsphere-alibaba-sentinel-spring-cloud/pom.xml` to use the correct Maven coordinates for `hibernate-core` by changing the groupId from `org.hibernate.orm` to `org.hibernate`. This aligns dependency resolution with the expected artifact namespace.
---
microsphere-alibaba-sentinel-spring-cloud/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-spring-cloud/pom.xml b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
index 15d7768..64abef8 100644
--- a/microsphere-alibaba-sentinel-spring-cloud/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
@@ -93,7 +93,7 @@
- org.hibernate.orm
+ org.hibernate
hibernate-core
true
From 41fede5b8836bc274a2f6da08735d489b9a62503 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 13:48:00 +0800
Subject: [PATCH 39/42] Use explicit cast in Druid filter test
Update `SentinelAlibabaDruidFilterTest` to replace pattern matching `instanceof` with a classic `instanceof` check plus explicit cast before assertions. This keeps the test behavior unchanged while improving compatibility with environments that do not support newer Java syntax.
---
.../sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
index 000d7fc..24f6596 100644
--- a/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
+++ b/microsphere-alibaba-sentinel-plugins/microsphere-alibaba-sentinel-alibaba-druid/src/test/java/io/microsphere/alibaba/sentinel/alibaba/druid/SentinelAlibabaDruidFilterTest.java
@@ -75,7 +75,8 @@ void setEnable(boolean enabled) {
DruidDataSource dataSource = getDruidDataSource();
List proxyFilters = dataSource.getProxyFilters();
for (Filter proxyFilter : proxyFilters) {
- if (proxyFilter instanceof SentinelAlibabaDruidFilter filter) {
+ if (proxyFilter instanceof SentinelAlibabaDruidFilter) {
+ SentinelAlibabaDruidFilter filter = (SentinelAlibabaDruidFilter) proxyFilter;
assertEquals(PLUGIN_NAME, filter.getName());
filter.setEnabled(enabled);
}
From e5632c237bf9deda5818e2308eae929713e4fb42 Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sun, 5 Jul 2026 22:35:22 +0800
Subject: [PATCH 40/42] Add Sentinel Spring Cloud auto-configuration
Introduce `SentinelCloudAutoConfiguration` to expose Sentinel plugin capabilities as Spring Cloud `HasFeatures`, including named features for enabled plugins and abstract features for disabled ones. Register the auto-configuration for both `spring.factories` and Boot 3 `AutoConfiguration.imports`, add optional Spring Cloud commons/context dependencies, and add a Spring Boot test to verify feature bean creation and `FeaturesEndpoint` integration.
---
.../pom.xml | 13 +++
.../cloud/SentinelCloudAutoConfiguration.java | 93 +++++++++++++++++++
.../main/resources/META-INF/spring.factories | 2 +
...ot.autoconfigure.AutoConfiguration.imports | 1 +
.../SentinelCloudAutoConfigurationTest.java | 68 ++++++++++++++
5 files changed, 177 insertions(+)
create mode 100644 microsphere-alibaba-sentinel-spring-cloud/src/main/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfiguration.java
create mode 100644 microsphere-alibaba-sentinel-spring-cloud/src/test/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfigurationTest.java
diff --git a/microsphere-alibaba-sentinel-spring-cloud/pom.xml b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
index 64abef8..281d9ca 100644
--- a/microsphere-alibaba-sentinel-spring-cloud/pom.xml
+++ b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
@@ -124,6 +124,19 @@
true
+
+
+ org.springframework.cloud
+ spring-cloud-commons
+ true
+
+
+
+ org.springframework.cloud
+ spring-cloud-context
+ true
+
+
org.springframework.boot
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/main/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-cloud/src/main/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfiguration.java
new file mode 100644
index 0000000..007dccc
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-cloud/src/main/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfiguration.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.cloud;
+
+import io.microsphere.alibaba.sentinel.common.SentinelPlugin;
+import io.microsphere.alibaba.sentinel.common.SentinelPluginRepository;
+import io.microsphere.alibaba.sentinel.spring.boot.condition.ConditionalOnSentinelAvailable;
+import io.microsphere.spring.cloud.client.condition.ConditionalOnFeaturesAvailable;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.cloud.client.actuator.HasFeatures;
+import org.springframework.cloud.client.actuator.NamedFeature;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+
+import java.util.Collection;
+import java.util.List;
+
+import static io.microsphere.alibaba.sentinel.common.SentinelPluginRepository.INSTANCE;
+import static io.microsphere.collection.ListUtils.newLinkedList;
+
+/**
+ * The Spring Cloud Auto-Configuration Class of Alibaba Sentinel
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see io.microsphere.alibaba.druid.spring.cloud.autoconfigure.AlibabaDruidCloudAutoConfiguration
+ * @see io.microsphere.mybatis.spring.cloud.autoconfigure.MyBatisCloudAutoConfiguration
+ * @see io.microsphere.redis.spring.cloud.autoconfigure.RedisCloudAutoConfiguration
+ * @see io.microsphere.spring.cloud.client.actuator.ConfigurationPropertyHasFeaturesAutoConfiguration
+ * @see io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration
+ * @see io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration
+ * @see io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration
+ * @see io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelSpringWebAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnSentinelAvailable
+@AutoConfigureAfter(name = {
+ "com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration",
+ "io.microsphere.alibaba.druid.spring.cloud.autoconfigure.AlibabaDruidCloudAutoConfiguration", // Microsphere Alibaba Druid Spring Cloud
+ "io.microsphere.mybatis.spring.cloud.autoconfigure.MyBatisCloudAutoConfiguration", // Microsphere MyBatis Spring Cloud
+ "io.microsphere.redis.spring.cloud.autoconfigure.RedisCloudAutoConfiguration", // Microsphere Redis Spring Cloud
+ "io.microsphere.spring.cloud.client.actuator.ConfigurationPropertyHasFeaturesAutoConfiguration", // Microsphere Spring Cloud
+ "io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelAlibabaDruidAutoConfiguration", // Microsphere Sentinel Spring Boot x Alibaba Druid
+ "io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelMyBatisAutoConfiguration", // Microsphere Sentinel Spring Boot x MyBatis
+ "io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration", // Microsphere Sentinel Spring Boot x Redis
+ "io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelSpringWebAutoConfiguration" // Microsphere Sentinel Spring Boot x Spring Web
+})
+@Import(value = {
+ SentinelCloudAutoConfiguration.FeaturesConfig.class
+})
+public class SentinelCloudAutoConfiguration {
+
+ @ConditionalOnFeaturesAvailable
+ public static class FeaturesConfig {
+
+ public static final String BEAN_NAME = "alibaba-sentinel.features";
+
+ @Bean(name = BEAN_NAME)
+ public HasFeatures features() {
+ SentinelPluginRepository sentinelPluginRepository = INSTANCE;
+ Collection sentinelPlugins = sentinelPluginRepository.getAll();
+ List> abstractFeatures = newLinkedList();
+ List namedFeatures = newLinkedList();
+ for (SentinelPlugin sentinelPlugin : sentinelPlugins) {
+ Class> type = sentinelPlugin.getClass();
+ if (sentinelPlugin.isEnabled()) {
+ String name = sentinelPlugin.getName();
+ NamedFeature namedFeature = new NamedFeature(name, type);
+ namedFeatures.add(namedFeature);
+ } else {
+ abstractFeatures.add(type);
+ }
+ }
+ HasFeatures hasFeatures = new HasFeatures(abstractFeatures, namedFeatures);
+ return hasFeatures;
+ }
+ }
+}
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories
index e69de29..28e933f 100644
--- a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories
+++ b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring.factories
@@ -0,0 +1,2 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
+io.microsphere.alibaba.sentinel.spring.cloud.SentinelCloudAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index e69de29..dfd85db 100644
--- a/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/microsphere-alibaba-sentinel-spring-cloud/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+io.microsphere.alibaba.sentinel.spring.cloud.SentinelCloudAutoConfiguration
\ No newline at end of file
diff --git a/microsphere-alibaba-sentinel-spring-cloud/src/test/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfigurationTest.java b/microsphere-alibaba-sentinel-spring-cloud/src/test/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfigurationTest.java
new file mode 100644
index 0000000..00cf988
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-cloud/src/test/java/io/microsphere/alibaba/sentinel/spring/cloud/SentinelCloudAutoConfigurationTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.microsphere.alibaba.sentinel.spring.cloud;
+
+
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.cloud.client.actuator.FeaturesEndpoint;
+import org.springframework.cloud.client.actuator.HasFeatures;
+
+import java.util.Map;
+
+import static io.microsphere.alibaba.sentinel.spring.cloud.SentinelCloudAutoConfiguration.FeaturesConfig.BEAN_NAME;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.NONE;
+
+/**
+ * {@link SentinelCloudAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelCloudAutoConfiguration
+ * @since 1.0.0
+ */
+@SpringBootTest(
+ classes = {
+ SentinelCloudAutoConfigurationTest.class
+ },
+ webEnvironment = NONE,
+ properties = {
+ "spring.application.name=test-app",
+ "management.endpoints.web.exposure.include=features",
+ }
+)
+@EnableAutoConfiguration
+class SentinelCloudAutoConfigurationTest {
+
+ @Autowired
+ private Map hasFeaturesMap;
+
+ @Autowired
+ private FeaturesEndpoint featuresEndpoint;
+
+ @Test
+ void test() {
+ assertEquals("alibaba-sentinel.features", BEAN_NAME);
+ HasFeatures hasFeatures = this.hasFeaturesMap.get(BEAN_NAME);
+ assertNotNull(hasFeatures);
+ assertNotNull(this.featuresEndpoint.features());
+ }
+}
\ No newline at end of file
From 53f2e81a706a687a21eca2fd9d219fcb2b5c3c6e Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Mon, 6 Jul 2026 00:00:09 +0800
Subject: [PATCH 41/42] Clarify Sentinel availability annotation docs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Improve readability of `ConditionalOnSentinelAvailable` by renaming the Javadoc section heading to “Example Usage” and adding inline comments that explain the two `@ConditionalOnClass` dependencies (Sentinel core API and Microsphere commons API).
---
.../boot/condition/ConditionalOnSentinelAvailable.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
index ec6be93..07cc066 100644
--- a/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
@@ -36,7 +36,7 @@
* only if Sentinel is explicitly enabled and the Sentinel core classes are present on the classpath.
*
*
- * Usage Example
+ * Example Usage
* {@code
* @Configuration
* @ConditionalOnSentinelAvailiable
@@ -54,8 +54,8 @@
@Documented
@ConditionalOnSentinelEnabled
@ConditionalOnClass(name = {
- "com.alibaba.csp.sentinel.SphU",
- "io.microsphere.alibaba.sentinel.common.SentinelPlugin"
+ "com.alibaba.csp.sentinel.SphU", // Sentinel Core API
+ "io.microsphere.alibaba.sentinel.common.SentinelPlugin" // Microsphere Sentinel Commons API
})
public @interface ConditionalOnSentinelAvailable {
}
\ No newline at end of file
From ccc910da254006dffa545f32235eeda3e6d7c81e Mon Sep 17 00:00:00 2001
From: Mercy Ma
Date: Sat, 11 Jul 2026 15:21:10 +0800
Subject: [PATCH 42/42] Bump Microsphere BOM and parent versions
Updates the project parent to `microsphere-spring-cloud-parent` 0.1.23 and refreshes related BOM properties in `microsphere-alibaba-sentinel-parent` (spring-cloud, alibaba-druid, mybatis, hibernate, redis) to their latest compatible releases.
---
microsphere-alibaba-sentinel-parent/pom.xml | 10 +++++-----
pom.xml | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/microsphere-alibaba-sentinel-parent/pom.xml b/microsphere-alibaba-sentinel-parent/pom.xml
index 2899fdf..fe1ffe1 100644
--- a/microsphere-alibaba-sentinel-parent/pom.xml
+++ b/microsphere-alibaba-sentinel-parent/pom.xml
@@ -20,11 +20,11 @@
- 0.1.21
- 0.1.17
- 0.1.12
- 0.1.6
- 0.1.10
+ 0.1.23
+ 0.1.18
+ 0.1.13
+ 0.1.7
+ 0.1.11
1.8.10
2.0.62
diff --git a/pom.xml b/pom.xml
index 010d7ff..b25449a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.github.microsphere-projects
microsphere-spring-cloud-parent
- 0.1.21
+ 0.1.23
io.github.microsphere-projects