diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpoint.java index 5f5888ab3d0..a4384a7ddd3 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpoint.java @@ -23,7 +23,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.context.annotation.Conditional; /** @@ -33,7 +33,7 @@ import org.springframework.context.annotation.Conditional; *

* If no specific {@code endpoints..*} or {@code endpoints.default.*} properties are * defined, the condition matches the {@code enabledByDefault} value regardless of the - * specific {@link EndpointDelivery}, if any. If any property are set, they are evaluated + * specific {@link EndpointExposure}, if any. If any property are set, they are evaluated * with a sensible order of precedence. *

* For instance if {@code endpoints.default.enabled} is {@code false} but diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/OnEnabledEndpointCondition.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/OnEnabledEndpointCondition.java index b0fc06a28ab..0b85d557f42 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/OnEnabledEndpointCondition.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/OnEnabledEndpointCondition.java @@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.jmx.JmxEndpointExtension; import org.springframework.boot.endpoint.web.WebEndpointExtension; import org.springframework.context.annotation.Bean; @@ -104,10 +104,10 @@ class OnEnabledEndpointCondition extends SpringBootCondition { if (endpoint == null) { return null; } - // If both types are set, all delivery technologies are exposed - EndpointDelivery[] delivery = endpoint.delivery(); + // If both types are set, all exposure technologies are exposed + EndpointExposure[] exposures = endpoint.exposure(); return new EndpointAttributes(endpoint.id(), endpoint.enabledByDefault(), - (delivery.length == 1 ? delivery[0] : null)); + (exposures.length == 1 ? exposures[0] : null)); } private static class EndpointAttributes { @@ -116,19 +116,19 @@ class OnEnabledEndpointCondition extends SpringBootCondition { private final boolean enabled; - private final EndpointDelivery delivery; + private final EndpointExposure exposure; - EndpointAttributes(String id, boolean enabled, EndpointDelivery delivery) { + EndpointAttributes(String id, boolean enabled, EndpointExposure exposure) { if (!StringUtils.hasText(id)) { throw new IllegalStateException("Endpoint id could not be determined"); } this.id = id; this.enabled = enabled; - this.delivery = delivery; + this.exposure = exposure; } public EndpointEnablement getEnablement(EndpointEnablementProvider provider) { - return provider.getEndpointEnablement(this.id, this.enabled, this.delivery); + return provider.getEndpointEnablement(this.id, this.enabled, this.exposure); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointInfrastructureAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointInfrastructureAutoConfiguration.java index 16310bdab94..54aa880c1d3 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointInfrastructureAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointInfrastructureAutoConfiguration.java @@ -34,7 +34,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplicat import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.endpoint.ConversionServiceOperationParameterMapper; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.OperationParameterMapper; import org.springframework.boot.endpoint.jmx.EndpointMBeanRegistrar; import org.springframework.boot.endpoint.jmx.JmxAnnotationEndpointDiscoverer; @@ -102,7 +102,7 @@ public class EndpointInfrastructureAutoConfiguration { ObjectProvider objectMapper) { EndpointProvider endpointProvider = new EndpointProvider<>( this.applicationContext.getEnvironment(), endpointDiscoverer, - EndpointDelivery.JMX); + EndpointExposure.JMX); EndpointMBeanRegistrar endpointMBeanRegistrar = new EndpointMBeanRegistrar( mBeanServer, new DefaultEndpointObjectNameFactory(properties, mBeanServer, ObjectUtils.getIdentityHexString(this.applicationContext))); @@ -127,7 +127,7 @@ public class EndpointInfrastructureAutoConfiguration { return new EndpointProvider<>(this.applicationContext.getEnvironment(), webEndpointDiscoverer(operationParameterMapper, cachingConfigurationFactory), - EndpointDelivery.WEB); + EndpointExposure.WEB); } private WebAnnotationEndpointDiscoverer webEndpointDiscoverer( diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointProvider.java index bc60c2c6e4b..d628186d315 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/infrastructure/EndpointProvider.java @@ -20,8 +20,8 @@ import java.util.Collection; import java.util.stream.Collectors; import org.springframework.boot.actuate.autoconfigure.endpoint.support.EndpointEnablementProvider; -import org.springframework.boot.endpoint.EndpointDelivery; import org.springframework.boot.endpoint.EndpointDiscoverer; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.EndpointInfo; import org.springframework.boot.endpoint.Operation; import org.springframework.core.env.Environment; @@ -40,19 +40,19 @@ public final class EndpointProvider { private final EndpointEnablementProvider endpointEnablementProvider; - private final EndpointDelivery delivery; + private final EndpointExposure exposure; /** * Creates a new instance. * @param environment the environment to use to check the endpoints that are enabled * @param discoverer the discoverer to get the initial set of endpoints - * @param delivery the delivery technology for the endpoint + * @param exposure the exposure technology for the endpoint */ public EndpointProvider(Environment environment, EndpointDiscoverer discoverer, - EndpointDelivery delivery) { + EndpointExposure exposure) { this.discoverer = discoverer; this.endpointEnablementProvider = new EndpointEnablementProvider(environment); - this.delivery = delivery; + this.exposure = exposure; } public Collection> getEndpoints() { @@ -62,7 +62,7 @@ public final class EndpointProvider { private boolean isEnabled(EndpointInfo endpoint) { return this.endpointEnablementProvider.getEndpointEnablement(endpoint.getId(), - endpoint.isEnabledByDefault(), this.delivery).isEnabled(); + endpoint.isEnabledByDefault(), this.exposure).isEnabled(); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProvider.java index 47aac5f193c..7dd2db425ce 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProvider.java @@ -16,7 +16,7 @@ package org.springframework.boot.actuate.autoconfigure.endpoint.support; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.core.env.Environment; import org.springframework.util.Assert; @@ -54,16 +54,16 @@ public class EndpointEnablementProvider { * Return the {@link EndpointEnablement} of an endpoint for a specific tech exposure. * @param endpointId the id of the endpoint * @param enabledByDefault whether the endpoint is enabled by default or not - * @param delivery the requested {@link EndpointDelivery} + * @param exposure the requested {@link EndpointExposure} * @return the {@link EndpointEnablement} of that endpoint for the specified - * {@link EndpointDelivery} + * {@link EndpointExposure} */ public EndpointEnablement getEndpointEnablement(String endpointId, - boolean enabledByDefault, EndpointDelivery delivery) { + boolean enabledByDefault, EndpointExposure exposure) { Assert.hasText(endpointId, "Endpoint id must have a value"); Assert.isTrue(!endpointId.equals("default"), "Endpoint id 'default' is a reserved " + "value and cannot be used by an endpoint"); - EndpointEnablement result = findEnablement(endpointId, delivery); + EndpointEnablement result = findEnablement(endpointId, exposure); if (result != null) { return result; } @@ -74,23 +74,23 @@ public class EndpointEnablementProvider { // All endpoints specific attributes have been looked at. Checking default value // for the endpoint if (!enabledByDefault) { - return getDefaultEndpointEnablement(endpointId, false, delivery); + return getDefaultEndpointEnablement(endpointId, false, exposure); } return getGlobalEndpointEnablement(endpointId, enabledByDefault, - delivery); + exposure); } private EndpointEnablement findEnablement(String endpointId, - EndpointDelivery delivery) { - if (delivery != null) { - return findEnablement(getKey(endpointId, delivery)); + EndpointExposure exposure) { + if (exposure != null) { + return findEnablement(getKey(endpointId, exposure)); } - return findEnablementForAnyDeliveryTechnology(endpointId); + return findEnablementForAnyExposureTechnology(endpointId); } private EndpointEnablement getGlobalEndpointEnablement(String endpointId, - boolean enabledByDefault, EndpointDelivery delivery) { - EndpointEnablement result = findGlobalEndpointEnablement(delivery); + boolean enabledByDefault, EndpointExposure exposure) { + EndpointEnablement result = findGlobalEndpointEnablement(exposure); if (result != null) { return result; } @@ -99,27 +99,27 @@ public class EndpointEnablementProvider { return result; } return getDefaultEndpointEnablement(endpointId, enabledByDefault, - delivery); + exposure); } private EndpointEnablement findGlobalEndpointEnablement( - EndpointDelivery delivery) { - if (delivery != null) { - EndpointEnablement result = findEnablement(getKey("default", delivery)); + EndpointExposure exposure) { + if (exposure != null) { + EndpointEnablement result = findEnablement(getKey("default", exposure)); if (result != null) { return result; } - if (!delivery.isEnabledByDefault()) { - return getDefaultEndpointEnablement("default", false, delivery); + if (!exposure.isEnabledByDefault()) { + return getDefaultEndpointEnablement("default", false, exposure); } return null; } - return findEnablementForAnyDeliveryTechnology("default"); + return findEnablementForAnyExposureTechnology("default"); } - private EndpointEnablement findEnablementForAnyDeliveryTechnology(String endpointId) { - for (EndpointDelivery candidate : EndpointDelivery.values()) { - EndpointEnablement result = findEnablementForDeliveryTechnology(endpointId, + private EndpointEnablement findEnablementForAnyExposureTechnology(String endpointId) { + for (EndpointExposure candidate : EndpointExposure.values()) { + EndpointEnablement result = findEnablementForExposureTechnology(endpointId, candidate); if (result != null && result.isEnabled()) { return result; @@ -128,34 +128,33 @@ public class EndpointEnablementProvider { return null; } - private EndpointEnablement findEnablementForDeliveryTechnology(String endpointId, - EndpointDelivery delivery) { - String endpointTypeKey = getKey(endpointId, delivery); - EndpointEnablement endpointTypeSpecificOutcome = findEnablement(endpointTypeKey); - return endpointTypeSpecificOutcome; + private EndpointEnablement findEnablementForExposureTechnology(String endpointId, + EndpointExposure exposure) { + String endpointTypeKey = getKey(endpointId, exposure); + return findEnablement(endpointTypeKey); } private EndpointEnablement getDefaultEndpointEnablement(String endpointId, - boolean enabledByDefault, EndpointDelivery delivery) { + boolean enabledByDefault, EndpointExposure exposure) { return new EndpointEnablement(enabledByDefault, createDefaultEnablementMessage( - endpointId, enabledByDefault, delivery)); + endpointId, enabledByDefault, exposure)); } private String createDefaultEnablementMessage(String endpointId, - boolean enabledByDefault, EndpointDelivery delivery) { + boolean enabledByDefault, EndpointExposure exposure) { StringBuilder message = new StringBuilder(); message.append(String.format("endpoint '%s' ", endpointId)); - if (delivery != null) { + if (exposure != null) { message.append( - String.format("(%s) ", delivery.name().toLowerCase())); + String.format("(%s) ", exposure.name().toLowerCase())); } message.append(String.format("is %s by default", (enabledByDefault ? "enabled" : "disabled"))); return message.toString(); } - private String getKey(String endpointId, EndpointDelivery delivery) { - return getKey(endpointId, delivery.name().toLowerCase() + ".enabled"); + private String getKey(String endpointId, EndpointExposure exposure) { + return getKey(endpointId, exposure.name().toLowerCase() + ".enabled"); } private String getKey(String endpointId, String suffix) { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/HeapDumpWebEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/HeapDumpWebEndpoint.java index ee39d39de24..2a04c0a0a15 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/HeapDumpWebEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/HeapDumpWebEndpoint.java @@ -36,7 +36,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.ReadOperation; import org.springframework.boot.endpoint.web.WebEndpointResponse; import org.springframework.core.io.FileSystemResource; @@ -55,7 +55,7 @@ import org.springframework.util.ReflectionUtils; * @since 2.0.0 */ @ConfigurationProperties(prefix = "endpoints.heapdump") -@Endpoint(id = "heapdump", delivery = EndpointDelivery.WEB) +@Endpoint(id = "heapdump", exposure = EndpointExposure.WEB) public class HeapDumpWebEndpoint { private final long timeout; diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/LogFileWebEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/LogFileWebEndpoint.java index 74a55e0fee4..cbf29a08ef9 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/LogFileWebEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/LogFileWebEndpoint.java @@ -23,7 +23,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.ReadOperation; import org.springframework.boot.logging.LogFile; import org.springframework.core.env.Environment; @@ -39,7 +39,7 @@ import org.springframework.core.io.Resource; * @since 2.0.0 */ @ConfigurationProperties(prefix = "endpoints.logfile") -@Endpoint(id = "logfile", delivery = EndpointDelivery.WEB) +@Endpoint(id = "logfile", exposure = EndpointExposure.WEB) public class LogFileWebEndpoint { private static final Log logger = LogFactory.getLog(LogFileWebEndpoint.class); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpointTests.java index 3ae081eeeb3..00f7fc004d7 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/ConditionalOnEnabledEndpointTests.java @@ -19,7 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.endpoint; import org.junit.Test; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.jmx.JmxEndpointExtension; import org.springframework.boot.endpoint.web.WebEndpointExtension; import org.springframework.boot.test.context.runner.ApplicationContextRunner; @@ -297,8 +297,8 @@ public class ConditionalOnEnabledEndpointTests { } - @Endpoint(id = "bar", delivery = { EndpointDelivery.WEB, - EndpointDelivery.JMX }, enabledByDefault = false) + @Endpoint(id = "bar", exposure = { EndpointExposure.WEB, + EndpointExposure.JMX }, enabledByDefault = false) static class BarEndpoint { } @@ -314,7 +314,7 @@ public class ConditionalOnEnabledEndpointTests { } - @Endpoint(id = "onlyweb", delivery = EndpointDelivery.WEB) + @Endpoint(id = "onlyweb", exposure = EndpointExposure.WEB) static class OnlyWebEndpoint { } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProviderTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProviderTests.java index 91fa808ed27..f07360eac7f 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProviderTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/support/EndpointEnablementProviderTests.java @@ -20,7 +20,7 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.mock.env.MockEnvironment; import org.springframework.util.ObjectUtils; @@ -188,42 +188,42 @@ public class EndpointEnablementProviderTests { @Test public void specificEnabledByDefault() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.JMX); + EndpointExposure.JMX); validate(enablement, true, "endpoint 'foo' (jmx) is enabled by default"); } @Test public void specificDisabledViaEndpointProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.foo.enabled=false"); + EndpointExposure.WEB, "endpoints.foo.enabled=false"); validate(enablement, false, "found property endpoints.foo.enabled"); } @Test public void specificDisabledViaTechProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.foo.web.enabled=false"); + EndpointExposure.WEB, "endpoints.foo.web.enabled=false"); validate(enablement, false, "found property endpoints.foo.web.enabled"); } @Test public void specificNotDisabledViaUnrelatedTechProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.JMX, "endpoints.foo.web.enabled=false"); + EndpointExposure.JMX, "endpoints.foo.web.enabled=false"); validate(enablement, true, "endpoint 'foo' (jmx) is enabled by default"); } @Test public void specificDisabledViaGeneralProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.JMX, "endpoints.default.enabled=false"); + EndpointExposure.JMX, "endpoints.default.enabled=false"); validate(enablement, false, "found property endpoints.default.enabled"); } @Test public void specificEnabledOverrideViaEndpointProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.default.enabled=false", + EndpointExposure.WEB, "endpoints.default.enabled=false", "endpoints.foo.enabled=true"); validate(enablement, true, "found property endpoints.foo.enabled"); } @@ -231,7 +231,7 @@ public class EndpointEnablementProviderTests { @Test public void specificEnabledOverrideViaTechProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.foo.enabled=false", + EndpointExposure.WEB, "endpoints.foo.enabled=false", "endpoints.foo.web.enabled=true"); validate(enablement, true, "found property endpoints.foo.web.enabled"); } @@ -239,7 +239,7 @@ public class EndpointEnablementProviderTests { @Test public void specificEnabledOverrideHasNotEffectWithUnrelatedTechProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.foo.enabled=false", + EndpointExposure.WEB, "endpoints.foo.enabled=false", "endpoints.foo.jmx.enabled=true"); validate(enablement, false, "found property endpoints.foo.enabled"); } @@ -247,7 +247,7 @@ public class EndpointEnablementProviderTests { @Test public void specificEnabledOverrideViaGeneralWebProperty() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.default.enabled=false", + EndpointExposure.WEB, "endpoints.default.enabled=false", "endpoints.default.web.enabled=true"); validate(enablement, true, "found property endpoints.default.web.enabled"); } @@ -255,7 +255,7 @@ public class EndpointEnablementProviderTests { @Test public void specificEnabledOverrideHasNoEffectWithUnrelatedTechProperty() { validate( - getEndpointEnablement("foo", true, EndpointDelivery.JMX, + getEndpointEnablement("foo", true, EndpointExposure.JMX, "endpoints.default.enabled=false", "endpoints.default.web.enabled=true"), false, "found property endpoints.default.enabled"); } @@ -263,7 +263,7 @@ public class EndpointEnablementProviderTests { @Test public void specificDisabledWithEndpointPropertyEvenWithEnabledGeneralProperties() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.default.enabled=true", + EndpointExposure.WEB, "endpoints.default.enabled=true", "endpoints.default.web.enabled=true", "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=false"); validate(enablement, false, "found property endpoints.foo.enabled"); @@ -272,7 +272,7 @@ public class EndpointEnablementProviderTests { @Test public void specificDisabledWithTechPropertyEvenWithEnabledGeneralProperties() { EndpointEnablement enablement = getEndpointEnablement("foo", true, - EndpointDelivery.WEB, "endpoints.default.enabled=true", + EndpointExposure.WEB, "endpoints.default.enabled=true", "endpoints.default.web.enabled=true", "endpoints.default.jmx.enabled=true", "endpoints.foo.enabled=true", "endpoints.foo.web.enabled=false"); validate(enablement, false, "found property endpoints.foo.web.enabled"); @@ -281,49 +281,49 @@ public class EndpointEnablementProviderTests { @Test public void specificDisabledByDefaultWithAnnotationFlag() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB); + EndpointExposure.WEB); validate(enablement, false, "endpoint 'bar' (web) is disabled by default"); } @Test public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.default.enabled=true"); + EndpointExposure.WEB, "endpoints.default.enabled=true"); validate(enablement, false, "endpoint 'bar' (web) is disabled by default"); } @Test public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralWebProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.default.web.enabled=true"); + EndpointExposure.WEB, "endpoints.default.web.enabled=true"); validate(enablement, false, "endpoint 'bar' (web) is disabled by default"); } @Test public void specificDisabledByDefaultWithAnnotationFlagEvenWithGeneralJmxProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.default.jmx.enabled=true"); + EndpointExposure.WEB, "endpoints.default.jmx.enabled=true"); validate(enablement, false, "endpoint 'bar' (web) is disabled by default"); } @Test public void specificEnabledOverrideWithAndAnnotationFlagAndEndpointProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.bar.enabled=true"); + EndpointExposure.WEB, "endpoints.bar.enabled=true"); validate(enablement, true, "found property endpoints.bar.enabled"); } @Test public void specificEnabledOverrideWithAndAnnotationFlagAndTechProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.bar.web.enabled=true"); + EndpointExposure.WEB, "endpoints.bar.web.enabled=true"); validate(enablement, true, "found property endpoints.bar.web.enabled"); } @Test public void specificEnabledOverrideWithAndAnnotationFlagHasNoEffectWithUnrelatedTechProperty() { EndpointEnablement enablement = getEndpointEnablement("bar", false, - EndpointDelivery.WEB, "endpoints.bar.jmx.enabled=true"); + EndpointExposure.WEB, "endpoints.bar.jmx.enabled=true"); validate(enablement, false, "endpoint 'bar' (web) is disabled by default"); } @@ -333,11 +333,11 @@ public class EndpointEnablementProviderTests { } private EndpointEnablement getEndpointEnablement(String id, boolean enabledByDefault, - EndpointDelivery delivery, String... environment) { + EndpointExposure exposure, String... environment) { MockEnvironment env = new MockEnvironment(); TestPropertyValues.of(environment).applyTo(env); EndpointEnablementProvider provider = new EndpointEnablementProvider(env); - return provider.getEndpointEnablement(id, enabledByDefault, delivery); + return provider.getEndpointEnablement(id, enabledByDefault, exposure); } private void validate(EndpointEnablement enablement, boolean enabled, diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/AnnotationEndpointDiscoverer.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/AnnotationEndpointDiscoverer.java index 4a47c0d802e..d66638d9b8d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/AnnotationEndpointDiscoverer.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/AnnotationEndpointDiscoverer.java @@ -70,15 +70,15 @@ public abstract class AnnotationEndpointDiscoverer /** * Perform endpoint discovery, including discovery and merging of extensions. * @param extensionType the annotation type of the extension - * @param delivery the {@link EndpointDelivery} that should be considered + * @param exposure the {@link EndpointExposure} that should be considered * @return the list of {@link EndpointInfo EndpointInfos} that describes the - * discovered endpoints matching the specified {@link EndpointDelivery} + * discovered endpoints matching the specified {@link EndpointExposure} */ protected Collection> discoverEndpoints( - Class extensionType, EndpointDelivery delivery) { - Map, EndpointInfo> endpoints = discoverEndpoints(delivery); + Class extensionType, EndpointExposure exposure) { + Map, EndpointInfo> endpoints = discoverEndpoints(exposure); Map, EndpointExtensionInfo> extensions = discoverExtensions(endpoints, - extensionType, delivery); + extensionType, exposure); Collection> result = new ArrayList<>(); endpoints.forEach((endpointClass, endpointInfo) -> { EndpointExtensionInfo extension = extensions.remove(endpointClass); @@ -87,7 +87,7 @@ public abstract class AnnotationEndpointDiscoverer return result; } - private Map, EndpointInfo> discoverEndpoints(EndpointDelivery delivery) { + private Map, EndpointInfo> discoverEndpoints(EndpointExposure exposure) { String[] beanNames = this.applicationContext .getBeanNamesForAnnotation(Endpoint.class); Map, EndpointInfo> endpoints = new LinkedHashMap<>(); @@ -96,7 +96,7 @@ public abstract class AnnotationEndpointDiscoverer Class beanType = this.applicationContext.getType(beanName); AnnotationAttributes attributes = AnnotatedElementUtils .findMergedAnnotationAttributes(beanType, Endpoint.class, true, true); - if (isDeliveredOver(attributes, delivery)) { + if (isExposedOver(attributes, exposure)) { EndpointInfo info = createEndpointInfo(beanName, beanType, attributes); EndpointInfo previous = endpointsById.putIfAbsent(info.getId(), info); Assert.state(previous == null, () -> "Found two endpoints with the id '" @@ -117,7 +117,7 @@ public abstract class AnnotationEndpointDiscoverer private Map, EndpointExtensionInfo> discoverExtensions( Map, EndpointInfo> endpoints, - Class extensionType, EndpointDelivery delivery) { + Class extensionType, EndpointExposure delivery) { if (extensionType == null) { return Collections.emptyMap(); } @@ -129,7 +129,7 @@ public abstract class AnnotationEndpointDiscoverer Class endpointType = getEndpointType(extensionType, beanType); AnnotationAttributes endpointAttributes = AnnotatedElementUtils .getMergedAnnotationAttributes(endpointType, Endpoint.class); - Assert.state(isDeliveredOver(endpointAttributes, delivery), + Assert.state(isExposedOver(endpointAttributes, delivery), "Invalid extension " + beanType.getName() + "': endpoint '" + endpointType.getName() + "' does not support such extension"); @@ -199,14 +199,14 @@ public abstract class AnnotationEndpointDiscoverer return result; } - private boolean isDeliveredOver(AnnotationAttributes attributes, - EndpointDelivery delivery) { - if (delivery == null) { + private boolean isExposedOver(AnnotationAttributes attributes, + EndpointExposure exposure) { + if (exposure == null) { return true; } - EndpointDelivery[] supported = (EndpointDelivery[]) attributes.get("delivery"); + EndpointExposure[] supported = (EndpointExposure[]) attributes.get("exposure"); return ObjectUtils.isEmpty(supported) - || ObjectUtils.containsElement(supported, delivery); + || ObjectUtils.containsElement(supported, exposure); } private Map discoverOperations(String id, String name, Class type) { diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/Endpoint.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/Endpoint.java index e98f8b97858..451b9684fcb 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/Endpoint.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/Endpoint.java @@ -41,11 +41,11 @@ public @interface Endpoint { String id(); /** - * Defines the {@link EndpointDelivery delivery technologies} over which the - * endpoint should be delivered over. By default, all technologies are supported. - * @return the supported endpoint delivery technologies + * Defines the {@link EndpointExposure technologies} over which the endpoint should be + * exposed. By default, all technologies are supported. + * @return the supported endpoint exposure technologies */ - EndpointDelivery[] delivery() default {}; + EndpointExposure[] exposure() default {}; /** * Whether or not the endpoint is enabled by default. diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointDelivery.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointExposure.java similarity index 87% rename from spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointDelivery.java rename to spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointExposure.java index df75b3e4ef6..bf86f0618d7 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointDelivery.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/EndpointExposure.java @@ -17,12 +17,12 @@ package org.springframework.boot.endpoint; /** - * An enumeration of the available {@link Endpoint} delivery technologies. + * An enumeration of the available {@link Endpoint} exposure technologies. * * @author Stephane Nicoll * @since 2.0.0 */ -public enum EndpointDelivery { +public enum EndpointExposure { /** * Expose the endpoint as a JMX MBean. @@ -36,7 +36,7 @@ public enum EndpointDelivery { private final boolean enabledByDefault; - EndpointDelivery(boolean enabledByDefault) { + EndpointExposure(boolean enabledByDefault) { this.enabledByDefault = enabledByDefault; } diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscoverer.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscoverer.java index f56f2f3f7c9..91a6d1adad5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscoverer.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscoverer.java @@ -31,7 +31,7 @@ import org.springframework.boot.endpoint.AnnotationEndpointDiscoverer; import org.springframework.boot.endpoint.CachingConfiguration; import org.springframework.boot.endpoint.CachingOperationInvoker; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.EndpointInfo; import org.springframework.boot.endpoint.OperationInvoker; import org.springframework.boot.endpoint.OperationParameterMapper; @@ -76,7 +76,7 @@ public class JmxAnnotationEndpointDiscoverer @Override public Collection> discoverEndpoints() { Collection> endpointDescriptors = discoverEndpoints( - JmxEndpointExtension.class, EndpointDelivery.JMX); + JmxEndpointExtension.class, EndpointExposure.JMX); verifyThatOperationsHaveDistinctName(endpointDescriptors); return endpointDescriptors.stream().map(EndpointInfoDescriptor::getEndpointInfo) .collect(Collectors.toList()); diff --git a/spring-boot/src/main/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscoverer.java b/spring-boot/src/main/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscoverer.java index 85ce0017c77..15fd546eb6a 100644 --- a/spring-boot/src/main/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscoverer.java +++ b/spring-boot/src/main/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscoverer.java @@ -31,7 +31,7 @@ import org.springframework.boot.endpoint.AnnotationEndpointDiscoverer; import org.springframework.boot.endpoint.CachingConfiguration; import org.springframework.boot.endpoint.CachingOperationInvoker; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.EndpointInfo; import org.springframework.boot.endpoint.OperationInvoker; import org.springframework.boot.endpoint.OperationParameterMapper; @@ -80,7 +80,7 @@ public class WebAnnotationEndpointDiscoverer extends @Override public Collection> discoverEndpoints() { Collection> endpoints = discoverEndpoints( - WebEndpointExtension.class, EndpointDelivery.WEB); + WebEndpointExtension.class, EndpointExposure.WEB); verifyThatOperationsHaveDistinctPredicates(endpoints); return endpoints.stream().map(EndpointInfoDescriptor::getEndpointInfo) .collect(Collectors.toList()); diff --git a/spring-boot/src/test/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscovererTests.java b/spring-boot/src/test/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscovererTests.java index 0a8073abc23..95ad8e97e7d 100644 --- a/spring-boot/src/test/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscovererTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/endpoint/jmx/JmxAnnotationEndpointDiscovererTests.java @@ -31,7 +31,7 @@ import org.springframework.boot.endpoint.CachingConfiguration; import org.springframework.boot.endpoint.CachingOperationInvoker; import org.springframework.boot.endpoint.ConversionServiceOperationParameterMapper; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.EndpointInfo; import org.springframework.boot.endpoint.ReadOperation; import org.springframework.boot.endpoint.ReflectiveOperationInvoker; @@ -331,7 +331,7 @@ public class JmxAnnotationEndpointDiscovererTests { } - @Endpoint(id = "jmx", delivery = EndpointDelivery.JMX) + @Endpoint(id = "jmx", exposure = EndpointExposure.JMX) private static class TestJmxEndpoint { @ReadOperation @@ -410,7 +410,7 @@ public class JmxAnnotationEndpointDiscovererTests { } - @Endpoint(id = "nonjmx", delivery = EndpointDelivery.WEB) + @Endpoint(id = "nonjmx", exposure = EndpointExposure.WEB) private static class NonJmxEndpoint { @ReadOperation diff --git a/spring-boot/src/test/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscovererTests.java b/spring-boot/src/test/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscovererTests.java index cad8296c020..137cc3c0873 100644 --- a/spring-boot/src/test/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscovererTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/endpoint/web/WebAnnotationEndpointDiscovererTests.java @@ -37,7 +37,7 @@ import org.springframework.boot.endpoint.CachingConfiguration; import org.springframework.boot.endpoint.CachingOperationInvoker; import org.springframework.boot.endpoint.ConversionServiceOperationParameterMapper; import org.springframework.boot.endpoint.Endpoint; -import org.springframework.boot.endpoint.EndpointDelivery; +import org.springframework.boot.endpoint.EndpointExposure; import org.springframework.boot.endpoint.EndpointInfo; import org.springframework.boot.endpoint.OperationInvoker; import org.springframework.boot.endpoint.ReadOperation; @@ -375,7 +375,7 @@ public class WebAnnotationEndpointDiscovererTests { } - @Endpoint(id = "nonweb", delivery = EndpointDelivery.JMX) + @Endpoint(id = "nonweb", exposure = EndpointExposure.JMX) static class NonWebEndpoint { @ReadOperation