sqlSessionFactoryProvider) {
-// SentinelMyBatisInterceptor interceptor = new SentinelMyBatisInterceptor();
-// SqlSessionFactory[] sqlSessionFactories = sqlSessionFactoryProvider.getIfAvailable();
-// for (SqlSessionFactory sqlSessionFactory : sqlSessionFactories) {
-// sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
-// }
-// }
-// }
-}
\ 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..9de6a42
--- /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 Spring Boot Auto-Configuration class of Alibaba 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..62357b7
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfiguration.java
@@ -0,0 +1,48 @@
+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.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;
+
+/**
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Redis
+ *
+ * @author Mercy
+ * @see com.alibaba.cloud.sentinel.custom.SentinelAutoConfiguration
+ * @see org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
+ * @since 1.0.0
+ */
+@ConditionalOnSentinelAvailable
+@ConditionalOnRedisAvailable
+@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
+@ConditionalOnClass(name = {
+ "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 {
+
+ @ConditionalOnRedisInterceptorEnabled
+ 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/autoconfigure/SentinelSpringWebAutoConfiguration.java b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfiguration.java
new file mode 100644
index 0000000..8c59be5
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelSpringWebAutoConfiguration.java
@@ -0,0 +1,47 @@
+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.spring.web.SentinelSpringWebConstants.ENABLED_PROPERTY_NAME;
+import static org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type.ANY;
+
+/**
+ * The Spring Boot Auto-Configuration class of Alibaba Sentinel x Spring Web
+ *
+ * @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 = {
+ "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 SentinelSpringWebAutoConfiguration {
+
+ @Bean
+ @ConditionalOnMissingBean
+ public SentinelHandlerMethodInterceptor sentinelHandlerMethodInterceptor() {
+ return new SentinelHandlerMethodInterceptor();
+ }
+}
\ 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
new file mode 100644
index 0000000..07cc066
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/main/java/io/microsphere/alibaba/sentinel/spring/boot/condition/ConditionalOnSentinelAvailable.java
@@ -0,0 +1,61 @@
+/*
+ * 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.SentinelRedisAutoConfiguration;
+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" ,
+ * "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.
+ *
+ *
+ * Example Usage
+ * {@code
+ * @Configuration
+ * @ConditionalOnSentinelAvailiable
+ * public class MySentinelConfiguration {
+ * // This configuration will only be active if Sentinel is available
+ * }
+ * }
+ *
+ * @author Mercy
+ * @see SentinelRedisAutoConfiguration
+ * @since 1.0.0
+ */
+@Retention(RUNTIME)
+@Target({TYPE, METHOD})
+@Documented
+@ConditionalOnSentinelEnabled
+@ConditionalOnClass(name = {
+ "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
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..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,37 +16,28 @@
*/
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 io.microsphere.alibaba.sentinel.spring.boot.autoconfigure.SentinelRedisAutoConfiguration;
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
+ * @see SentinelRedisAutoConfiguration
* @since 1.0.0
*/
@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
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..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
@@ -1,2 +1,5 @@
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,\
+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 8344d3f..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 +1,4 @@
-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
+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
new file mode 100644
index 0000000..8ce5a32
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/AutoConfigurationTest.java
@@ -0,0 +1,153 @@
+/*
+ * 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.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;
+
+/**
+ * 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;
+
+ WebApplicationContextRunner webApplicationContextRunner;
+
+ final Class autoConfigurationClass;
+
+ AutoConfigurationTest() {
+ this.autoConfigurationClass = (Class) forClass(getClass())
+ .as(AutoConfigurationTest.class).resolveGeneric(0);
+ }
+
+ @BeforeEach
+ 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 -> {
+ for (Class> beanClass : 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) {
+ this.applicationContextRunner.withClassLoader(new FilteredClassLoader(filteredClass))
+ .run(context -> {
+ for (Class> beanClass : 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
new file mode 100644
index 0000000..61f28b1
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAlibabaDruidAutoConfigurationTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.autoconfigure.SentinelAlibabaDruidAutoConfiguration.Config;
+import org.junit.jupiter.api.Test;
+
+import java.util.Set;
+
+/**
+ * {@link SentinelAlibabaDruidAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelAlibabaDruidAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelAlibabaDruidAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Test
+ void tesOnDisabledProperty() {
+ assertDisabledProperty("microsphere.alibaba.druid.enabled=false",
+ Config.class, SentinelAlibabaDruidFilter.class);
+ }
+
+ @Test
+ void testOnMissingClass() {
+ 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/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..f09de87
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelAutoConfigurationTest.java
@@ -0,0 +1,120 @@
+/*
+ * 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 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;
+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 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;
+import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
+
+/**
+ * SentinelAutoConfiguration Test
+ *
+ * @author Mercy
+ * @see SentinelAlibabaDruidAutoConfiguration
+ * @see SentinelMyBatisAutoConfiguration
+ * @see SentinelRedisAutoConfiguration
+ * @since 1.0.0
+ */
+@SpringBootTest(classes = {
+ MyBatisDataBaseTestConfiguration.class,
+ RedisConfig.class,
+ 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 {
+
+ @Autowired
+ private RedisContext redisContext;
+
+ @Autowired
+ private StringRedisTemplate stringRedisTemplate;
+
+ @Autowired
+ private SentinelRedisCommandInterceptor interceptor;
+
+ @Autowired
+ private SqlSessionFactory sessionFactory;
+
+ @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);
+ }
+
+ static class TestConfig {
+
+ @Bean(initMethod = "init", destroyMethod = "close")
+ public DruidDataSource dataSource() throws IOException {
+ return buildDefaultDruidDataSource();
+ }
+ }
+}
\ 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..d8f1348
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelMyBatisAutoConfigurationTest.java
@@ -0,0 +1,55 @@
+/*
+ * 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 io.microsphere.mybatis.spring.annotation.EnableMyBatisExtension;
+import org.apache.ibatis.session.SqlSessionFactory;
+
+import java.util.Set;
+
+/**
+ * {@link SentinelMyBatisAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelMyBatisAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelMyBatisAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Override
+ protected void configureAutoConfiguredClasses(Set> autoConfiguredClasses) {
+ autoConfiguredClasses.add(Config.class);
+ autoConfiguredClasses.add(SentinelMyBatisExecutorFilter.class);
+ }
+
+ @Override
+ protected void configureGlobalDisabledPropertyValues(Set globalDisabledPropertyValues) {
+ globalDisabledPropertyValues.add("microsphere.mybatis.enabled=false");
+ globalDisabledPropertyValues.add("microsphere.sentinel.mybatis.enabled=false");
+ }
+
+ @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
new file mode 100644
index 0000000..52a2d75
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-boot/src/test/java/io/microsphere/alibaba/sentinel/spring/boot/autoconfigure/SentinelRedisAutoConfigurationTest.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.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 java.util.Set;
+
+/**
+ * {@link SentinelRedisAutoConfiguration} Test
+ *
+ * @author Mercy
+ * @see SentinelRedisAutoConfiguration
+ * @since 1.0.0
+ */
+class SentinelRedisAutoConfigurationTest extends AutoConfigurationTest {
+
+ @Test
+ void tesOntDisabledProperty() {
+ assertDisabledProperty("microsphere.redis.interceptor.enabled=false",
+ 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
diff --git a/microsphere-alibaba-sentinel-spring-cloud/pom.xml b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
new file mode 100644
index 0000000..281d9ca
--- /dev/null
+++ b/microsphere-alibaba-sentinel-spring-cloud/pom.xml
@@ -0,0 +1,250 @@
+
+
+
+ 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
+ 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.cloud
+ spring-cloud-commons
+ true
+
+
+
+ org.springframework.cloud
+ spring-cloud-context
+ 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/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
new file mode 100644
index 0000000..28e933f
--- /dev/null
+++ 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
new file mode 100644
index 0000000..dfd85db
--- /dev/null
+++ 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
diff --git a/pom.xml b/pom.xml
index 35ae772..b25449a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.github.microsphere-projects
microsphere-spring-cloud-parent
- 0.1.16
+ 0.1.23
io.github.microsphere-projects
@@ -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