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