Merge branch '2.7.x' into 3.0.x
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ public class RabbitHealthIndicator extends AbstractHealthIndicator {
|
||||
|
||||
private String getVersion() {
|
||||
return this.rabbitTemplate
|
||||
.execute((channel) -> channel.getConnection().getServerProperties().get("version").toString());
|
||||
.execute((channel) -> channel.getConnection().getServerProperties().get("version").toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,14 +109,22 @@ public class CachesEndpoint {
|
||||
|
||||
private List<CacheEntryDescriptor> getCacheEntries(Predicate<String> cacheNamePredicate,
|
||||
Predicate<String> cacheManagerNamePredicate) {
|
||||
return this.cacheManagers.keySet().stream().filter(cacheManagerNamePredicate)
|
||||
.flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream()).toList();
|
||||
return this.cacheManagers.keySet()
|
||||
.stream()
|
||||
.filter(cacheManagerNamePredicate)
|
||||
.flatMap((cacheManagerName) -> getCacheEntries(cacheManagerName, cacheNamePredicate).stream())
|
||||
.toList();
|
||||
}
|
||||
|
||||
private List<CacheEntryDescriptor> getCacheEntries(String cacheManagerName, Predicate<String> cacheNamePredicate) {
|
||||
CacheManager cacheManager = this.cacheManagers.get(cacheManagerName);
|
||||
return cacheManager.getCacheNames().stream().filter(cacheNamePredicate).map(cacheManager::getCache)
|
||||
.filter(Objects::nonNull).map((cache) -> new CacheEntryDescriptor(cache, cacheManagerName)).toList();
|
||||
return cacheManager.getCacheNames()
|
||||
.stream()
|
||||
.filter(cacheNamePredicate)
|
||||
.map(cacheManager::getCache)
|
||||
.filter(Objects::nonNull)
|
||||
.map((cache) -> new CacheEntryDescriptor(cache, cacheManagerName))
|
||||
.toList();
|
||||
}
|
||||
|
||||
private CacheEntryDescriptor extractUniqueCacheEntry(String cache, List<CacheEntryDescriptor> entries) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -189,8 +189,8 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||
|
||||
private void applyConfigurationPropertiesFilter(JsonMapper.Builder builder) {
|
||||
builder.annotationIntrospector(new ConfigurationPropertiesAnnotationIntrospector());
|
||||
builder.filterProvider(
|
||||
new SimpleFilterProvider().setDefaultFilter(new ConfigurationPropertiesPropertyFilter()));
|
||||
builder
|
||||
.filterProvider(new SimpleFilterProvider().setDefaultFilter(new ConfigurationPropertiesPropertyFilter()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,16 +199,18 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||
*/
|
||||
private void applySerializationModifier(JsonMapper.Builder builder) {
|
||||
SerializerFactory factory = BeanSerializerFactory.instance
|
||||
.withSerializerModifier(new GenericSerializerModifier());
|
||||
.withSerializerModifier(new GenericSerializerModifier());
|
||||
builder.serializerFactory(factory);
|
||||
}
|
||||
|
||||
private ContextConfigurationPropertiesDescriptor describeBeans(ObjectMapper mapper, ApplicationContext context,
|
||||
Predicate<ConfigurationPropertiesBean> beanFilterPredicate, boolean showUnsanitized) {
|
||||
Map<String, ConfigurationPropertiesBean> beans = ConfigurationPropertiesBean.getAll(context);
|
||||
Map<String, ConfigurationPropertiesBeanDescriptor> descriptors = beans.values().stream()
|
||||
.filter(beanFilterPredicate).collect(Collectors.toMap(ConfigurationPropertiesBean::getName,
|
||||
(bean) -> describeBean(mapper, bean, showUnsanitized)));
|
||||
Map<String, ConfigurationPropertiesBeanDescriptor> descriptors = beans.values()
|
||||
.stream()
|
||||
.filter(beanFilterPredicate)
|
||||
.collect(Collectors.toMap(ConfigurationPropertiesBean::getName,
|
||||
(bean) -> describeBean(mapper, bean, showUnsanitized)));
|
||||
return new ContextConfigurationPropertiesDescriptor(descriptors,
|
||||
(context.getParent() != null) ? context.getParent().getId() : null);
|
||||
}
|
||||
@@ -508,9 +510,10 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext
|
||||
names = new String[parameters.length];
|
||||
}
|
||||
for (int i = 0; i < parameters.length; i++) {
|
||||
String name = MergedAnnotations.from(parameters[i]).get(Name.class)
|
||||
.getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse((names[i] != null) ? names[i] : parameters[i].getName());
|
||||
String name = MergedAnnotations.from(parameters[i])
|
||||
.get(Name.class)
|
||||
.getValue(MergedAnnotation.VALUE, String.class)
|
||||
.orElse((names[i] != null) ? names[i] : parameters[i].getName());
|
||||
if (name.equals(writer.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,8 +61,10 @@ public class ConfigurationPropertiesReportEndpointWebExtension {
|
||||
boolean showUnsanitized = this.showValues.isShown(securityContext, this.roles);
|
||||
ConfigurationPropertiesDescriptor configurationProperties = this.delegate.getConfigurationProperties(prefix,
|
||||
showUnsanitized);
|
||||
boolean foundMatchingBeans = configurationProperties.getContexts().values().stream()
|
||||
.anyMatch((context) -> !context.getBeans().isEmpty());
|
||||
boolean foundMatchingBeans = configurationProperties.getContexts()
|
||||
.values()
|
||||
.stream()
|
||||
.anyMatch((context) -> !context.getBeans().isEmpty());
|
||||
return (foundMatchingBeans) ? new WebEndpointResponse<>(configurationProperties, WebEndpointResponse.STATUS_OK)
|
||||
: new WebEndpointResponse<>(WebEndpointResponse.STATUS_NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -42,8 +42,13 @@ class CouchbaseHealth {
|
||||
void applyTo(Builder builder) {
|
||||
builder = isCouchbaseUp(this.diagnostics) ? builder.up() : builder.down();
|
||||
builder.withDetail("sdk", this.diagnostics.sdk());
|
||||
builder.withDetail("endpoints", this.diagnostics.endpoints().values().stream().flatMap(Collection::stream)
|
||||
.map(this::describe).toList());
|
||||
builder.withDetail("endpoints",
|
||||
this.diagnostics.endpoints()
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.map(this::describe)
|
||||
.toList());
|
||||
}
|
||||
|
||||
private boolean isCouchbaseUp(DiagnosticsResult diagnostics) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,12 +54,12 @@ public class RedisReactiveHealthIndicator extends AbstractReactiveHealthIndicato
|
||||
|
||||
private Mono<ReactiveRedisConnection> getConnection() {
|
||||
return Mono.fromSupplier(this.connectionFactory::getReactiveConnection)
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
.subscribeOn(Schedulers.boundedElastic());
|
||||
}
|
||||
|
||||
private Mono<Health> doHealthCheck(Health.Builder builder, ReactiveRedisConnection connection) {
|
||||
return getHealth(builder, connection).onErrorResume((ex) -> Mono.just(builder.down(ex).build()))
|
||||
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
||||
.flatMap((health) -> connection.closeLater().thenReturn(health));
|
||||
}
|
||||
|
||||
private Mono<Health> getHealth(Health.Builder builder, ReactiveRedisConnection connection) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractDiscoveredEndpoint<O extends Operation> extends Ab
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator creator = new ToStringCreator(this).append("discoverer", this.discoverer.getClass().getName())
|
||||
.append("endpointBean", this.endpointBean.getClass().getName());
|
||||
.append("endpointBean", this.endpointBean.getClass().getName());
|
||||
appendFields(creator);
|
||||
return creator.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ public abstract class AbstractDiscoveredOperation implements Operation {
|
||||
@Override
|
||||
public String toString() {
|
||||
ToStringCreator creator = new ToStringCreator(this).append("operationMethod", this.operationMethod)
|
||||
.append("invoker", this.invoker);
|
||||
.append("invoker", this.invoker);
|
||||
appendFields(creator);
|
||||
return creator.toString();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,14 +70,17 @@ abstract class DiscoveredOperationsFactory<O extends Operation> {
|
||||
|
||||
Collection<O> createOperations(EndpointId id, Object target) {
|
||||
return MethodIntrospector
|
||||
.selectMethods(target.getClass(), (MetadataLookup<O>) (method) -> createOperation(id, target, method))
|
||||
.values();
|
||||
.selectMethods(target.getClass(), (MetadataLookup<O>) (method) -> createOperation(id, target, method))
|
||||
.values();
|
||||
}
|
||||
|
||||
private O createOperation(EndpointId endpointId, Object target, Method method) {
|
||||
return OPERATION_TYPES.entrySet().stream()
|
||||
.map((entry) -> createOperation(endpointId, target, method, entry.getKey(), entry.getValue()))
|
||||
.filter(Objects::nonNull).findFirst().orElse(null);
|
||||
return OPERATION_TYPES.entrySet()
|
||||
.stream()
|
||||
.map((entry) -> createOperation(endpointId, target, method, entry.getKey(), entry.getValue()))
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private O createOperation(EndpointId endpointId, Object target, Method method, OperationType operationType,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -148,7 +148,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
|
||||
private void addExtensionBeans(Collection<EndpointBean> endpointBeans) {
|
||||
Map<EndpointId, EndpointBean> byId = endpointBeans.stream()
|
||||
.collect(Collectors.toMap(EndpointBean::getId, Function.identity()));
|
||||
.collect(Collectors.toMap(EndpointBean::getId, Function.identity()));
|
||||
String[] beanNames = BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors(this.applicationContext,
|
||||
EndpointExtension.class);
|
||||
for (String beanName : beanNames) {
|
||||
@@ -190,8 +190,10 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
EndpointId id = endpointBean.getId();
|
||||
addOperations(indexed, id, endpointBean.getBean(), false);
|
||||
if (endpointBean.getExtensions().size() > 1) {
|
||||
String extensionBeans = endpointBean.getExtensions().stream().map(ExtensionBean::getBeanName)
|
||||
.collect(Collectors.joining(", "));
|
||||
String extensionBeans = endpointBean.getExtensions()
|
||||
.stream()
|
||||
.map(ExtensionBean::getBeanName)
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new IllegalStateException("Found multiple extensions for the endpoint bean "
|
||||
+ endpointBean.getBeanName() + " (" + extensionBeans + ")");
|
||||
}
|
||||
@@ -222,12 +224,16 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
}
|
||||
|
||||
private void assertNoDuplicateOperations(EndpointBean endpointBean, MultiValueMap<OperationKey, O> indexed) {
|
||||
List<OperationKey> duplicates = indexed.entrySet().stream().filter((entry) -> entry.getValue().size() > 1)
|
||||
.map(Map.Entry::getKey).toList();
|
||||
List<OperationKey> duplicates = indexed.entrySet()
|
||||
.stream()
|
||||
.filter((entry) -> entry.getValue().size() > 1)
|
||||
.map(Map.Entry::getKey)
|
||||
.toList();
|
||||
if (!duplicates.isEmpty()) {
|
||||
Set<ExtensionBean> extensions = endpointBean.getExtensions();
|
||||
String extensionBeanNames = extensions.stream().map(ExtensionBean::getBeanName)
|
||||
.collect(Collectors.joining(", "));
|
||||
String extensionBeanNames = extensions.stream()
|
||||
.map(ExtensionBean::getBeanName)
|
||||
.collect(Collectors.joining(", "));
|
||||
throw new IllegalStateException("Unable to map duplicate endpoint operations: " + duplicates.toString()
|
||||
+ " to " + endpointBean.getBeanName()
|
||||
+ (extensions.isEmpty() ? "" : " (" + extensionBeanNames + ")"));
|
||||
@@ -296,8 +302,10 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private boolean isFilterMatch(EndpointFilter<E> filter, E endpoint) {
|
||||
return LambdaSafe.callback(EndpointFilter.class, filter, endpoint).withLogger(EndpointDiscoverer.class)
|
||||
.invokeAnd((f) -> f.match(endpoint)).get();
|
||||
return LambdaSafe.callback(EndpointFilter.class, filter, endpoint)
|
||||
.withLogger(EndpointDiscoverer.class)
|
||||
.invokeAnd((f) -> f.match(endpoint))
|
||||
.get();
|
||||
}
|
||||
|
||||
private E getFilterEndpoint(EndpointBean endpointBean) {
|
||||
@@ -409,7 +417,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
|
||||
EndpointBean(Environment environment, String beanName, Class<?> beanType, Supplier<Object> beanSupplier) {
|
||||
MergedAnnotation<Endpoint> annotation = MergedAnnotations.from(beanType, SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(Endpoint.class);
|
||||
.get(Endpoint.class);
|
||||
String id = annotation.getString("id");
|
||||
Assert.state(StringUtils.hasText(id),
|
||||
() -> "No @Endpoint id attribute specified for " + beanType.getName());
|
||||
@@ -430,8 +438,10 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
}
|
||||
|
||||
private Class<?> getFilter(Class<?> type) {
|
||||
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(FilteredEndpoint.class)
|
||||
.getValue(MergedAnnotation.VALUE, Class.class).orElse(null);
|
||||
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(FilteredEndpoint.class)
|
||||
.getValue(MergedAnnotation.VALUE, Class.class)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
String getBeanName() {
|
||||
@@ -480,10 +490,12 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
this.beanType = beanType;
|
||||
this.beanSupplier = beanSupplier;
|
||||
MergedAnnotation<EndpointExtension> extensionAnnotation = MergedAnnotations
|
||||
.from(beanType, SearchStrategy.TYPE_HIERARCHY).get(EndpointExtension.class);
|
||||
.from(beanType, SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(EndpointExtension.class);
|
||||
Class<?> endpointType = extensionAnnotation.getClass("endpoint");
|
||||
MergedAnnotation<Endpoint> endpointAnnotation = MergedAnnotations
|
||||
.from(endpointType, SearchStrategy.TYPE_HIERARCHY).get(Endpoint.class);
|
||||
.from(endpointType, SearchStrategy.TYPE_HIERARCHY)
|
||||
.get(Endpoint.class);
|
||||
Assert.state(endpointAnnotation.isPresent(),
|
||||
() -> "Extension " + endpointType.getName() + " does not specify an endpoint");
|
||||
this.endpointId = EndpointId.of(environment, endpointAnnotation.getString("id"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -39,6 +39,7 @@ import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||
* boolean enableByDefault() default true;
|
||||
*
|
||||
* } </pre>
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 2.0.0
|
||||
* @see DiscovererEndpointFilter
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -75,8 +75,10 @@ public class ReflectiveOperationInvoker implements OperationInvoker {
|
||||
}
|
||||
|
||||
private void validateRequiredParameters(InvocationContext context) {
|
||||
Set<OperationParameter> missing = this.operationMethod.getParameters().stream()
|
||||
.filter((parameter) -> isMissing(context, parameter)).collect(Collectors.toSet());
|
||||
Set<OperationParameter> missing = this.operationMethod.getParameters()
|
||||
.stream()
|
||||
.filter((parameter) -> isMissing(context, parameter))
|
||||
.collect(Collectors.toSet());
|
||||
if (!missing.isEmpty()) {
|
||||
throw new MissingParametersException(missing);
|
||||
}
|
||||
@@ -93,8 +95,10 @@ public class ReflectiveOperationInvoker implements OperationInvoker {
|
||||
}
|
||||
|
||||
private Object[] resolveArguments(InvocationContext context) {
|
||||
return this.operationMethod.getParameters().stream().map((parameter) -> resolveArgument(parameter, context))
|
||||
.toArray();
|
||||
return this.operationMethod.getParameters()
|
||||
.stream()
|
||||
.map((parameter) -> resolveArgument(parameter, context))
|
||||
.toArray();
|
||||
}
|
||||
|
||||
private Object resolveArgument(OperationParameter parameter, InvocationContext context) {
|
||||
@@ -108,8 +112,9 @@ public class ReflectiveOperationInvoker implements OperationInvoker {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("target", this.target).append("method", this.operationMethod)
|
||||
.toString();
|
||||
return new ToStringCreator(this).append("target", this.target)
|
||||
.append("method", this.operationMethod)
|
||||
.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -115,8 +115,10 @@ public class EndpointMBean implements DynamicMBean {
|
||||
|
||||
private Object invoke(JmxOperation operation, Object[] params) throws MBeanException, ReflectionException {
|
||||
try {
|
||||
String[] parameterNames = operation.getParameters().stream().map(JmxOperationParameter::getName)
|
||||
.toArray(String[]::new);
|
||||
String[] parameterNames = operation.getParameters()
|
||||
.stream()
|
||||
.map(JmxOperationParameter::getName)
|
||||
.toArray(String[]::new);
|
||||
Map<String, Object> arguments = getArguments(parameterNames, params);
|
||||
InvocationContext context = new InvocationContext(SecurityContext.NONE, arguments);
|
||||
Object result = operation.invoke(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,8 +41,8 @@ public class JacksonJmxOperationResponseMapper implements JmxOperationResponseMa
|
||||
public JacksonJmxOperationResponseMapper(ObjectMapper objectMapper) {
|
||||
this.objectMapper = (objectMapper != null) ? objectMapper : new ObjectMapper();
|
||||
this.listType = this.objectMapper.getTypeFactory().constructParametricType(List.class, Object.class);
|
||||
this.mapType = this.objectMapper.getTypeFactory().constructParametricType(Map.class, String.class,
|
||||
Object.class);
|
||||
this.mapType = this.objectMapper.getTypeFactory()
|
||||
.constructParametricType(Map.class, String.class, Object.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,8 +83,9 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
|
||||
Method method = operationMethod.getMethod();
|
||||
ManagedOperationParameter[] managed = jmxAttributeSource.getManagedOperationParameters(method);
|
||||
if (managed.length == 0) {
|
||||
Stream<JmxOperationParameter> parameters = operationMethod.getParameters().stream()
|
||||
.map(DiscoveredJmxOperationParameter::new);
|
||||
Stream<JmxOperationParameter> parameters = operationMethod.getParameters()
|
||||
.stream()
|
||||
.map(DiscoveredJmxOperationParameter::new);
|
||||
return parameters.toList();
|
||||
}
|
||||
return mergeParameters(operationMethod.getParameters(), managed);
|
||||
@@ -121,8 +122,10 @@ class DiscoveredJmxOperation extends AbstractDiscoveredOperation implements JmxO
|
||||
|
||||
@Override
|
||||
protected void appendFields(ToStringCreator creator) {
|
||||
creator.append("name", this.name).append("outputType", this.outputType).append("description", this.description)
|
||||
.append("parameters", this.parameters);
|
||||
creator.append("name", this.name)
|
||||
.append("outputType", this.outputType)
|
||||
.append("description", this.description)
|
||||
.append("parameters", this.parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -90,8 +90,8 @@ public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableCo
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(ControllerEndpointFilter.class,
|
||||
MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
hints.reflection()
|
||||
.registerType(ControllerEndpointFilter.class, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,8 +60,11 @@ class DiscoveredWebOperation extends AbstractDiscoveredOperation implements WebO
|
||||
}
|
||||
|
||||
private String getId(EndpointId endpointId, OperationMethod method) {
|
||||
return endpointId + method.getParameters().stream().filter(this::hasSelector).map(this::dashName)
|
||||
.collect(Collectors.joining());
|
||||
return endpointId + method.getParameters()
|
||||
.stream()
|
||||
.filter(this::hasSelector)
|
||||
.map(this::dashName)
|
||||
.collect(Collectors.joining());
|
||||
}
|
||||
|
||||
private boolean hasSelector(OperationParameter parameter) {
|
||||
@@ -93,8 +96,9 @@ class DiscoveredWebOperation extends AbstractDiscoveredOperation implements WebO
|
||||
|
||||
@Override
|
||||
protected void appendFields(ToStringCreator creator) {
|
||||
creator.append("id", this.id).append("blocking", this.blocking).append("requestPredicate",
|
||||
this.requestPredicate);
|
||||
creator.append("id", this.id)
|
||||
.append("blocking", this.blocking)
|
||||
.append("requestPredicate", this.requestPredicate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,8 +53,10 @@ class RequestPredicateFactory {
|
||||
|
||||
WebOperationRequestPredicate getRequestPredicate(String rootPath, DiscoveredOperationMethod operationMethod) {
|
||||
Method method = operationMethod.getMethod();
|
||||
OperationParameter[] selectorParameters = operationMethod.getParameters().stream().filter(this::hasSelector)
|
||||
.toArray(OperationParameter[]::new);
|
||||
OperationParameter[] selectorParameters = operationMethod.getParameters()
|
||||
.stream()
|
||||
.filter(this::hasSelector)
|
||||
.toArray(OperationParameter[]::new);
|
||||
OperationParameter allRemainingPathSegmentsParameter = getAllRemainingPathSegmentsParameter(selectorParameters);
|
||||
String path = getPath(rootPath, selectorParameters, allRemainingPathSegmentsParameter != null);
|
||||
WebEndpointHttpMethod httpMethod = determineHttpMethod(operationMethod.getOperationType());
|
||||
@@ -131,7 +133,7 @@ class RequestPredicateFactory {
|
||||
|
||||
private boolean consumesRequestBody(Method method) {
|
||||
return Stream.of(method.getParameters())
|
||||
.anyMatch((parameter) -> parameter.getAnnotation(Selector.class) == null);
|
||||
.anyMatch((parameter) -> parameter.getAnnotation(Selector.class) == null);
|
||||
}
|
||||
|
||||
private WebEndpointHttpMethod determineHttpMethod(OperationType operationType) {
|
||||
|
||||
@@ -84,8 +84,10 @@ public class JerseyEndpointResourceFactory {
|
||||
Collection<ExposableWebEndpoint> endpoints, EndpointMediaTypes endpointMediaTypes,
|
||||
EndpointLinksResolver linksResolver, boolean shouldRegisterLinks) {
|
||||
List<Resource> resources = new ArrayList<>();
|
||||
endpoints.stream().flatMap((endpoint) -> endpoint.getOperations().stream())
|
||||
.map((operation) -> createResource(endpointMapping, operation)).forEach(resources::add);
|
||||
endpoints.stream()
|
||||
.flatMap((endpoint) -> endpoint.getOperations().stream())
|
||||
.map((operation) -> createResource(endpointMapping, operation))
|
||||
.forEach(resources::add);
|
||||
if (shouldRegisterLinks) {
|
||||
Resource resource = createEndpointLinksResource(endpointMapping.getPath(), endpointMediaTypes,
|
||||
linksResolver);
|
||||
@@ -108,21 +110,23 @@ public class JerseyEndpointResourceFactory {
|
||||
protected Resource getResource(EndpointMapping endpointMapping, WebOperation operation,
|
||||
WebOperationRequestPredicate requestPredicate, String path, WebServerNamespace serverNamespace,
|
||||
JerseyRemainingPathSegmentProvider remainingPathSegmentProvider) {
|
||||
Builder resourceBuilder = Resource.builder().path(endpointMapping.getPath())
|
||||
.path(endpointMapping.createSubPath(path));
|
||||
Builder resourceBuilder = Resource.builder()
|
||||
.path(endpointMapping.getPath())
|
||||
.path(endpointMapping.createSubPath(path));
|
||||
resourceBuilder.addMethod(requestPredicate.getHttpMethod().name())
|
||||
.consumes(StringUtils.toStringArray(requestPredicate.getConsumes()))
|
||||
.produces(StringUtils.toStringArray(requestPredicate.getProduces()))
|
||||
.handledBy(new OperationInflector(operation, !requestPredicate.getConsumes().isEmpty(), serverNamespace,
|
||||
remainingPathSegmentProvider));
|
||||
.consumes(StringUtils.toStringArray(requestPredicate.getConsumes()))
|
||||
.produces(StringUtils.toStringArray(requestPredicate.getProduces()))
|
||||
.handledBy(new OperationInflector(operation, !requestPredicate.getConsumes().isEmpty(), serverNamespace,
|
||||
remainingPathSegmentProvider));
|
||||
return resourceBuilder.build();
|
||||
}
|
||||
|
||||
private Resource createEndpointLinksResource(String endpointPath, EndpointMediaTypes endpointMediaTypes,
|
||||
EndpointLinksResolver linksResolver) {
|
||||
Builder resourceBuilder = Resource.builder().path(endpointPath);
|
||||
resourceBuilder.addMethod("GET").produces(StringUtils.toStringArray(endpointMediaTypes.getProduced()))
|
||||
.handledBy(new EndpointLinksInflector(linksResolver));
|
||||
resourceBuilder.addMethod("GET")
|
||||
.produces(StringUtils.toStringArray(endpointMediaTypes.getProduced()))
|
||||
.handledBy(new EndpointLinksInflector(linksResolver));
|
||||
return resourceBuilder.build();
|
||||
}
|
||||
|
||||
@@ -172,7 +176,7 @@ public class JerseyEndpointResourceFactory {
|
||||
try {
|
||||
JerseySecurityContext securityContext = new JerseySecurityContext(data.getSecurityContext());
|
||||
OperationArgumentResolver serverNamespaceArgumentResolver = OperationArgumentResolver
|
||||
.of(WebServerNamespace.class, () -> this.serverNamespace);
|
||||
.of(WebServerNamespace.class, () -> this.serverNamespace);
|
||||
InvocationContext invocationContext = new InvocationContext(securityContext, arguments,
|
||||
serverNamespaceArgumentResolver,
|
||||
new ProducibleOperationArgumentResolver(() -> data.getHeaders().get("Accept")));
|
||||
@@ -193,7 +197,7 @@ public class JerseyEndpointResourceFactory {
|
||||
private Map<String, Object> extractPathParameters(ContainerRequestContext requestContext) {
|
||||
Map<String, Object> pathParameters = extract(requestContext.getUriInfo().getPathParameters());
|
||||
String matchAllRemainingPathSegmentsVariable = this.operation.getRequestPredicate()
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
if (matchAllRemainingPathSegmentsVariable != null) {
|
||||
String remainingPathSegments = getRemainingPathSegments(requestContext, pathParameters,
|
||||
matchAllRemainingPathSegmentsVariable);
|
||||
@@ -244,8 +248,9 @@ public class JerseyEndpointResourceFactory {
|
||||
return Response.status(Status.OK).entity(convertIfNecessary(response)).build();
|
||||
}
|
||||
return Response.status(webEndpointResponse.getStatus())
|
||||
.header("Content-Type", webEndpointResponse.getContentType())
|
||||
.entity(convertIfNecessary(webEndpointResponse.getBody())).build();
|
||||
.header("Content-Type", webEndpointResponse.getContentType())
|
||||
.entity(convertIfNecessary(webEndpointResponse.getBody()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private Object convertIfNecessary(Object body) {
|
||||
@@ -322,7 +327,7 @@ public class JerseyEndpointResourceFactory {
|
||||
@Override
|
||||
public Response apply(ContainerRequestContext request) {
|
||||
Map<String, Link> links = this.linksResolver
|
||||
.resolveLinks(request.getUriInfo().getAbsolutePath().toString());
|
||||
.resolveLinks(request.getUriInfo().getAbsolutePath().toString());
|
||||
Map<String, Map<String, Link>> entity = OperationResponseBody.of(Collections.singletonMap("_links", links));
|
||||
return Response.ok(entity).build();
|
||||
}
|
||||
|
||||
@@ -186,8 +186,10 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
String path = this.endpointMapping.getPath();
|
||||
String linksPath = StringUtils.hasLength(path) ? path : "/";
|
||||
String[] produces = StringUtils.toStringArray(this.endpointMediaTypes.getProduced());
|
||||
RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath).methods(RequestMethod.GET).produces(produces)
|
||||
.build();
|
||||
RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath)
|
||||
.methods(RequestMethod.GET)
|
||||
.produces(produces)
|
||||
.build();
|
||||
LinksHandler linksHandler = getLinksHandler();
|
||||
registerMapping(mapping, linksHandler,
|
||||
ReflectionUtils.findMethod(linksHandler.getClass(), "links", ServerWebExchange.class));
|
||||
@@ -305,8 +307,8 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
|
||||
Mono<? extends SecurityContext> springSecurityContext() {
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.map((securityContext) -> new ReactiveSecurityContext(securityContext.getAuthentication()))
|
||||
.switchIfEmpty(Mono.just(new ReactiveSecurityContext(null)));
|
||||
.map((securityContext) -> new ReactiveSecurityContext(securityContext.getAuthentication()))
|
||||
.switchIfEmpty(Mono.just(new ReactiveSecurityContext(null)));
|
||||
}
|
||||
|
||||
Mono<SecurityContext> emptySecurityContext() {
|
||||
@@ -317,29 +319,30 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
public Mono<ResponseEntity<Object>> handle(ServerWebExchange exchange, Map<String, String> body) {
|
||||
Map<String, Object> arguments = getArguments(exchange, body);
|
||||
OperationArgumentResolver serverNamespaceArgumentResolver = OperationArgumentResolver
|
||||
.of(WebServerNamespace.class, () -> WebServerNamespace
|
||||
.from(WebServerApplicationContext.getServerNamespace(exchange.getApplicationContext())));
|
||||
.of(WebServerNamespace.class, () -> WebServerNamespace
|
||||
.from(WebServerApplicationContext.getServerNamespace(exchange.getApplicationContext())));
|
||||
return this.securityContextSupplier.get()
|
||||
.map((securityContext) -> new InvocationContext(securityContext, arguments,
|
||||
serverNamespaceArgumentResolver,
|
||||
new ProducibleOperationArgumentResolver(
|
||||
() -> exchange.getRequest().getHeaders().get("Accept"))))
|
||||
.flatMap((invocationContext) -> handleResult((Publisher<?>) this.invoker.invoke(invocationContext),
|
||||
exchange.getRequest().getMethod()));
|
||||
.map((securityContext) -> new InvocationContext(securityContext, arguments,
|
||||
serverNamespaceArgumentResolver,
|
||||
new ProducibleOperationArgumentResolver(
|
||||
() -> exchange.getRequest().getHeaders().get("Accept"))))
|
||||
.flatMap((invocationContext) -> handleResult((Publisher<?>) this.invoker.invoke(invocationContext),
|
||||
exchange.getRequest().getMethod()));
|
||||
}
|
||||
|
||||
private Map<String, Object> getArguments(ServerWebExchange exchange, Map<String, String> body) {
|
||||
Map<String, Object> arguments = new LinkedHashMap<>(getTemplateVariables(exchange));
|
||||
String matchAllRemainingPathSegmentsVariable = this.operation.getRequestPredicate()
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
if (matchAllRemainingPathSegmentsVariable != null) {
|
||||
arguments.put(matchAllRemainingPathSegmentsVariable, getRemainingPathSegments(exchange));
|
||||
}
|
||||
if (body != null) {
|
||||
arguments.putAll(body);
|
||||
}
|
||||
exchange.getRequest().getQueryParams()
|
||||
.forEach((name, values) -> arguments.put(name, (values.size() != 1) ? values : values.get(0)));
|
||||
exchange.getRequest()
|
||||
.getQueryParams()
|
||||
.forEach((name, values) -> arguments.put(name, (values.size() != 1) ? values : values.get(0)));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@@ -347,7 +350,8 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
PathPattern pathPattern = exchange.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
|
||||
if (pathPattern.hasPatternSyntax()) {
|
||||
String remainingSegments = pathPattern
|
||||
.extractPathWithinPattern(exchange.getRequest().getPath().pathWithinApplication()).value();
|
||||
.extractPathWithinPattern(exchange.getRequest().getPath().pathWithinApplication())
|
||||
.value();
|
||||
return tokenizePathSegments(remainingSegments);
|
||||
}
|
||||
return tokenizePathSegments(pathPattern.toString());
|
||||
@@ -371,11 +375,12 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
if (result instanceof Flux) {
|
||||
result = ((Flux<?>) result).collectList();
|
||||
}
|
||||
return Mono.from(result).map(this::toResponseEntity)
|
||||
.onErrorMap(InvalidEndpointRequestException.class,
|
||||
(ex) -> new ResponseStatusException(HttpStatus.BAD_REQUEST, ex.getReason()))
|
||||
.defaultIfEmpty(new ResponseEntity<>(
|
||||
(httpMethod != HttpMethod.GET) ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND));
|
||||
return Mono.from(result)
|
||||
.map(this::toResponseEntity)
|
||||
.onErrorMap(InvalidEndpointRequestException.class,
|
||||
(ex) -> new ResponseStatusException(HttpStatus.BAD_REQUEST, ex.getReason()))
|
||||
.defaultIfEmpty(new ResponseEntity<>(
|
||||
(httpMethod != HttpMethod.GET) ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND));
|
||||
}
|
||||
|
||||
private ResponseEntity<Object> toResponseEntity(Object response) {
|
||||
@@ -384,8 +389,9 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
}
|
||||
MediaType contentType = (webEndpointResponse.getContentType() != null)
|
||||
? new MediaType(webEndpointResponse.getContentType()) : null;
|
||||
return ResponseEntity.status(webEndpointResponse.getStatus()).contentType(contentType)
|
||||
.body(webEndpointResponse.getBody());
|
||||
return ResponseEntity.status(webEndpointResponse.getStatus())
|
||||
.contentType(contentType)
|
||||
.body(webEndpointResponse.getBody());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -485,8 +491,9 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
||||
@Override
|
||||
public boolean isUserInRole(String role) {
|
||||
String authority = (!role.startsWith(ROLE_PREFIX)) ? ROLE_PREFIX + role : role;
|
||||
return AuthorityAuthorizationManager.hasAuthority(authority).check(this::getAuthentication, null)
|
||||
.isGranted();
|
||||
return AuthorityAuthorizationManager.hasAuthority(authority)
|
||||
.check(this::getAuthentication, null)
|
||||
.isGranted();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -92,7 +92,8 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
|
||||
patterns = Collections.singleton(getPathPatternParser().parse(""));
|
||||
}
|
||||
String[] endpointMappedPatterns = patterns.stream()
|
||||
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern)).toArray(String[]::new);
|
||||
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern))
|
||||
.toArray(String[]::new);
|
||||
return mapping.mutate().paths(endpointMappedPatterns).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -86,8 +86,9 @@ public class WebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandle
|
||||
@ResponseBody
|
||||
@Reflective
|
||||
public Map<String, Map<String, Link>> links(ServerWebExchange exchange) {
|
||||
String requestUri = UriComponentsBuilder.fromUri(exchange.getRequest().getURI()).replaceQuery(null)
|
||||
.toUriString();
|
||||
String requestUri = UriComponentsBuilder.fromUri(exchange.getRequest().getURI())
|
||||
.replaceQuery(null)
|
||||
.toUriString();
|
||||
Map<String, Link> links = WebFluxEndpointHandlerMapping.this.linksResolver.resolveLinks(requestUri);
|
||||
return OperationResponseBody.of(Collections.singletonMap("_links", links));
|
||||
}
|
||||
|
||||
@@ -196,18 +196,22 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
}
|
||||
|
||||
private RequestMappingInfo createRequestMappingInfo(WebOperationRequestPredicate predicate, String path) {
|
||||
return RequestMappingInfo.paths(this.endpointMapping.createSubPath(path)).options(this.builderConfig)
|
||||
.methods(RequestMethod.valueOf(predicate.getHttpMethod().name()))
|
||||
.consumes(predicate.getConsumes().toArray(new String[0]))
|
||||
.produces(predicate.getProduces().toArray(new String[0])).build();
|
||||
return RequestMappingInfo.paths(this.endpointMapping.createSubPath(path))
|
||||
.options(this.builderConfig)
|
||||
.methods(RequestMethod.valueOf(predicate.getHttpMethod().name()))
|
||||
.consumes(predicate.getConsumes().toArray(new String[0]))
|
||||
.produces(predicate.getProduces().toArray(new String[0]))
|
||||
.build();
|
||||
}
|
||||
|
||||
private void registerLinksMapping() {
|
||||
String path = this.endpointMapping.getPath();
|
||||
String linksPath = (StringUtils.hasLength(path)) ? this.endpointMapping.createSubPath("/") : "/";
|
||||
RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath).methods(RequestMethod.GET)
|
||||
.produces(this.endpointMediaTypes.getProduced().toArray(new String[0])).options(this.builderConfig)
|
||||
.build();
|
||||
RequestMappingInfo mapping = RequestMappingInfo.paths(linksPath)
|
||||
.methods(RequestMethod.GET)
|
||||
.produces(this.endpointMediaTypes.getProduced().toArray(new String[0]))
|
||||
.options(this.builderConfig)
|
||||
.build();
|
||||
LinksHandler linksHandler = getLinksHandler();
|
||||
registerMapping(mapping, linksHandler, ReflectionUtils.findMethod(linksHandler.getClass(), "links",
|
||||
HttpServletRequest.class, HttpServletResponse.class));
|
||||
@@ -306,12 +310,12 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
ProducibleOperationArgumentResolver producibleOperationArgumentResolver = new ProducibleOperationArgumentResolver(
|
||||
() -> headers.get("Accept"));
|
||||
OperationArgumentResolver serverNamespaceArgumentResolver = OperationArgumentResolver
|
||||
.of(WebServerNamespace.class, () -> {
|
||||
WebApplicationContext applicationContext = WebApplicationContextUtils
|
||||
.getRequiredWebApplicationContext(request.getServletContext());
|
||||
return WebServerNamespace
|
||||
.from(WebServerApplicationContext.getServerNamespace(applicationContext));
|
||||
});
|
||||
.of(WebServerNamespace.class, () -> {
|
||||
WebApplicationContext applicationContext = WebApplicationContextUtils
|
||||
.getRequiredWebApplicationContext(request.getServletContext());
|
||||
return WebServerNamespace
|
||||
.from(WebServerApplicationContext.getServerNamespace(applicationContext));
|
||||
});
|
||||
InvocationContext invocationContext = new InvocationContext(securityContext, arguments,
|
||||
serverNamespaceArgumentResolver, producibleOperationArgumentResolver);
|
||||
return handleResult(this.operation.invoke(invocationContext), HttpMethod.valueOf(request.getMethod()));
|
||||
@@ -329,15 +333,16 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
private Map<String, Object> getArguments(HttpServletRequest request, Map<String, String> body) {
|
||||
Map<String, Object> arguments = new LinkedHashMap<>(getTemplateVariables(request));
|
||||
String matchAllRemainingPathSegmentsVariable = this.operation.getRequestPredicate()
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
.getMatchAllRemainingPathSegmentsVariable();
|
||||
if (matchAllRemainingPathSegmentsVariable != null) {
|
||||
arguments.put(matchAllRemainingPathSegmentsVariable, getRemainingPathSegments(request));
|
||||
}
|
||||
if (body != null && HttpMethod.POST.name().equals(request.getMethod())) {
|
||||
arguments.putAll(body);
|
||||
}
|
||||
request.getParameterMap().forEach(
|
||||
(name, values) -> arguments.put(name, (values.length != 1) ? Arrays.asList(values) : values[0]));
|
||||
request.getParameterMap()
|
||||
.forEach((name, values) -> arguments.put(name,
|
||||
(values.length != 1) ? Arrays.asList(values) : values[0]));
|
||||
return arguments;
|
||||
}
|
||||
|
||||
@@ -380,8 +385,9 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
||||
}
|
||||
MediaType contentType = (response.getContentType() != null) ? new MediaType(response.getContentType())
|
||||
: null;
|
||||
return ResponseEntity.status(response.getStatus()).contentType(contentType)
|
||||
.body(convertIfNecessary(response.getBody()));
|
||||
return ResponseEntity.status(response.getStatus())
|
||||
.contentType(contentType)
|
||||
.body(convertIfNecessary(response.getBody()));
|
||||
}
|
||||
|
||||
private Object convertIfNecessary(Object body) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -93,7 +93,8 @@ public class ControllerEndpointHandlerMapping extends RequestMappingHandlerMappi
|
||||
patterns = Collections.singleton(getPatternParser().parse(""));
|
||||
}
|
||||
String[] endpointMappedPatterns = patterns.stream()
|
||||
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern)).toArray(String[]::new);
|
||||
.map((pattern) -> getEndpointMappedPattern(endpoint, pattern))
|
||||
.toArray(String[]::new);
|
||||
return mapping.mutate().paths(endpointMappedPatterns).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,7 @@ final class SkipPathExtensionContentNegotiation implements HandlerInterceptor {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final String SKIP_ATTRIBUTE = org.springframework.web.accept.PathExtensionContentNegotiationStrategy.class
|
||||
.getName() + ".SKIP";
|
||||
.getName() + ".SKIP";
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -86,7 +86,7 @@ public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerM
|
||||
@Reflective
|
||||
public Map<String, Map<String, Link>> links(HttpServletRequest request, HttpServletResponse response) {
|
||||
Map<String, Link> links = WebMvcEndpointHandlerMapping.this.linksResolver
|
||||
.resolveLinks(request.getRequestURL().toString());
|
||||
.resolveLinks(request.getRequestURL().toString());
|
||||
return OperationResponseBody.of(Collections.singletonMap("_links", links));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -144,8 +144,9 @@ public class EnvironmentEndpoint {
|
||||
private PropertySourceDescriptor describeSource(String sourceName, EnumerablePropertySource<?> source,
|
||||
Predicate<String> namePredicate, boolean showUnsanitized) {
|
||||
Map<String, PropertyValueDescriptor> properties = new LinkedHashMap<>();
|
||||
Stream.of(source.getPropertyNames()).filter(namePredicate)
|
||||
.forEach((name) -> properties.put(name, describeValueOf(name, source, showUnsanitized)));
|
||||
Stream.of(source.getPropertyNames())
|
||||
.filter(namePredicate)
|
||||
.forEach((name) -> properties.put(name, describeValueOf(name, source, showUnsanitized)));
|
||||
return new PropertySourceDescriptor(sourceName, properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,7 +58,7 @@ public class FlywayEndpoint {
|
||||
while (target != null) {
|
||||
Map<String, FlywayDescriptor> flywayBeans = new HashMap<>();
|
||||
target.getBeansOfType(Flyway.class)
|
||||
.forEach((name, flyway) -> flywayBeans.put(name, new FlywayDescriptor(flyway.info().all())));
|
||||
.forEach((name, flyway) -> flywayBeans.put(name, new FlywayDescriptor(flyway.info().all())));
|
||||
ApplicationContext parent = target.getParent();
|
||||
contextFlywayBeans.put(target.getId(),
|
||||
new ContextFlywayBeansDescriptor(flywayBeans, (parent != null) ? parent.getId() : null));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,9 +78,10 @@ public interface HealthEndpointGroups {
|
||||
default Set<HealthEndpointGroup> getAllWithAdditionalPath(WebServerNamespace namespace) {
|
||||
Assert.notNull(namespace, "Namespace must not be null");
|
||||
Set<HealthEndpointGroup> filteredGroups = new LinkedHashSet<>();
|
||||
getNames().stream().map(this::get).filter(
|
||||
(group) -> group.getAdditionalPath() != null && group.getAdditionalPath().hasNamespace(namespace))
|
||||
.forEach(filteredGroups::add);
|
||||
getNames().stream()
|
||||
.map(this::get)
|
||||
.filter((group) -> group.getAdditionalPath() != null && group.getAdditionalPath().hasNamespace(namespace))
|
||||
.forEach(filteredGroups::add);
|
||||
return filteredGroups;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -193,7 +193,7 @@ abstract class HealthEndpointSupport<C, T> {
|
||||
protected final CompositeHealth getCompositeHealth(ApiVersion apiVersion, Map<String, HealthComponent> components,
|
||||
StatusAggregator statusAggregator, boolean showComponents, Set<String> groupNames) {
|
||||
Status status = statusAggregator
|
||||
.getAggregateStatus(components.values().stream().map(this::getStatus).collect(Collectors.toSet()));
|
||||
.getAggregateStatus(components.values().stream().map(this::getStatus).collect(Collectors.toSet()));
|
||||
Map<String, HealthComponent> instances = showComponents ? components : null;
|
||||
if (groupNames != null) {
|
||||
return new SystemHealth(apiVersion, status, instances, groupNames);
|
||||
|
||||
@@ -43,8 +43,10 @@ abstract class NamedContributorsMapAdapter<V, C> implements NamedContributors<C>
|
||||
Assert.notNull(map, "Map must not be null");
|
||||
Assert.notNull(valueAdapter, "ValueAdapter must not be null");
|
||||
map.keySet().forEach(this::validateKey);
|
||||
this.map = Collections.unmodifiableMap(map.entrySet().stream().collect(LinkedHashMap::new,
|
||||
(result, entry) -> result.put(entry.getKey(), adapt(entry.getValue(), valueAdapter)), Map::putAll));
|
||||
this.map = Collections.unmodifiableMap(map.entrySet()
|
||||
.stream()
|
||||
.collect(LinkedHashMap::new,
|
||||
(result, entry) -> result.put(entry.getKey(), adapt(entry.getValue(), valueAdapter)), Map::putAll));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -101,9 +101,11 @@ public class ReactiveHealthEndpointWebExtension
|
||||
protected Mono<? extends HealthComponent> aggregateContributions(ApiVersion apiVersion,
|
||||
Map<String, Mono<? extends HealthComponent>> contributions, StatusAggregator statusAggregator,
|
||||
boolean showComponents, Set<String> groupNames) {
|
||||
return Flux.fromIterable(contributions.entrySet()).flatMap(NamedHealthComponent::create)
|
||||
.collectMap(NamedHealthComponent::getName, NamedHealthComponent::getHealth).map((components) -> this
|
||||
.getCompositeHealth(apiVersion, components, statusAggregator, showComponents, groupNames));
|
||||
return Flux.fromIterable(contributions.entrySet())
|
||||
.flatMap(NamedHealthComponent::create)
|
||||
.collectMap(NamedHealthComponent::getName, NamedHealthComponent::getHealth)
|
||||
.map((components) -> this.getCompositeHealth(apiVersion, components, statusAggregator, showComponents,
|
||||
groupNames));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -91,7 +91,7 @@ public abstract class InfoPropertiesInfoContributor<T extends InfoProperties> im
|
||||
*/
|
||||
protected Map<String, Object> extractContent(PropertySource<?> propertySource) {
|
||||
return new Binder(ConfigurationPropertySources.from(propertySource)).bind("", STRING_OBJECT_MAP)
|
||||
.orElseGet(LinkedHashMap::new);
|
||||
.orElseGet(LinkedHashMap::new);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,7 +69,7 @@ public class JmsHealthIndicator extends AbstractHealthIndicator {
|
||||
try {
|
||||
if (!this.latch.await(5, TimeUnit.SECONDS)) {
|
||||
JmsHealthIndicator.this.logger
|
||||
.warn("Connection failed to start within 5 seconds and will be closed.");
|
||||
.warn("Connection failed to start within 5 seconds and will be closed.");
|
||||
closeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,7 +63,7 @@ public class LiquibaseEndpoint {
|
||||
Map<String, LiquibaseBeanDescriptor> liquibaseBeans = new HashMap<>();
|
||||
DatabaseFactory factory = DatabaseFactory.getInstance();
|
||||
target.getBeansOfType(SpringLiquibase.class)
|
||||
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
|
||||
.forEach((name, liquibase) -> liquibaseBeans.put(name, createReport(liquibase, factory)));
|
||||
ApplicationContext parent = target.getParent();
|
||||
contextBeans.put(target.getId(),
|
||||
new ContextLiquibaseBeansDescriptor(liquibaseBeans, (parent != null) ? parent.getId() : null));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -154,9 +154,9 @@ public class HeapDumpWebEndpoint {
|
||||
protected HotSpotDiagnosticMXBeanHeapDumper() {
|
||||
try {
|
||||
Class<?> diagnosticMXBeanClass = ClassUtils
|
||||
.resolveClassName("com.sun.management.HotSpotDiagnosticMXBean", null);
|
||||
.resolveClassName("com.sun.management.HotSpotDiagnosticMXBean", null);
|
||||
this.diagnosticMXBean = ManagementFactory
|
||||
.getPlatformMXBean((Class<PlatformManagedObject>) diagnosticMXBeanClass);
|
||||
.getPlatformMXBean((Class<PlatformManagedObject>) diagnosticMXBeanClass);
|
||||
this.dumpHeapMethod = ReflectionUtils.findMethod(diagnosticMXBeanClass, "dumpHeap", String.class,
|
||||
Boolean.TYPE);
|
||||
}
|
||||
@@ -285,7 +285,7 @@ public class HeapDumpWebEndpoint {
|
||||
}
|
||||
catch (IOException ex) {
|
||||
TemporaryFileSystemResource.this.logger
|
||||
.warn("Failed to delete temporary heap dump file '" + getFile() + "'", ex);
|
||||
.warn("Failed to delete temporary heap dump file '" + getFile() + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -114,8 +114,12 @@ public class MetricsEndpoint {
|
||||
|
||||
private Collection<Meter> findFirstMatchingMeters(CompositeMeterRegistry composite, String name,
|
||||
Iterable<Tag> tags) {
|
||||
return composite.getRegistries().stream().map((registry) -> findFirstMatchingMeters(registry, name, tags))
|
||||
.filter((matching) -> !matching.isEmpty()).findFirst().orElse(Collections.emptyList());
|
||||
return composite.getRegistries()
|
||||
.stream()
|
||||
.map((registry) -> findFirstMatchingMeters(registry, name, tags))
|
||||
.filter((matching) -> !matching.isEmpty())
|
||||
.findFirst()
|
||||
.orElse(Collections.emptyList());
|
||||
}
|
||||
|
||||
private Map<Statistic, Double> getSamples(Collection<Meter> meters) {
|
||||
@@ -125,8 +129,9 @@ public class MetricsEndpoint {
|
||||
}
|
||||
|
||||
private void mergeMeasurements(Map<Statistic, Double> samples, Meter meter) {
|
||||
meter.measure().forEach((measurement) -> samples.merge(measurement.getStatistic(), measurement.getValue(),
|
||||
mergeFunction(measurement.getStatistic())));
|
||||
meter.measure()
|
||||
.forEach((measurement) -> samples.merge(measurement.getStatistic(), measurement.getValue(),
|
||||
mergeFunction(measurement.getStatistic())));
|
||||
}
|
||||
|
||||
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,9 +72,11 @@ public class CacheMetricsRegistrar {
|
||||
private MeterBinder getMeterBinder(Cache cache, Tags tags) {
|
||||
Tags cacheTags = tags.and(getAdditionalTags(cache));
|
||||
return LambdaSafe.callbacks(CacheMeterBinderProvider.class, this.binderProviders, cache)
|
||||
.withLogger(CacheMetricsRegistrar.class)
|
||||
.invokeAnd((binderProvider) -> binderProvider.getMeterBinder(cache, cacheTags)).filter(Objects::nonNull)
|
||||
.findFirst().orElse(null);
|
||||
.withLogger(CacheMetricsRegistrar.class)
|
||||
.invokeAnd((binderProvider) -> binderProvider.getMeterBinder(cache, cacheTags))
|
||||
.filter(Objects::nonNull)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,8 +56,8 @@ public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvid
|
||||
try {
|
||||
Method nativeCacheAccessor = ReflectionUtils.findMethod(HazelcastCache.class, "getNativeCache");
|
||||
Object nativeCache = ReflectionUtils.invokeMethod(nativeCacheAccessor, cache);
|
||||
return HazelcastCacheMetrics.class.getConstructor(Object.class, Iterable.class).newInstance(nativeCache,
|
||||
tags);
|
||||
return HazelcastCacheMetrics.class.getConstructor(Object.class, Iterable.class)
|
||||
.newInstance(nativeCache, tags);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException("Failed to create MeterBinder for Hazelcast", ex);
|
||||
@@ -72,8 +72,9 @@ public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvid
|
||||
Method getNativeCacheMethod = ReflectionUtils.findMethod(HazelcastCache.class, "getNativeCache");
|
||||
Assert.state(getNativeCacheMethod != null, "Unable to find 'getNativeCache' method");
|
||||
Constructor<?> constructor = HazelcastCacheMetrics.class.getConstructor(Object.class, Iterable.class);
|
||||
hints.reflection().registerMethod(getNativeCacheMethod, ExecutableMode.INVOKE)
|
||||
.registerConstructor(constructor, ExecutableMode.INVOKE);
|
||||
hints.reflection()
|
||||
.registerMethod(getNativeCacheMethod, ExecutableMode.INVOKE)
|
||||
.registerConstructor(constructor, ExecutableMode.INVOKE);
|
||||
}
|
||||
catch (NoSuchMethodException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,15 +69,20 @@ public class RedisCacheMetrics extends CacheMeterBinder<RedisCache> {
|
||||
@Override
|
||||
protected void bindImplementationSpecificMetrics(MeterRegistry registry) {
|
||||
FunctionCounter.builder("cache.removals", this.cache, (cache) -> cache.getStatistics().getDeletes())
|
||||
.tags(getTagsWithCacheName()).description("Cache removals").register(registry);
|
||||
.tags(getTagsWithCacheName())
|
||||
.description("Cache removals")
|
||||
.register(registry);
|
||||
FunctionCounter.builder("cache.gets", this.cache, (cache) -> cache.getStatistics().getPending())
|
||||
.tags(getTagsWithCacheName()).tag("result", "pending").description("The number of pending requests")
|
||||
.register(registry);
|
||||
.tags(getTagsWithCacheName())
|
||||
.tag("result", "pending")
|
||||
.description("The number of pending requests")
|
||||
.register(registry);
|
||||
TimeGauge
|
||||
.builder("cache.lock.duration", this.cache, TimeUnit.NANOSECONDS,
|
||||
(cache) -> cache.getStatistics().getLockWaitDuration(TimeUnit.NANOSECONDS))
|
||||
.tags(getTagsWithCacheName()).description("The time the cache has spent waiting on a lock")
|
||||
.register(registry);
|
||||
.builder("cache.lock.duration", this.cache, TimeUnit.NANOSECONDS,
|
||||
(cache) -> cache.getStatistics().getLockWaitDuration(TimeUnit.NANOSECONDS))
|
||||
.tags(getTagsWithCacheName())
|
||||
.description("The time the cache has spent waiting on a lock")
|
||||
.register(registry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,8 +69,10 @@ public class MetricsRepositoryMethodInvocationListener implements RepositoryMeth
|
||||
Iterable<Tag> tags = this.tagsProvider.repositoryTags(invocation);
|
||||
long duration = invocation.getDuration(TimeUnit.NANOSECONDS);
|
||||
AutoTimer.apply(this.autoTimer, this.metricName, annotations,
|
||||
(builder) -> builder.description("Duration of repository invocations").tags(tags)
|
||||
.register(this.registrySupplier.get()).record(duration, TimeUnit.NANOSECONDS));
|
||||
(builder) -> builder.description("Duration of repository invocations")
|
||||
.tags(tags)
|
||||
.register(this.registrySupplier.get())
|
||||
.record(duration, TimeUnit.NANOSECONDS));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -88,7 +88,9 @@ public class DataSourcePoolMetrics implements MeterBinder {
|
||||
Function<DataSource, N> function) {
|
||||
if (function.apply(this.dataSource) != null) {
|
||||
Gauge.builder("jdbc.connections." + metricName, this.dataSource, (m) -> function.apply(m).doubleValue())
|
||||
.tags(this.tags).description(description).register(registry);
|
||||
.tags(this.tags)
|
||||
.description(description)
|
||||
.register(registry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,22 +50,21 @@ public class ConnectionPoolMetrics implements MeterBinder {
|
||||
this.pool.getMetrics().ifPresent((poolMetrics) -> {
|
||||
bindConnectionPoolMetric(registry,
|
||||
Gauge.builder(metricKey("acquired"), poolMetrics, PoolMetrics::acquiredSize)
|
||||
.description("Size of successfully acquired connections which are in active use."));
|
||||
.description("Size of successfully acquired connections which are in active use."));
|
||||
bindConnectionPoolMetric(registry,
|
||||
Gauge.builder(metricKey("allocated"), poolMetrics, PoolMetrics::allocatedSize)
|
||||
.description("Size of allocated connections in the pool which are in active use or idle."));
|
||||
.description("Size of allocated connections in the pool which are in active use or idle."));
|
||||
bindConnectionPoolMetric(registry, Gauge.builder(metricKey("idle"), poolMetrics, PoolMetrics::idleSize)
|
||||
.description("Size of idle connections in the pool."));
|
||||
.description("Size of idle connections in the pool."));
|
||||
bindConnectionPoolMetric(registry,
|
||||
Gauge.builder(metricKey("pending"), poolMetrics, PoolMetrics::pendingAcquireSize).description(
|
||||
"Size of pending to acquire connections from the underlying connection factory."));
|
||||
Gauge.builder(metricKey("pending"), poolMetrics, PoolMetrics::pendingAcquireSize)
|
||||
.description("Size of pending to acquire connections from the underlying connection factory."));
|
||||
bindConnectionPoolMetric(registry,
|
||||
Gauge.builder(metricKey("max.allocated"), poolMetrics, PoolMetrics::getMaxAllocatedSize)
|
||||
.description("Maximum size of allocated connections that this pool allows."));
|
||||
.description("Maximum size of allocated connections that this pool allows."));
|
||||
bindConnectionPoolMetric(registry,
|
||||
Gauge.builder(metricKey("max.pending"), poolMetrics, PoolMetrics::getMaxPendingAcquireSize)
|
||||
.description(
|
||||
"Maximum size of pending state to acquire connections that this pool allows."));
|
||||
.description("Maximum size of pending state to acquire connections that this pool allows."));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -116,8 +116,10 @@ public class StartupTimeMetricsListener implements SmartApplicationListener {
|
||||
SpringApplication springApplication) {
|
||||
if (timeTaken != null) {
|
||||
Iterable<Tag> tags = createTagsFrom(springApplication);
|
||||
TimeGauge.builder(name, timeTaken::toMillis, TimeUnit.MILLISECONDS).tags(tags).description(description)
|
||||
.register(this.meterRegistry);
|
||||
TimeGauge.builder(name, timeTaken::toMillis, TimeUnit.MILLISECONDS)
|
||||
.tags(tags)
|
||||
.description(description)
|
||||
.register(this.meterRegistry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class ObservationWebClientCustomizer implements WebClientCustomizer {
|
||||
@Override
|
||||
public void customize(WebClient.Builder webClientBuilder) {
|
||||
webClientBuilder.observationRegistry(this.observationRegistry)
|
||||
.observationConvention(this.observationConvention);
|
||||
.observationConvention(this.observationConvention);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -38,8 +38,9 @@ class Neo4jHealthDetailsHandler {
|
||||
void addHealthDetails(Builder builder, Neo4jHealthDetails healthDetails) {
|
||||
ResultSummary summary = healthDetails.getSummary();
|
||||
ServerInfo serverInfo = summary.server();
|
||||
builder.up().withDetail("server", healthDetails.getVersion() + "@" + serverInfo.address()).withDetail("edition",
|
||||
healthDetails.getEdition());
|
||||
builder.up()
|
||||
.withDetail("server", healthDetails.getVersion() + "@" + serverInfo.address())
|
||||
.withDetail("edition", healthDetails.getEdition());
|
||||
DatabaseInfo databaseInfo = summary.database();
|
||||
if (StringUtils.hasText(databaseInfo.name())) {
|
||||
builder.withDetail("database", databaseInfo.name());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2021 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,8 +57,9 @@ public class Neo4jHealthIndicator extends AbstractHealthIndicator {
|
||||
/**
|
||||
* The default session config to use while connecting.
|
||||
*/
|
||||
static final SessionConfig DEFAULT_SESSION_CONFIG = SessionConfig.builder().withDefaultAccessMode(AccessMode.WRITE)
|
||||
.build();
|
||||
static final SessionConfig DEFAULT_SESSION_CONFIG = SessionConfig.builder()
|
||||
.withDefaultAccessMode(AccessMode.WRITE)
|
||||
.build();
|
||||
|
||||
private final Driver driver;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,12 +57,12 @@ public final class Neo4jReactiveHealthIndicator extends AbstractReactiveHealthIn
|
||||
@Override
|
||||
protected Mono<Health> doHealthCheck(Health.Builder builder) {
|
||||
return runHealthCheckQuery()
|
||||
.doOnError(SessionExpiredException.class,
|
||||
(ex) -> logger.warn(Neo4jHealthIndicator.MESSAGE_SESSION_EXPIRED))
|
||||
.retryWhen(Retry.max(1).filter(SessionExpiredException.class::isInstance)).map((healthDetails) -> {
|
||||
this.healthDetailsHandler.addHealthDetails(builder, healthDetails);
|
||||
return builder.build();
|
||||
});
|
||||
.doOnError(SessionExpiredException.class, (ex) -> logger.warn(Neo4jHealthIndicator.MESSAGE_SESSION_EXPIRED))
|
||||
.retryWhen(Retry.max(1).filter(SessionExpiredException.class::isInstance))
|
||||
.map((healthDetails) -> {
|
||||
this.healthDetailsHandler.addHealthDetails(builder, healthDetails);
|
||||
return builder.build();
|
||||
});
|
||||
}
|
||||
|
||||
Mono<Neo4jHealthDetails> runHealthCheckQuery() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,8 +66,8 @@ import org.springframework.util.Assert;
|
||||
public class QuartzEndpoint {
|
||||
|
||||
private static final Comparator<Trigger> TRIGGER_COMPARATOR = Comparator
|
||||
.comparing(Trigger::getNextFireTime, Comparator.nullsLast(Comparator.naturalOrder()))
|
||||
.thenComparing(Comparator.comparingInt(Trigger::getPriority).reversed());
|
||||
.comparing(Trigger::getNextFireTime, Comparator.nullsLast(Comparator.naturalOrder()))
|
||||
.thenComparing(Comparator.comparingInt(Trigger::getPriority).reversed());
|
||||
|
||||
private final Scheduler scheduler;
|
||||
|
||||
@@ -98,8 +98,10 @@ public class QuartzEndpoint {
|
||||
public QuartzGroupsDescriptor quartzJobGroups() throws SchedulerException {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
for (String groupName : this.scheduler.getJobGroupNames()) {
|
||||
List<String> jobs = this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName)).stream()
|
||||
.map((key) -> key.getName()).toList();
|
||||
List<String> jobs = this.scheduler.getJobKeys(GroupMatcher.jobGroupEquals(groupName))
|
||||
.stream()
|
||||
.map((key) -> key.getName())
|
||||
.toList();
|
||||
result.put(groupName, Collections.singletonMap("jobs", jobs));
|
||||
}
|
||||
return new QuartzGroupsDescriptor(result);
|
||||
@@ -116,8 +118,11 @@ public class QuartzEndpoint {
|
||||
for (String groupName : this.scheduler.getTriggerGroupNames()) {
|
||||
Map<String, Object> groupDetails = new LinkedHashMap<>();
|
||||
groupDetails.put("paused", pausedTriggerGroups.contains(groupName));
|
||||
groupDetails.put("triggers", this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(groupName))
|
||||
.stream().map((key) -> key.getName()).toList());
|
||||
groupDetails.put("triggers",
|
||||
this.scheduler.getTriggerKeys(GroupMatcher.triggerGroupEquals(groupName))
|
||||
.stream()
|
||||
.map((key) -> key.getName())
|
||||
.toList());
|
||||
result.put(groupName, groupDetails);
|
||||
}
|
||||
return new QuartzGroupsDescriptor(result);
|
||||
@@ -570,9 +575,12 @@ public class QuartzEndpoint {
|
||||
private final TriggerType type;
|
||||
|
||||
private static TriggerDescriptor of(Trigger trigger) {
|
||||
return DESCRIBERS.entrySet().stream().filter((entry) -> entry.getKey().isInstance(trigger))
|
||||
.map((entry) -> entry.getValue().apply(trigger)).findFirst()
|
||||
.orElse(new CustomTriggerDescriptor(trigger));
|
||||
return DESCRIBERS.entrySet()
|
||||
.stream()
|
||||
.filter((entry) -> entry.getKey().isInstance(trigger))
|
||||
.map((entry) -> entry.getValue().apply(trigger))
|
||||
.findFirst()
|
||||
.orElse(new CustomTriggerDescriptor(trigger));
|
||||
}
|
||||
|
||||
protected TriggerDescriptor(Trigger trigger, TriggerType type) {
|
||||
@@ -721,7 +729,7 @@ public class QuartzEndpoint {
|
||||
protected void appendSummary(Map<String, Object> content) {
|
||||
content.put("interval",
|
||||
getIntervalDuration(this.trigger.getRepeatInterval(), this.trigger.getRepeatIntervalUnit())
|
||||
.toMillis());
|
||||
.toMillis());
|
||||
putIfNoNull(content, "daysOfWeek", this.trigger.getDaysOfWeek());
|
||||
putIfNoNull(content, "startTimeOfDay", getLocalTime(this.trigger.getStartTimeOfDay()));
|
||||
putIfNoNull(content, "endTimeOfDay", getLocalTime(this.trigger.getEndTimeOfDay()));
|
||||
@@ -752,7 +760,7 @@ public class QuartzEndpoint {
|
||||
protected void appendSummary(Map<String, Object> content) {
|
||||
content.put("interval",
|
||||
getIntervalDuration(this.trigger.getRepeatInterval(), this.trigger.getRepeatIntervalUnit())
|
||||
.toMillis());
|
||||
.toMillis());
|
||||
putIfNoNull(content, "timeZone", this.trigger.getTimeZone());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2020 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,8 +70,8 @@ public class ConnectionFactoryHealthIndicator extends AbstractReactiveHealthIndi
|
||||
|
||||
@Override
|
||||
protected final Mono<Health> doHealthCheck(Builder builder) {
|
||||
return validate(builder).defaultIfEmpty(builder.build()).onErrorResume(Exception.class,
|
||||
(ex) -> Mono.just(builder.down(ex).build()));
|
||||
return validate(builder).defaultIfEmpty(builder.build())
|
||||
.onErrorResume(Exception.class, (ex) -> Mono.just(builder.down(ex).build()));
|
||||
}
|
||||
|
||||
private Mono<Health> validate(Builder builder) {
|
||||
@@ -84,7 +84,8 @@ public class ConnectionFactoryHealthIndicator extends AbstractReactiveHealthIndi
|
||||
builder.withDetail("validationQuery", this.validationQuery);
|
||||
Mono<Object> connectionValidation = Mono.usingWhen(this.connectionFactory.create(),
|
||||
(conn) -> Flux.from(conn.createStatement(this.validationQuery).execute())
|
||||
.flatMap((it) -> it.map(this::extractResult)).next(),
|
||||
.flatMap((it) -> it.map(this::extractResult))
|
||||
.next(),
|
||||
Connection::close, (o, throwable) -> o.close(), Connection::close);
|
||||
return connectionValidation.map((result) -> builder.up().withDetail("result", result).build());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,9 +67,11 @@ public class ScheduledTasksEndpoint {
|
||||
@ReadOperation
|
||||
public ScheduledTasksDescriptor scheduledTasks() {
|
||||
Map<TaskType, List<TaskDescriptor>> descriptionsByType = this.scheduledTaskHolders.stream()
|
||||
.flatMap((holder) -> holder.getScheduledTasks().stream()).map(ScheduledTask::getTask)
|
||||
.map(TaskDescriptor::of).filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(TaskDescriptor::getType));
|
||||
.flatMap((holder) -> holder.getScheduledTasks().stream())
|
||||
.map(ScheduledTask::getTask)
|
||||
.map(TaskDescriptor::of)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.groupingBy(TaskDescriptor::getType));
|
||||
return new ScheduledTasksDescriptor(descriptionsByType);
|
||||
}
|
||||
|
||||
@@ -130,8 +132,12 @@ public class ScheduledTasksEndpoint {
|
||||
private final RunnableDescriptor runnable;
|
||||
|
||||
private static TaskDescriptor of(Task task) {
|
||||
return DESCRIBERS.entrySet().stream().filter((entry) -> entry.getKey().isInstance(task))
|
||||
.map((entry) -> entry.getValue().apply(task)).findFirst().orElse(null);
|
||||
return DESCRIBERS.entrySet()
|
||||
.stream()
|
||||
.filter((entry) -> entry.getKey().isInstance(task))
|
||||
.map((entry) -> entry.getValue().apply(task))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
private static TaskDescriptor describeTriggerTask(TriggerTask triggerTask) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -93,23 +93,25 @@ public class StartupEndpoint {
|
||||
static class StartupEndpointRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
private static final TypeReference DEFAULT_TAG = TypeReference
|
||||
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep$DefaultTag");
|
||||
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep$DefaultTag");
|
||||
|
||||
private static final TypeReference BUFFERED_STARTUP_STEP = TypeReference
|
||||
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep");
|
||||
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep");
|
||||
|
||||
private static final TypeReference FLIGHT_RECORDER_TAG = TypeReference
|
||||
.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep$FlightRecorderTag");
|
||||
.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep$FlightRecorderTag");
|
||||
|
||||
private static final TypeReference FLIGHT_RECORDER_STARTUP_STEP = TypeReference
|
||||
.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep");
|
||||
.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep");
|
||||
|
||||
@Override
|
||||
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||
hints.reflection().registerType(DEFAULT_TAG, (typeHint) -> typeHint.onReachableType(BUFFERED_STARTUP_STEP)
|
||||
hints.reflection()
|
||||
.registerType(DEFAULT_TAG, (typeHint) -> typeHint.onReachableType(BUFFERED_STARTUP_STEP)
|
||||
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
hints.reflection()
|
||||
.registerType(FLIGHT_RECORDER_TAG, (typeHint) -> typeHint.onReachableType(FLIGHT_RECORDER_STARTUP_STEP)
|
||||
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
hints.reflection().registerType(FLIGHT_RECORDER_TAG, (typeHint) -> typeHint
|
||||
.onReachableType(FLIGHT_RECORDER_STARTUP_STEP).withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -68,9 +68,11 @@ public class DiskSpaceHealthIndicator extends AbstractHealthIndicator {
|
||||
this.path.getAbsolutePath(), diskFreeInBytes, this.threshold));
|
||||
builder.down();
|
||||
}
|
||||
builder.withDetail("total", this.path.getTotalSpace()).withDetail("free", diskFreeInBytes)
|
||||
.withDetail("threshold", this.threshold.toBytes()).withDetail("path", this.path.getAbsolutePath())
|
||||
.withDetail("exists", this.path.exists());
|
||||
builder.withDetail("total", this.path.getTotalSpace())
|
||||
.withDetail("free", diskFreeInBytes)
|
||||
.withDetail("threshold", this.threshold.toBytes())
|
||||
.withDetail("path", this.path.getAbsolutePath())
|
||||
.withDetail("exists", this.path.exists());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,7 +73,7 @@ public class HttpExchangesWebFilter implements WebFilter, Ordered {
|
||||
Mono<?> principal = exchange.getPrincipal().cast(Object.class).defaultIfEmpty(NONE);
|
||||
Mono<Object> session = exchange.getSession().cast(Object.class).defaultIfEmpty(NONE);
|
||||
return Mono.zip(PrincipalAndSession::new, principal, session)
|
||||
.flatMap((principalAndSession) -> filter(exchange, chain, principalAndSession));
|
||||
.flatMap((principalAndSession) -> filter(exchange, chain, principalAndSession));
|
||||
}
|
||||
|
||||
private Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -61,8 +61,8 @@ import org.springframework.web.util.pattern.PathPattern;
|
||||
public class DispatcherHandlersMappingDescriptionProvider implements MappingDescriptionProvider {
|
||||
|
||||
private static final List<HandlerMappingDescriptionProvider<? extends HandlerMapping>> descriptionProviders = Arrays
|
||||
.asList(new RequestMappingInfoHandlerMappingDescriptionProvider(),
|
||||
new UrlHandlerMappingDescriptionProvider(), new RouterFunctionMappingDescriptionProvider());
|
||||
.asList(new RequestMappingInfoHandlerMappingDescriptionProvider(), new UrlHandlerMappingDescriptionProvider(),
|
||||
new RouterFunctionMappingDescriptionProvider());
|
||||
|
||||
@Override
|
||||
public String getMappingName() {
|
||||
@@ -73,7 +73,7 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc
|
||||
public Map<String, List<DispatcherHandlerMappingDescription>> describeMappings(ApplicationContext context) {
|
||||
Map<String, List<DispatcherHandlerMappingDescription>> mappings = new HashMap<>();
|
||||
context.getBeansOfType(DispatcherHandler.class)
|
||||
.forEach((name, handler) -> mappings.put(name, describeMappings(handler)));
|
||||
.forEach((name, handler) -> mappings.put(name, describeMappings(handler)));
|
||||
return mappings;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -48,17 +48,32 @@ public class RequestMappingConditionsDescription {
|
||||
private final List<MediaTypeExpressionDescription> produces;
|
||||
|
||||
RequestMappingConditionsDescription(RequestMappingInfo requestMapping) {
|
||||
this.consumes = requestMapping.getConsumesCondition().getExpressions().stream()
|
||||
.map(MediaTypeExpressionDescription::new).toList();
|
||||
this.headers = requestMapping.getHeadersCondition().getExpressions().stream()
|
||||
.map(NameValueExpressionDescription::new).toList();
|
||||
this.consumes = requestMapping.getConsumesCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(MediaTypeExpressionDescription::new)
|
||||
.toList();
|
||||
this.headers = requestMapping.getHeadersCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(NameValueExpressionDescription::new)
|
||||
.toList();
|
||||
this.methods = requestMapping.getMethodsCondition().getMethods();
|
||||
this.params = requestMapping.getParamsCondition().getExpressions().stream()
|
||||
.map(NameValueExpressionDescription::new).toList();
|
||||
this.patterns = requestMapping.getPatternsCondition().getPatterns().stream().map(PathPattern::getPatternString)
|
||||
.collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet));
|
||||
this.produces = requestMapping.getProducesCondition().getExpressions().stream()
|
||||
.map(MediaTypeExpressionDescription::new).toList();
|
||||
this.params = requestMapping.getParamsCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(NameValueExpressionDescription::new)
|
||||
.toList();
|
||||
this.patterns = requestMapping.getPatternsCondition()
|
||||
.getPatterns()
|
||||
.stream()
|
||||
.map(PathPattern::getPatternString)
|
||||
.collect(Collectors.collectingAndThen(Collectors.toSet(), Collections::unmodifiableSet));
|
||||
this.produces = requestMapping.getProducesCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(MediaTypeExpressionDescription::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public List<MediaTypeExpressionDescription> getConsumes() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,8 +95,10 @@ final class DispatcherServletHandlerMappings {
|
||||
}
|
||||
|
||||
private Optional<Context> findContext() {
|
||||
return Stream.of(this.webServer.getTomcat().getHost().findChildren()).filter(Context.class::isInstance)
|
||||
.map(Context.class::cast).findFirst();
|
||||
return Stream.of(this.webServer.getTomcat().getHost().findChildren())
|
||||
.filter(Context.class::isInstance)
|
||||
.map(Context.class::cast)
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
private void initializeServlet(Context context, String name) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -192,8 +192,8 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc
|
||||
public List<DispatcherServletMappingDescription> describe(Iterable handlerMapping) {
|
||||
List<DispatcherServletMappingDescription> descriptions = new ArrayList<>();
|
||||
for (Object delegate : handlerMapping) {
|
||||
descriptions.addAll(
|
||||
DispatcherServletsMappingDescriptionProvider.describe(delegate, this.descriptionProviders));
|
||||
descriptions
|
||||
.addAll(DispatcherServletsMappingDescriptionProvider.describe(delegate, this.descriptionProviders));
|
||||
}
|
||||
return descriptions;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,8 +44,12 @@ public class FiltersMappingDescriptionProvider implements MappingDescriptionProv
|
||||
@Override
|
||||
public List<FilterRegistrationMappingDescription> describeMappings(ApplicationContext context) {
|
||||
if (context instanceof WebApplicationContext webApplicationContext) {
|
||||
return webApplicationContext.getServletContext().getFilterRegistrations().values().stream()
|
||||
.map(FilterRegistrationMappingDescription::new).toList();
|
||||
return webApplicationContext.getServletContext()
|
||||
.getFilterRegistrations()
|
||||
.values()
|
||||
.stream()
|
||||
.map(FilterRegistrationMappingDescription::new)
|
||||
.toList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,16 +46,28 @@ public class RequestMappingConditionsDescription {
|
||||
private final List<MediaTypeExpressionDescription> produces;
|
||||
|
||||
RequestMappingConditionsDescription(RequestMappingInfo requestMapping) {
|
||||
this.consumes = requestMapping.getConsumesCondition().getExpressions().stream()
|
||||
.map(MediaTypeExpressionDescription::new).toList();
|
||||
this.headers = requestMapping.getHeadersCondition().getExpressions().stream()
|
||||
.map(NameValueExpressionDescription::new).toList();
|
||||
this.consumes = requestMapping.getConsumesCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(MediaTypeExpressionDescription::new)
|
||||
.toList();
|
||||
this.headers = requestMapping.getHeadersCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(NameValueExpressionDescription::new)
|
||||
.toList();
|
||||
this.methods = requestMapping.getMethodsCondition().getMethods();
|
||||
this.params = requestMapping.getParamsCondition().getExpressions().stream()
|
||||
.map(NameValueExpressionDescription::new).toList();
|
||||
this.params = requestMapping.getParamsCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(NameValueExpressionDescription::new)
|
||||
.toList();
|
||||
this.patterns = extractPathPatterns(requestMapping);
|
||||
this.produces = requestMapping.getProducesCondition().getExpressions().stream()
|
||||
.map(MediaTypeExpressionDescription::new).toList();
|
||||
this.produces = requestMapping.getProducesCondition()
|
||||
.getExpressions()
|
||||
.stream()
|
||||
.map(MediaTypeExpressionDescription::new)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private Set<String> extractPathPatterns(RequestMappingInfo requestMapping) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2022 the original author or authors.
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,8 +44,12 @@ public class ServletsMappingDescriptionProvider implements MappingDescriptionPro
|
||||
@Override
|
||||
public List<ServletRegistrationMappingDescription> describeMappings(ApplicationContext context) {
|
||||
if (context instanceof WebApplicationContext webApplicationContext) {
|
||||
return webApplicationContext.getServletContext().getServletRegistrations().values().stream()
|
||||
.map(ServletRegistrationMappingDescription::new).toList();
|
||||
return webApplicationContext.getServletContext()
|
||||
.getServletRegistrations()
|
||||
.values()
|
||||
.stream()
|
||||
.map(ServletRegistrationMappingDescription::new)
|
||||
.toList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user