Rename EndpointType to EndpointExposure
Closes gh-10100
This commit is contained in:
@@ -70,15 +70,15 @@ public abstract class AnnotationEndpointDiscoverer<T extends Operation, K>
|
||||
/**
|
||||
* 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<EndpointInfoDescriptor<T, K>> discoverEndpoints(
|
||||
Class<? extends Annotation> extensionType, EndpointDelivery delivery) {
|
||||
Map<Class<?>, EndpointInfo<T>> endpoints = discoverEndpoints(delivery);
|
||||
Class<? extends Annotation> extensionType, EndpointExposure exposure) {
|
||||
Map<Class<?>, EndpointInfo<T>> endpoints = discoverEndpoints(exposure);
|
||||
Map<Class<?>, EndpointExtensionInfo<T>> extensions = discoverExtensions(endpoints,
|
||||
extensionType, delivery);
|
||||
extensionType, exposure);
|
||||
Collection<EndpointInfoDescriptor<T, K>> result = new ArrayList<>();
|
||||
endpoints.forEach((endpointClass, endpointInfo) -> {
|
||||
EndpointExtensionInfo<T> extension = extensions.remove(endpointClass);
|
||||
@@ -87,7 +87,7 @@ public abstract class AnnotationEndpointDiscoverer<T extends Operation, K>
|
||||
return result;
|
||||
}
|
||||
|
||||
private Map<Class<?>, EndpointInfo<T>> discoverEndpoints(EndpointDelivery delivery) {
|
||||
private Map<Class<?>, EndpointInfo<T>> discoverEndpoints(EndpointExposure exposure) {
|
||||
String[] beanNames = this.applicationContext
|
||||
.getBeanNamesForAnnotation(Endpoint.class);
|
||||
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);
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils
|
||||
.findMergedAnnotationAttributes(beanType, Endpoint.class, true, true);
|
||||
if (isDeliveredOver(attributes, delivery)) {
|
||||
if (isExposedOver(attributes, exposure)) {
|
||||
EndpointInfo<T> info = createEndpointInfo(beanName, beanType, attributes);
|
||||
EndpointInfo<T> previous = endpointsById.putIfAbsent(info.getId(), info);
|
||||
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(
|
||||
Map<Class<?>, EndpointInfo<T>> endpoints,
|
||||
Class<? extends Annotation> extensionType, EndpointDelivery delivery) {
|
||||
Class<? extends Annotation> extensionType, EndpointExposure delivery) {
|
||||
if (extensionType == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public abstract class AnnotationEndpointDiscoverer<T extends Operation, K>
|
||||
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<T extends Operation, K>
|
||||
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<Method, T> discoverOperations(String id, String name, Class<?> type) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<EndpointInfo<JmxEndpointOperation>> discoverEndpoints() {
|
||||
Collection<EndpointInfoDescriptor<JmxEndpointOperation, String>> endpointDescriptors = discoverEndpoints(
|
||||
JmxEndpointExtension.class, EndpointDelivery.JMX);
|
||||
JmxEndpointExtension.class, EndpointExposure.JMX);
|
||||
verifyThatOperationsHaveDistinctName(endpointDescriptors);
|
||||
return endpointDescriptors.stream().map(EndpointInfoDescriptor::getEndpointInfo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -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<EndpointInfo<WebEndpointOperation>> discoverEndpoints() {
|
||||
Collection<EndpointInfoDescriptor<WebEndpointOperation, OperationRequestPredicate>> endpoints = discoverEndpoints(
|
||||
WebEndpointExtension.class, EndpointDelivery.WEB);
|
||||
WebEndpointExtension.class, EndpointExposure.WEB);
|
||||
verifyThatOperationsHaveDistinctPredicates(endpoints);
|
||||
return endpoints.stream().map(EndpointInfoDescriptor::getEndpointInfo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user