diff --git a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java index bc1e0a1739..80b4f4a938 100644 --- a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java +++ b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java @@ -15,14 +15,6 @@ */ package io.github.resilience4j.bulkhead.autoconfigure; -import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; - import io.github.resilience4j.bulkhead.Bulkhead; import io.github.resilience4j.bulkhead.BulkheadRegistry; import io.github.resilience4j.bulkhead.ThreadPoolBulkheadRegistry; @@ -30,6 +22,14 @@ import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEndpoint; import io.github.resilience4j.bulkhead.monitoring.endpoint.BulkheadEventsEndpoint; import io.github.resilience4j.consumer.EventConsumerRegistry; +import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; +import org.springframework.boot.actuate.endpoint.Endpoint; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; /** * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -43,11 +43,13 @@ public class BulkheadAutoConfiguration { @Bean + @ConditionalOnClass(value = {Endpoint.class}) public BulkheadEndpoint bulkheadEndpoint(BulkheadRegistry bulkheadRegistry, ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry) { return new BulkheadEndpoint(bulkheadRegistry, threadPoolBulkheadRegistry); } @Bean + @ConditionalOnClass(value = {Endpoint.class}) public BulkheadEventsEndpoint bulkheadEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new BulkheadEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java index 0dffc92c10..cbe8719159 100644 --- a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java +++ b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java @@ -16,6 +16,7 @@ package io.github.resilience4j.circuitbreaker.autoconfigure; import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; +import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -42,11 +43,13 @@ public class CircuitBreakerAutoConfiguration { @Bean + @ConditionalOnClass(value = {Endpoint.class}) public CircuitBreakerEndpoint circuitBreakerEndpoint(CircuitBreakerRegistry circuitBreakerRegistry) { return new CircuitBreakerEndpoint(circuitBreakerRegistry); } @Bean + @ConditionalOnClass(value = {Endpoint.class}) public CircuitBreakerEventsEndpoint circuitBreakerEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new CircuitBreakerEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java index 81257beccf..20511caee7 100644 --- a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java +++ b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java @@ -15,10 +15,16 @@ */ package io.github.resilience4j.ratelimiter.autoconfigure; -import javax.annotation.PostConstruct; - +import io.github.resilience4j.consumer.EventConsumerRegistry; +import io.github.resilience4j.ratelimiter.RateLimiter; +import io.github.resilience4j.ratelimiter.RateLimiterRegistry; +import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint; +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint; +import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; +import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -26,13 +32,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import io.github.resilience4j.consumer.EventConsumerRegistry; -import io.github.resilience4j.ratelimiter.RateLimiter; -import io.github.resilience4j.ratelimiter.RateLimiterRegistry; -import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; -import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint; -import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint; -import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator; +import javax.annotation.PostConstruct; /** * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -55,11 +55,13 @@ public RateLimiterAutoConfiguration(RateLimiterProperties rateLimiterProperties, } @Bean + @ConditionalOnClass(value = {Endpoint.class}) public RateLimiterEndpoint rateLimiterEndpoint(RateLimiterRegistry rateLimiterRegistry) { return new RateLimiterEndpoint(rateLimiterRegistry); } @Bean + @ConditionalOnClass(value = {Endpoint.class}) public RateLimiterEventsEndpoint rateLimiterEventsEndpoint(EventConsumerRegistry eventsConsumerRegistry) { return new RateLimiterEventsEndpoint(eventsConsumerRegistry); } diff --git a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java index eba2f8822a..2753e6d817 100644 --- a/resilience4j-spring-boot/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java +++ b/resilience4j-spring-boot/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java @@ -16,6 +16,7 @@ package io.github.resilience4j.retry.autoconfigure; import org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration; +import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -43,11 +44,13 @@ public class RetryAutoConfiguration { @Bean + @ConditionalOnClass(value = {Endpoint.class}) public RetryEndpoint retryEndpoint(RetryRegistry retryRegistry) { return new RetryEndpoint(retryRegistry); } @Bean + @ConditionalOnClass(value = {Endpoint.class}) public RetryEventsEndpoint retryEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new RetryEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java index 75f7ec233c..345ce50f1b 100644 --- a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java +++ b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/bulkhead/autoconfigure/BulkheadAutoConfiguration.java @@ -17,6 +17,7 @@ import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -43,14 +44,17 @@ @Import({BulkheadConfigurationOnMissingBean.class, FallbackConfigurationOnMissingBean.class}) @AutoConfigureBefore(EndpointAutoConfiguration.class) public class BulkheadAutoConfiguration { + @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public BulkheadEndpoint bulkheadEndpoint(BulkheadRegistry bulkheadRegistry, ThreadPoolBulkheadRegistry threadPoolBulkheadRegistry) { return new BulkheadEndpoint(bulkheadRegistry, threadPoolBulkheadRegistry); } @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public BulkheadEventsEndpoint bulkheadEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new BulkheadEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java index 55c7655a16..041fba7b3b 100644 --- a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java +++ b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/circuitbreaker/autoconfigure/CircuitBreakerAutoConfiguration.java @@ -15,8 +15,16 @@ */ package io.github.resilience4j.circuitbreaker.autoconfigure; +import io.github.resilience4j.circuitbreaker.CircuitBreaker; +import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry; +import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent; +import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEndpoint; +import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpoint; +import io.github.resilience4j.consumer.EventConsumerRegistry; +import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -24,14 +32,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import io.github.resilience4j.circuitbreaker.CircuitBreaker; -import io.github.resilience4j.circuitbreaker.CircuitBreakerRegistry; -import io.github.resilience4j.circuitbreaker.event.CircuitBreakerEvent; -import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEndpoint; -import io.github.resilience4j.circuitbreaker.monitoring.endpoint.CircuitBreakerEventsEndpoint; -import io.github.resilience4j.consumer.EventConsumerRegistry; -import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean; - /** * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -46,12 +46,14 @@ public class CircuitBreakerAutoConfiguration { @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public CircuitBreakerEndpoint circuitBreakerEndpoint(CircuitBreakerRegistry circuitBreakerRegistry) { return new CircuitBreakerEndpoint(circuitBreakerRegistry); } @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public CircuitBreakerEventsEndpoint circuitBreakerEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new CircuitBreakerEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java index b48a2d562b..38443253a2 100644 --- a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java +++ b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/ratelimiter/autoconfigure/RateLimiterAutoConfiguration.java @@ -15,11 +15,18 @@ */ package io.github.resilience4j.ratelimiter.autoconfigure; -import javax.annotation.PostConstruct; - +import io.github.resilience4j.consumer.EventConsumerRegistry; +import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean; +import io.github.resilience4j.ratelimiter.RateLimiter; +import io.github.resilience4j.ratelimiter.RateLimiterRegistry; +import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint; +import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint; +import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator; import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -27,14 +34,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import io.github.resilience4j.consumer.EventConsumerRegistry; -import io.github.resilience4j.fallback.autoconfigure.FallbackConfigurationOnMissingBean; -import io.github.resilience4j.ratelimiter.RateLimiter; -import io.github.resilience4j.ratelimiter.RateLimiterRegistry; -import io.github.resilience4j.ratelimiter.event.RateLimiterEvent; -import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEndpoint; -import io.github.resilience4j.ratelimiter.monitoring.endpoint.RateLimiterEventsEndpoint; -import io.github.resilience4j.ratelimiter.monitoring.health.RateLimiterHealthIndicator; +import javax.annotation.PostConstruct; /** * {@link org.springframework.boot.autoconfigure.EnableAutoConfiguration @@ -58,12 +58,14 @@ public RateLimiterAutoConfiguration(RateLimiterProperties rateLimiterProperties, @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public RateLimiterEndpoint rateLimiterEndpoint(RateLimiterRegistry rateLimiterRegistry) { return new RateLimiterEndpoint(rateLimiterRegistry); } @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public RateLimiterEventsEndpoint rateLimiterEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new RateLimiterEventsEndpoint(eventConsumerRegistry); } diff --git a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java index 64f07e99c0..55f819f602 100644 --- a/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java +++ b/resilience4j-spring-boot2/src/main/java/io/github/resilience4j/retry/autoconfigure/RetryAutoConfiguration.java @@ -16,6 +16,7 @@ package io.github.resilience4j.retry.autoconfigure; import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint; +import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; @@ -40,14 +41,17 @@ @EnableConfigurationProperties(RetryProperties.class) @Import({RetryConfigurationOnMissingBean.class, FallbackConfigurationOnMissingBean.class}) public class RetryAutoConfiguration { + @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public RetryEndpoint retryEndpoint(RetryRegistry retryRegistry) { return new RetryEndpoint(retryRegistry); } @Bean @ConditionalOnEnabledEndpoint + @ConditionalOnClass(value = {Endpoint.class}) public RetryEventsEndpoint retryEventsEndpoint(EventConsumerRegistry eventConsumerRegistry) { return new RetryEventsEndpoint(eventConsumerRegistry); }