mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add AOT support for actuator
Mainly adds reflection hints for the actuator infrastructure. Also adds the OperationReflectiveProcessor, which registers the @ReadMethod, @DeleteMethod and @WriteMethod annotated methods for reflection and adds reflection hints for method return types. See gh-31671
This commit is contained in:
parent
00ec17b418
commit
584b7d1343
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,6 +19,10 @@ package org.springframework.boot.actuate.autoconfigure.cloudfoundry;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer.CloudFoundryWebEndpointDiscovererRuntimeHints;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.invoke.OperationInvokerAdvisor;
|
import org.springframework.boot.actuate.endpoint.invoke.OperationInvokerAdvisor;
|
||||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||||
@ -29,6 +33,7 @@ import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExten
|
|||||||
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer;
|
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer;
|
||||||
import org.springframework.boot.actuate.health.HealthEndpoint;
|
import org.springframework.boot.actuate.health.HealthEndpoint;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.core.annotation.MergedAnnotations;
|
import org.springframework.core.annotation.MergedAnnotations;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,6 +43,7 @@ import org.springframework.core.annotation.MergedAnnotations;
|
|||||||
* @author Madhura Bhave
|
* @author Madhura Bhave
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(CloudFoundryWebEndpointDiscovererRuntimeHints.class)
|
||||||
public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
|
public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,4 +81,14 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer {
|
|||||||
return MergedAnnotations.from(extensionBeanType).isPresent(EndpointCloudFoundryExtension.class);
|
return MergedAnnotations.from(extensionBeanType).isPresent(EndpointCloudFoundryExtension.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class CloudFoundryWebEndpointDiscovererRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(CloudFoundryEndpointFilter.class,
|
||||||
|
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,14 +19,20 @@ package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.reactivestreams.Publisher;
|
import org.reactivestreams.Publisher;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
||||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryWebFluxEndpointHandlerMapping.CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
||||||
@ -35,6 +41,8 @@ import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.Link;
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping;
|
import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||||
@ -50,6 +58,7 @@ import org.springframework.web.server.ServerWebExchange;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints.class)
|
||||||
class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping {
|
class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping {
|
||||||
|
|
||||||
private final CloudFoundrySecurityInterceptor securityInterceptor;
|
private final CloudFoundrySecurityInterceptor securityInterceptor;
|
||||||
@ -145,4 +154,19 @@ class CloudFoundryWebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointH
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(CloudFoundryLinksHandler.class,
|
||||||
|
(hint) -> hint.onReachableType(TypeReference.of(CloudFoundryLinksHandler.class)).withMethod("links",
|
||||||
|
List.of(TypeReference.of(ServerWebExchange.class)),
|
||||||
|
(method) -> method.setModes(ExecutableMode.INVOKE)));
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -27,8 +28,13 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.AccessLevel;
|
||||||
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.SecurityResponse;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundryWebEndpointServletHandlerMapping.CloudFoundryWebEndpointServletHandlerMappingRuntimeHints;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
||||||
@ -37,6 +43,8 @@ import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.Link;
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping;
|
import org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
@ -51,6 +59,7 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMappi
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(CloudFoundryWebEndpointServletHandlerMappingRuntimeHints.class)
|
||||||
class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpointHandlerMapping {
|
class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpointHandlerMapping {
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(CloudFoundryWebEndpointServletHandlerMapping.class);
|
private static final Log logger = LogFactory.getLog(CloudFoundryWebEndpointServletHandlerMapping.class);
|
||||||
@ -147,4 +156,20 @@ class CloudFoundryWebEndpointServletHandlerMapping extends AbstractWebMvcEndpoin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class CloudFoundryWebEndpointServletHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(CloudFoundryLinksHandler.class,
|
||||||
|
(hint) -> hint.onReachableType(TypeReference.of(CloudFoundryLinksHandler.class)).withMethod("links",
|
||||||
|
List.of(TypeReference.of(HttpServletRequest.class),
|
||||||
|
TypeReference.of(HttpServletResponse.class)),
|
||||||
|
(method) -> method.setModes(ExecutableMode.INVOKE)));
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.beans.factory.ObjectProvider;
|
import org.springframework.beans.factory.ObjectProvider;
|
||||||
|
import org.springframework.boot.actuate.aot.ActuatorAnnotationsRuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.EndpointConverter;
|
import org.springframework.boot.actuate.endpoint.annotation.EndpointConverter;
|
||||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||||
@ -30,6 +31,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.convert.ApplicationConversionService;
|
import org.springframework.boot.convert.ApplicationConversionService;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
import org.springframework.core.convert.converter.Converter;
|
||||||
import org.springframework.core.convert.converter.GenericConverter;
|
import org.springframework.core.convert.converter.GenericConverter;
|
||||||
@ -45,6 +47,7 @@ import org.springframework.core.env.Environment;
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
|
@ImportRuntimeHints(ActuatorAnnotationsRuntimeHintsRegistrar.class)
|
||||||
public class EndpointAutoConfiguration {
|
public class EndpointAutoConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
@ -17,9 +17,12 @@
|
|||||||
package org.springframework.boot.actuate.autoconfigure.management;
|
package org.springframework.boot.actuate.autoconfigure.management;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
|
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnAvailableEndpoint;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.endpoint.expose.EndpointExposure;
|
||||||
import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpointWebExtension;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@ -39,4 +42,12 @@ public class ThreadDumpEndpointAutoConfiguration {
|
|||||||
return new ThreadDumpEndpoint();
|
return new ThreadDumpEndpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnBean(ThreadDumpEndpoint.class)
|
||||||
|
@ConditionalOnAvailableEndpoint(exposure = { EndpointExposure.WEB, EndpointExposure.CLOUD_FOUNDRY })
|
||||||
|
public ThreadDumpEndpointWebExtension threadDumpWebExtension(ThreadDumpEndpoint threadDumpEndpoint) {
|
||||||
|
return new ThreadDumpEndpointWebExtension(threadDumpEndpoint);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.cloudfoundry;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.CloudFoundryWebEndpointDiscoverer.CloudFoundryWebEndpointDiscovererRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link CloudFoundryWebEndpointDiscovererRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class CloudFoundryWebEndpointDiscovererRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final CloudFoundryWebEndpointDiscovererRuntimeHints sut = new CloudFoundryWebEndpointDiscovererRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(CloudFoundryEndpointFilter.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive;
|
||||||
|
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryWebFluxEndpointHandlerMapping.CloudFoundryLinksHandler;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.reactive.CloudFoundryWebFluxEndpointHandlerMapping.CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class CloudFoundryWebFluxEndpointHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints sut = new CloudFoundryWebFluxEndpointHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Assertions.assertThat(RuntimeHintsPredicates.reflection().onMethod(CloudFoundryLinksHandler.class, "links"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
Assertions.assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundryWebEndpointServletHandlerMapping.CloudFoundryLinksHandler;
|
||||||
|
import org.springframework.boot.actuate.autoconfigure.cloudfoundry.servlet.CloudFoundryWebEndpointServletHandlerMapping.CloudFoundryWebEndpointServletHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link CloudFoundryWebEndpointServletHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class CloudFoundryWebEndpointServletHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final CloudFoundryWebEndpointServletHandlerMappingRuntimeHints sut = new CloudFoundryWebEndpointServletHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(CloudFoundryLinksHandler.class, "links"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,6 +19,7 @@ package org.springframework.boot.actuate.autoconfigure.management;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpointWebExtension;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
import org.springframework.boot.autoconfigure.AutoConfigurations;
|
||||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* Tests for {@link ThreadDumpEndpointAutoConfiguration}.
|
* Tests for {@link ThreadDumpEndpointAutoConfiguration}.
|
||||||
*
|
*
|
||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
|
* @author Moritz Halbritter
|
||||||
*/
|
*/
|
||||||
class ThreadDumpEndpointAutoConfigurationTests {
|
class ThreadDumpEndpointAutoConfigurationTests {
|
||||||
|
|
||||||
@ -36,20 +38,27 @@ class ThreadDumpEndpointAutoConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void runShouldHaveEndpointBean() {
|
void runShouldHaveEndpointBean() {
|
||||||
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=threaddump")
|
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=threaddump").run((context) -> {
|
||||||
.run((context) -> assertThat(context).hasSingleBean(ThreadDumpEndpoint.class));
|
assertThat(context).hasSingleBean(ThreadDumpEndpoint.class);
|
||||||
|
assertThat(context).hasSingleBean(ThreadDumpEndpointWebExtension.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void runWhenNotExposedShouldNotHaveEndpointBean() {
|
void runWhenNotExposedShouldNotHaveEndpointBean() {
|
||||||
this.contextRunner.run((context) -> assertThat(context).doesNotHaveBean(ThreadDumpEndpoint.class));
|
this.contextRunner.run((context) -> {
|
||||||
|
assertThat(context).doesNotHaveBean(ThreadDumpEndpoint.class);
|
||||||
|
assertThat(context).doesNotHaveBean(ThreadDumpEndpointWebExtension.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
void runWhenEnabledPropertyIsFalseShouldNotHaveEndpointBean() {
|
||||||
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=*")
|
this.contextRunner.withPropertyValues("management.endpoints.web.exposure.include=*")
|
||||||
.withPropertyValues("management.endpoint.threaddump.enabled:false")
|
.withPropertyValues("management.endpoint.threaddump.enabled:false").run((context) -> {
|
||||||
.run((context) -> assertThat(context).doesNotHaveBean(ThreadDumpEndpoint.class));
|
assertThat(context).doesNotHaveBean(ThreadDumpEndpoint.class);
|
||||||
|
assertThat(context).doesNotHaveBean(ThreadDumpEndpointWebExtension.class);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.aot;
|
||||||
|
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.support.RuntimeHintsUtils;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||||
|
import org.springframework.core.annotation.SynthesizedAnnotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registrar which registers the annotations needed for actuator support.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
|
public class ActuatorAnnotationsRuntimeHintsRegistrar implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
Stream.of(Endpoint.class, ReadOperation.class, WriteOperation.class, DeleteOperation.class,
|
||||||
|
EndpointExtension.class)
|
||||||
|
.forEach((annotationType) -> RuntimeHintsUtils.registerAnnotation(hints, annotationType));
|
||||||
|
// TODO: See https://github.com/spring-projects/spring-framework/issues/28767
|
||||||
|
Stream.of(Endpoint.class, EndpointExtension.class).forEach(
|
||||||
|
(annotationType) -> hints.proxies().registerJdkProxy(annotationType, SynthesizedAnnotation.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support classes for actuator in AOT mode.
|
||||||
|
*/
|
||||||
|
package org.springframework.boot.actuate.aot;
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.annotation.Reflective;
|
||||||
import org.springframework.boot.actuate.endpoint.Producible;
|
import org.springframework.boot.actuate.endpoint.Producible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +35,7 @@ import org.springframework.boot.actuate.endpoint.Producible;
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
|
@Reflective(OperationReflectiveProcessor.class)
|
||||||
public @interface DeleteOperation {
|
public @interface DeleteOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.annotation.Reflective;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,6 +52,7 @@ import org.springframework.boot.actuate.endpoint.EndpointId;
|
|||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
|
@Reflective
|
||||||
public @interface Endpoint {
|
public @interface Endpoint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.annotation.Reflective;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.Operation;
|
import org.springframework.boot.actuate.endpoint.Operation;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
@ -51,6 +52,7 @@ import org.springframework.core.annotation.AliasFor;
|
|||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
|
@Reflective
|
||||||
public @interface EndpointExtension {
|
public @interface EndpointExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.annotation;
|
||||||
|
|
||||||
|
import java.lang.reflect.AnnotatedElement;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.ReflectionHints;
|
||||||
|
import org.springframework.aot.hint.annotation.ReflectiveProcessor;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
import org.springframework.core.ResolvableType;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processor which registers the annotated operation method and its return type for
|
||||||
|
* reflection.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class OperationReflectiveProcessor implements ReflectiveProcessor {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerReflectionHints(ReflectionHints hints, AnnotatedElement element) {
|
||||||
|
if (!(element instanceof Method method)) {
|
||||||
|
throw new IllegalArgumentException("This processor can only be invoked for annotated methods");
|
||||||
|
}
|
||||||
|
hints.registerMethod(method, (hint) -> hint.setModes(ExecutableMode.INVOKE));
|
||||||
|
registerReturnValueHints(hints, method);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerReturnValueHints(ReflectionHints hints, Method method) {
|
||||||
|
ResolvableType returnType = ResolvableType.forMethodReturnType(method);
|
||||||
|
if (WebEndpointResponse.class.isAssignableFrom(method.getReturnType())) {
|
||||||
|
registerWebEndpointResponse(hints, returnType);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
registerReflectionHints(hints, returnType.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerWebEndpointResponse(ReflectionHints hints, ResolvableType returnType) {
|
||||||
|
ResolvableType genericParameter = returnType.getGeneric(0);
|
||||||
|
if (genericParameter.getRawClass() != null) {
|
||||||
|
registerReflectionHints(hints, genericParameter.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerReflectionHints(ReflectionHints hints, Type type) {
|
||||||
|
if (type.equals(Resource.class)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.annotation.Reflective;
|
||||||
import org.springframework.boot.actuate.endpoint.Producible;
|
import org.springframework.boot.actuate.endpoint.Producible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,7 @@ import org.springframework.boot.actuate.endpoint.Producible;
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
|
@Reflective(OperationReflectiveProcessor.class)
|
||||||
public @interface ReadOperation {
|
public @interface ReadOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.annotation.Reflective;
|
||||||
import org.springframework.boot.actuate.endpoint.Producible;
|
import org.springframework.boot.actuate.endpoint.Producible;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,6 +34,7 @@ import org.springframework.boot.actuate.endpoint.Producible;
|
|||||||
@Target(ElementType.METHOD)
|
@Target(ElementType.METHOD)
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
|
@Reflective(OperationReflectiveProcessor.class)
|
||||||
public @interface WriteOperation {
|
public @interface WriteOperation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,6 +18,9 @@ package org.springframework.boot.actuate.endpoint.jmx.annotation;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod;
|
import org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod;
|
||||||
@ -28,7 +31,9 @@ import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
|||||||
import org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint;
|
import org.springframework.boot.actuate.endpoint.jmx.ExposableJmxEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.jmx.JmxEndpointsSupplier;
|
import org.springframework.boot.actuate.endpoint.jmx.JmxEndpointsSupplier;
|
||||||
import org.springframework.boot.actuate.endpoint.jmx.JmxOperation;
|
import org.springframework.boot.actuate.endpoint.jmx.JmxOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpointDiscoverer.JmxEndpointDiscovererRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EndpointDiscoverer} for {@link ExposableJmxEndpoint JMX endpoints}.
|
* {@link EndpointDiscoverer} for {@link ExposableJmxEndpoint JMX endpoints}.
|
||||||
@ -36,6 +41,7 @@ import org.springframework.context.ApplicationContext;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(JmxEndpointDiscovererRuntimeHints.class)
|
||||||
public class JmxEndpointDiscoverer extends EndpointDiscoverer<ExposableJmxEndpoint, JmxOperation>
|
public class JmxEndpointDiscoverer extends EndpointDiscoverer<ExposableJmxEndpoint, JmxOperation>
|
||||||
implements JmxEndpointsSupplier {
|
implements JmxEndpointsSupplier {
|
||||||
|
|
||||||
@ -69,4 +75,14 @@ public class JmxEndpointDiscoverer extends EndpointDiscoverer<ExposableJmxEndpoi
|
|||||||
return new OperationKey(operation.getName(), () -> "MBean call '" + operation.getName() + "'");
|
return new OperationKey(operation.getName(), () -> "MBean call '" + operation.getName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JmxEndpointDiscovererRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(JmxEndpointFilter.class,
|
||||||
|
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -20,6 +20,9 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.Operation;
|
import org.springframework.boot.actuate.endpoint.Operation;
|
||||||
@ -28,7 +31,9 @@ import org.springframework.boot.actuate.endpoint.annotation.EndpointDiscoverer;
|
|||||||
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
||||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||||
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.core.annotation.MergedAnnotations;
|
import org.springframework.core.annotation.MergedAnnotations;
|
||||||
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
||||||
|
|
||||||
@ -39,6 +44,7 @@ import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(ControllerEndpointDiscovererRuntimeHints.class)
|
||||||
public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableControllerEndpoint, Operation>
|
public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableControllerEndpoint, Operation>
|
||||||
implements ControllerEndpointsSupplier {
|
implements ControllerEndpointsSupplier {
|
||||||
|
|
||||||
@ -80,4 +86,14 @@ public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableCo
|
|||||||
throw new IllegalStateException("ControllerEndpoints must not declare operations");
|
throw new IllegalStateException("ControllerEndpoints must not declare operations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ControllerEndpointDiscovererRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(ControllerEndpointFilter.class,
|
||||||
|
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -20,6 +20,9 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.Operation;
|
import org.springframework.boot.actuate.endpoint.Operation;
|
||||||
@ -29,7 +32,9 @@ import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
|
|||||||
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
|
||||||
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
|
import org.springframework.boot.actuate.endpoint.web.ExposableServletEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.core.annotation.MergedAnnotations;
|
import org.springframework.core.annotation.MergedAnnotations;
|
||||||
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
||||||
|
|
||||||
@ -39,6 +44,7 @@ import org.springframework.core.annotation.MergedAnnotations.SearchStrategy;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(ServletEndpointDiscovererRuntimeHints.class)
|
||||||
public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServletEndpoint, Operation>
|
public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServletEndpoint, Operation>
|
||||||
implements ServletEndpointsSupplier {
|
implements ServletEndpointsSupplier {
|
||||||
|
|
||||||
@ -79,4 +85,14 @@ public class ServletEndpointDiscoverer extends EndpointDiscoverer<ExposableServl
|
|||||||
throw new IllegalStateException("ServletEndpoints must not declare operations");
|
throw new IllegalStateException("ServletEndpoints must not declare operations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ServletEndpointDiscovererRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(ServletEndpointFilter.class,
|
||||||
|
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,6 +19,9 @@ package org.springframework.boot.actuate.endpoint.web.annotation;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
import org.springframework.boot.actuate.endpoint.EndpointFilter;
|
||||||
import org.springframework.boot.actuate.endpoint.EndpointId;
|
import org.springframework.boot.actuate.endpoint.EndpointId;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod;
|
import org.springframework.boot.actuate.endpoint.annotation.DiscoveredOperationMethod;
|
||||||
@ -32,7 +35,9 @@ import org.springframework.boot.actuate.endpoint.web.PathMapper;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointsSupplier;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer.WebEndpointDiscovererRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EndpointDiscoverer} for {@link ExposableWebEndpoint web endpoints}.
|
* {@link EndpointDiscoverer} for {@link ExposableWebEndpoint web endpoints}.
|
||||||
@ -40,6 +45,7 @@ import org.springframework.context.ApplicationContext;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(WebEndpointDiscovererRuntimeHints.class)
|
||||||
public class WebEndpointDiscoverer extends EndpointDiscoverer<ExposableWebEndpoint, WebOperation>
|
public class WebEndpointDiscoverer extends EndpointDiscoverer<ExposableWebEndpoint, WebOperation>
|
||||||
implements WebEndpointsSupplier {
|
implements WebEndpointsSupplier {
|
||||||
|
|
||||||
@ -87,4 +93,14 @@ public class WebEndpointDiscoverer extends EndpointDiscoverer<ExposableWebEndpoi
|
|||||||
() -> "web request predicate " + operation.getRequestPredicate());
|
() -> "web request predicate " + operation.getRequestPredicate());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class WebEndpointDiscovererRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(WebEndpointFilter.class,
|
||||||
|
(hint) -> hint.withMembers(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import java.security.Principal;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ -30,6 +31,10 @@ import reactor.core.publisher.Flux;
|
|||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
import reactor.core.scheduler.Schedulers;
|
import reactor.core.scheduler.Schedulers;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException;
|
import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException;
|
||||||
import org.springframework.boot.actuate.endpoint.InvocationContext;
|
import org.springframework.boot.actuate.endpoint.InvocationContext;
|
||||||
import org.springframework.boot.actuate.endpoint.OperationArgumentResolver;
|
import org.springframework.boot.actuate.endpoint.OperationArgumentResolver;
|
||||||
@ -44,7 +49,9 @@ import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.AbstractWebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
@ -80,6 +87,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
|||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(AbstractWebFluxEndpointHandlerMappingRuntimeHints.class)
|
||||||
public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappingInfoHandlerMapping {
|
public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappingInfoHandlerMapping {
|
||||||
|
|
||||||
private final EndpointMapping endpointMapping;
|
private final EndpointMapping endpointMapping;
|
||||||
@ -484,4 +492,19 @@ public abstract class AbstractWebFluxEndpointHandlerMapping extends RequestMappi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class AbstractWebFluxEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(WriteOperationHandler.class,
|
||||||
|
(hint) -> hint.withMethod("handle",
|
||||||
|
List.of(TypeReference.of(ServerWebExchange.class), TypeReference.of(Map.class)),
|
||||||
|
(method) -> method.withMode(ExecutableMode.INVOKE)));
|
||||||
|
hints.reflection().registerType(ReadOperationHandler.class,
|
||||||
|
(hint) -> hint.withMethod("handle", List.of(TypeReference.of(ServerWebExchange.class)),
|
||||||
|
(method) -> method.withMode(ExecutableMode.INVOKE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,14 +18,22 @@ package org.springframework.boot.actuate.endpoint.web.reactive;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
||||||
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.Link;
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping.WebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.reactive.HandlerMapping;
|
import org.springframework.web.reactive.HandlerMapping;
|
||||||
@ -41,6 +49,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
|||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(WebFluxEndpointHandlerMappingRuntimeHints.class)
|
||||||
public class WebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping implements InitializingBean {
|
public class WebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping implements InitializingBean {
|
||||||
|
|
||||||
private final EndpointLinksResolver linksResolver;
|
private final EndpointLinksResolver linksResolver;
|
||||||
@ -89,4 +98,19 @@ public class WebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandle
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class WebFluxEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(WebFluxLinksHandler.class,
|
||||||
|
(hint) -> hint.onReachableType(TypeReference.of(WebFluxLinksHandler.class)).withMethod("links",
|
||||||
|
List.of(TypeReference.of(ServerWebExchange.class)),
|
||||||
|
(method) -> method.setModes(ExecutableMode.INVOKE)));
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,10 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException;
|
import org.springframework.boot.actuate.endpoint.InvalidEndpointRequestException;
|
||||||
import org.springframework.boot.actuate.endpoint.InvocationContext;
|
import org.springframework.boot.actuate.endpoint.InvocationContext;
|
||||||
@ -46,7 +50,9 @@ import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
import org.springframework.boot.actuate.endpoint.web.WebOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
import org.springframework.boot.actuate.endpoint.web.WebOperationRequestPredicate;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.AbstractWebMvcEndpointHandlerMappingRuntimeHints;
|
||||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -80,6 +86,7 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMappi
|
|||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(AbstractWebMvcEndpointHandlerMappingRuntimeHints.class)
|
||||||
public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappingInfoHandlerMapping
|
public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappingInfoHandlerMapping
|
||||||
implements InitializingBean {
|
implements InitializingBean {
|
||||||
|
|
||||||
@ -476,4 +483,16 @@ public abstract class AbstractWebMvcEndpointHandlerMapping extends RequestMappin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class AbstractWebMvcEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(OperationHandler.class,
|
||||||
|
(hint) -> hint.withMethod("handle",
|
||||||
|
List.of(TypeReference.of(HttpServletRequest.class), TypeReference.of(Map.class)),
|
||||||
|
(method) -> method.withMode(ExecutableMode.INVOKE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,16 +18,24 @@ package org.springframework.boot.actuate.endpoint.web.servlet;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
import org.springframework.boot.actuate.endpoint.web.EndpointLinksResolver;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMapping;
|
||||||
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes;
|
||||||
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.web.Link;
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.WebMvcEndpointHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
import org.springframework.web.servlet.HandlerMapping;
|
import org.springframework.web.servlet.HandlerMapping;
|
||||||
@ -40,6 +48,7 @@ import org.springframework.web.servlet.HandlerMapping;
|
|||||||
* @author Phillip Webb
|
* @author Phillip Webb
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(WebMvcEndpointHandlerMappingRuntimeHints.class)
|
||||||
public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping {
|
public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping {
|
||||||
|
|
||||||
private final EndpointLinksResolver linksResolver;
|
private final EndpointLinksResolver linksResolver;
|
||||||
@ -86,4 +95,20 @@ public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerM
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class WebMvcEndpointHandlerMappingRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(WebMvcLinksHandler.class,
|
||||||
|
(hint) -> hint.onReachableType(TypeReference.of(WebMvcLinksHandler.class)).withMethod("links",
|
||||||
|
List.of(TypeReference.of(HttpServletRequest.class),
|
||||||
|
TypeReference.of(HttpServletResponse.class)),
|
||||||
|
(method) -> method.setModes(ExecutableMode.INVOKE)));
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Link.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import java.util.Arrays;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.ApiVersion;
|
import org.springframework.boot.actuate.endpoint.ApiVersion;
|
||||||
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
import org.springframework.boot.actuate.endpoint.SecurityContext;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
@ -29,6 +31,9 @@ import org.springframework.boot.actuate.endpoint.annotation.Selector.Match;
|
|||||||
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
import org.springframework.boot.actuate.endpoint.web.WebServerNamespace;
|
||||||
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
|
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
|
||||||
|
import org.springframework.boot.actuate.health.HealthEndpointWebExtension.HealthEndpointWebExtensionRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EndpointWebExtension @EndpointWebExtension} for the {@link HealthEndpoint}.
|
* {@link EndpointWebExtension @EndpointWebExtension} for the {@link HealthEndpoint}.
|
||||||
@ -44,6 +49,7 @@ import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExten
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@EndpointWebExtension(endpoint = HealthEndpoint.class)
|
@EndpointWebExtension(endpoint = HealthEndpoint.class)
|
||||||
|
@ImportRuntimeHints(HealthEndpointWebExtensionRuntimeHints.class)
|
||||||
public class HealthEndpointWebExtension extends HealthEndpointSupport<HealthContributor, HealthComponent> {
|
public class HealthEndpointWebExtension extends HealthEndpointSupport<HealthContributor, HealthComponent> {
|
||||||
|
|
||||||
private static final String[] NO_PATH = {};
|
private static final String[] NO_PATH = {};
|
||||||
@ -110,4 +116,16 @@ public class HealthEndpointWebExtension extends HealthEndpointSupport<HealthCont
|
|||||||
return getCompositeHealth(apiVersion, contributions, statusAggregator, showComponents, groupNames);
|
return getCompositeHealth(apiVersion, contributions, statusAggregator, showComponents, groupNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class HealthEndpointWebExtensionRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Health.class, SystemHealth.class,
|
||||||
|
CompositeHealth.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -19,7 +19,12 @@ package org.springframework.boot.actuate.info;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.actuate.info.BuildInfoContributor.BuildInfoContributorRuntimeHints;
|
||||||
import org.springframework.boot.info.BuildProperties;
|
import org.springframework.boot.info.BuildProperties;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
import org.springframework.core.env.PropertiesPropertySource;
|
||||||
import org.springframework.core.env.PropertySource;
|
import org.springframework.core.env.PropertySource;
|
||||||
|
|
||||||
@ -29,6 +34,7 @@ import org.springframework.core.env.PropertySource;
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(BuildInfoContributorRuntimeHints.class)
|
||||||
public class BuildInfoContributor extends InfoPropertiesInfoContributor<BuildProperties> {
|
public class BuildInfoContributor extends InfoPropertiesInfoContributor<BuildProperties> {
|
||||||
|
|
||||||
public BuildInfoContributor(BuildProperties properties) {
|
public BuildInfoContributor(BuildProperties properties) {
|
||||||
@ -56,4 +62,15 @@ public class BuildInfoContributor extends InfoPropertiesInfoContributor<BuildPro
|
|||||||
replaceValue(content, "time", getProperties().getTime());
|
replaceValue(content, "time", getProperties().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class BuildInfoContributorRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), BuildProperties.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -20,7 +20,12 @@ import java.time.Instant;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.actuate.info.GitInfoContributor.GitInfoContributorRuntimeHints;
|
||||||
import org.springframework.boot.info.GitProperties;
|
import org.springframework.boot.info.GitProperties;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.core.env.PropertiesPropertySource;
|
import org.springframework.core.env.PropertiesPropertySource;
|
||||||
import org.springframework.core.env.PropertySource;
|
import org.springframework.core.env.PropertySource;
|
||||||
|
|
||||||
@ -30,6 +35,7 @@ import org.springframework.core.env.PropertySource;
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(GitInfoContributorRuntimeHints.class)
|
||||||
public class GitInfoContributor extends InfoPropertiesInfoContributor<GitProperties> {
|
public class GitInfoContributor extends InfoPropertiesInfoContributor<GitProperties> {
|
||||||
|
|
||||||
public GitInfoContributor(GitProperties properties) {
|
public GitInfoContributor(GitProperties properties) {
|
||||||
@ -68,4 +74,15 @@ public class GitInfoContributor extends InfoPropertiesInfoContributor<GitPropert
|
|||||||
replaceValue(getNestedMap(content, "build"), "time", getProperties().getInstant("build.time"));
|
replaceValue(getNestedMap(content, "build"), "time", getProperties().getInstant("build.time"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class GitInfoContributorRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), GitProperties.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,8 +16,13 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.info;
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.info.Info.Builder;
|
import org.springframework.boot.actuate.info.Info.Builder;
|
||||||
|
import org.springframework.boot.actuate.info.JavaInfoContributor.JavaInfoContributorRuntimeHints;
|
||||||
import org.springframework.boot.info.JavaInfo;
|
import org.springframework.boot.info.JavaInfo;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link InfoContributor} that exposes {@link JavaInfo}.
|
* An {@link InfoContributor} that exposes {@link JavaInfo}.
|
||||||
@ -25,6 +30,7 @@ import org.springframework.boot.info.JavaInfo;
|
|||||||
* @author Jonatan Ivanov
|
* @author Jonatan Ivanov
|
||||||
* @since 2.6.0
|
* @since 2.6.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(JavaInfoContributorRuntimeHints.class)
|
||||||
public class JavaInfoContributor implements InfoContributor {
|
public class JavaInfoContributor implements InfoContributor {
|
||||||
|
|
||||||
private final JavaInfo javaInfo;
|
private final JavaInfo javaInfo;
|
||||||
@ -38,4 +44,15 @@ public class JavaInfoContributor implements InfoContributor {
|
|||||||
builder.withDetail("java", this.javaInfo);
|
builder.withDetail("java", this.javaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class JavaInfoContributorRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), JavaInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.info;
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.actuate.info.OsInfoContributor.OsInfoContributorRuntimeHints;
|
||||||
import org.springframework.boot.info.OsInfo;
|
import org.springframework.boot.info.OsInfo;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link InfoContributor} that exposes {@link OsInfo}.
|
* An {@link InfoContributor} that exposes {@link OsInfo}.
|
||||||
@ -24,6 +29,7 @@ import org.springframework.boot.info.OsInfo;
|
|||||||
* @author Jonatan Ivanov
|
* @author Jonatan Ivanov
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(OsInfoContributorRuntimeHints.class)
|
||||||
public class OsInfoContributor implements InfoContributor {
|
public class OsInfoContributor implements InfoContributor {
|
||||||
|
|
||||||
private final OsInfo osInfo;
|
private final OsInfo osInfo;
|
||||||
@ -37,4 +43,15 @@ public class OsInfoContributor implements InfoContributor {
|
|||||||
builder.withDetail("os", this.osInfo);
|
builder.withDetail("os", this.osInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class OsInfoContributorRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), OsInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,11 +16,31 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.integration;
|
package org.springframework.boot.actuate.integration;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||||
|
import org.springframework.boot.actuate.integration.IntegrationGraphEndpoint.IntegrationGraphEndpointRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
import org.springframework.integration.graph.CompositeMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.DiscardingMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.EndpointNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableCompositeMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableDiscardingMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableEndpointNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableRoutingNode;
|
||||||
import org.springframework.integration.graph.Graph;
|
import org.springframework.integration.graph.Graph;
|
||||||
import org.springframework.integration.graph.IntegrationGraphServer;
|
import org.springframework.integration.graph.IntegrationGraphServer;
|
||||||
|
import org.springframework.integration.graph.MessageChannelNode;
|
||||||
|
import org.springframework.integration.graph.MessageGatewayNode;
|
||||||
|
import org.springframework.integration.graph.MessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.MessageProducerNode;
|
||||||
|
import org.springframework.integration.graph.MessageSourceNode;
|
||||||
|
import org.springframework.integration.graph.PollableChannelNode;
|
||||||
|
import org.springframework.integration.graph.RoutingMessageHandlerNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Endpoint @Endpoint} to expose the Spring Integration graph.
|
* {@link Endpoint @Endpoint} to expose the Spring Integration graph.
|
||||||
@ -29,6 +49,7 @@ import org.springframework.integration.graph.IntegrationGraphServer;
|
|||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
*/
|
*/
|
||||||
@Endpoint(id = "integrationgraph")
|
@Endpoint(id = "integrationgraph")
|
||||||
|
@ImportRuntimeHints(IntegrationGraphEndpointRuntimeHints.class)
|
||||||
public class IntegrationGraphEndpoint {
|
public class IntegrationGraphEndpoint {
|
||||||
|
|
||||||
private final IntegrationGraphServer graphServer;
|
private final IntegrationGraphServer graphServer;
|
||||||
@ -53,4 +74,21 @@ public class IntegrationGraphEndpoint {
|
|||||||
this.graphServer.rebuild();
|
this.graphServer.rebuild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class IntegrationGraphEndpointRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), Graph.class,
|
||||||
|
CompositeMessageHandlerNode.class, DiscardingMessageHandlerNode.class, EndpointNode.class,
|
||||||
|
ErrorCapableCompositeMessageHandlerNode.class, ErrorCapableDiscardingMessageHandlerNode.class,
|
||||||
|
ErrorCapableEndpointNode.class, ErrorCapableMessageHandlerNode.class, ErrorCapableRoutingNode.class,
|
||||||
|
MessageChannelNode.class, MessageGatewayNode.class, MessageHandlerNode.class,
|
||||||
|
MessageProducerNode.class, MessageSourceNode.class, PollableChannelNode.class,
|
||||||
|
RoutingMessageHandlerNode.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,6 +24,7 @@ import java.util.function.Function;
|
|||||||
|
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.core.NativeDetector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Endpoint @Endpoint} to expose thread info.
|
* {@link Endpoint @Endpoint} to expose thread info.
|
||||||
@ -48,7 +49,41 @@ public class ThreadDumpEndpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T> T getFormattedThreadDump(Function<ThreadInfo[], T> formatter) {
|
private <T> T getFormattedThreadDump(Function<ThreadInfo[], T> formatter) {
|
||||||
return formatter.apply(ManagementFactory.getThreadMXBean().dumpAllThreads(true, true));
|
ThreadDumper threadDumper = createThreadDumper();
|
||||||
|
return formatter.apply(threadDumper.dumpAllThreads());
|
||||||
|
}
|
||||||
|
|
||||||
|
private ThreadDumper createThreadDumper() {
|
||||||
|
if (NativeDetector.inNativeImage()) {
|
||||||
|
throw new ThreadDumperUnavailableException("Running in native image");
|
||||||
|
}
|
||||||
|
return new ThreadMXBeanThreadDumper();
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface ThreadDumper {
|
||||||
|
|
||||||
|
ThreadInfo[] dumpAllThreads();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ThreadMXBeanThreadDumper implements ThreadDumper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ThreadInfo[] dumpAllThreads() {
|
||||||
|
return ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception to be thrown if the {@link ThreadDumper} cannot be created.
|
||||||
|
*/
|
||||||
|
static class ThreadDumperUnavailableException extends RuntimeException {
|
||||||
|
|
||||||
|
ThreadDumperUnavailableException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.management;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint.ThreadDumpDescriptor;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint.ThreadDumperUnavailableException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link EndpointWebExtension @EndpointWebExtension} for the {@link ThreadDumpEndpoint}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
* @since 3.0.0
|
||||||
|
*/
|
||||||
|
@EndpointWebExtension(endpoint = ThreadDumpEndpoint.class)
|
||||||
|
public class ThreadDumpEndpointWebExtension {
|
||||||
|
|
||||||
|
private final ThreadDumpEndpoint delegate;
|
||||||
|
|
||||||
|
public ThreadDumpEndpointWebExtension(ThreadDumpEndpoint delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReadOperation
|
||||||
|
public WebEndpointResponse<ThreadDumpDescriptor> threadDump() {
|
||||||
|
try {
|
||||||
|
return new WebEndpointResponse<>(this.delegate.threadDump());
|
||||||
|
}
|
||||||
|
catch (ThreadDumperUnavailableException ex) {
|
||||||
|
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ReadOperation(produces = "text/plain;charset=UTF-8")
|
||||||
|
public WebEndpointResponse<String> textThreadDump() {
|
||||||
|
try {
|
||||||
|
return new WebEndpointResponse<>(this.delegate.textThreadDump());
|
||||||
|
}
|
||||||
|
catch (ThreadDumperUnavailableException ex) {
|
||||||
|
return new WebEndpointResponse<>(WebEndpointResponse.STATUS_SERVICE_UNAVAILABLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,12 +17,19 @@
|
|||||||
package org.springframework.boot.actuate.metrics.cache;
|
package org.springframework.boot.actuate.metrics.cache;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.hazelcast.spring.cache.HazelcastCache;
|
import com.hazelcast.spring.cache.HazelcastCache;
|
||||||
import io.micrometer.core.instrument.Tag;
|
import io.micrometer.core.instrument.Tag;
|
||||||
import io.micrometer.core.instrument.binder.MeterBinder;
|
import io.micrometer.core.instrument.binder.MeterBinder;
|
||||||
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
|
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.ExecutableMode;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
import org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.HazelcastCacheMeterBinderProviderRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +38,7 @@ import org.springframework.util.ReflectionUtils;
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(HazelcastCacheMeterBinderProviderRuntimeHints.class)
|
||||||
public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvider<HazelcastCache> {
|
public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvider<HazelcastCache> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,4 +64,18 @@ public class HazelcastCacheMeterBinderProvider implements CacheMeterBinderProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class HazelcastCacheMeterBinderProviderRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(HazelcastCache.class, (hint) -> hint.withMethod("getNativeCache", List.of(),
|
||||||
|
(method) -> method.withMode(ExecutableMode.INVOKE)));
|
||||||
|
hints.reflection().registerType(HazelcastCacheMetrics.class,
|
||||||
|
(hint) -> hint.withConstructor(
|
||||||
|
List.of(TypeReference.of(Object.class), TypeReference.of(Iterable.class)),
|
||||||
|
(ctor) -> ctor.withMode(ExecutableMode.INVOKE)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -18,11 +18,19 @@ package org.springframework.boot.actuate.quartz;
|
|||||||
|
|
||||||
import org.quartz.SchedulerException;
|
import org.quartz.SchedulerException;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Selector;
|
import org.springframework.boot.actuate.endpoint.annotation.Selector;
|
||||||
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
|
import org.springframework.boot.actuate.endpoint.web.annotation.EndpointWebExtension;
|
||||||
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummary;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension.QuartzEndpointWebExtensionRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link EndpointWebExtension @EndpointWebExtension} for the {@link QuartzEndpoint}.
|
* {@link EndpointWebExtension @EndpointWebExtension} for the {@link QuartzEndpoint}.
|
||||||
@ -31,6 +39,7 @@ import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
|
|||||||
* @since 2.5.0
|
* @since 2.5.0
|
||||||
*/
|
*/
|
||||||
@EndpointWebExtension(endpoint = QuartzEndpoint.class)
|
@EndpointWebExtension(endpoint = QuartzEndpoint.class)
|
||||||
|
@ImportRuntimeHints(QuartzEndpointWebExtensionRuntimeHints.class)
|
||||||
public class QuartzEndpointWebExtension {
|
public class QuartzEndpointWebExtension {
|
||||||
|
|
||||||
private final QuartzEndpoint delegate;
|
private final QuartzEndpoint delegate;
|
||||||
@ -84,4 +93,16 @@ public class QuartzEndpointWebExtension {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class QuartzEndpointWebExtensionRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), QuartzGroups.class,
|
||||||
|
QuartzJobDetails.class, QuartzJobGroupSummary.class, QuartzTriggerGroupSummary.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,13 @@ import java.util.Objects;
|
|||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.ScheduledTasksEndpointRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.scheduling.Trigger;
|
import org.springframework.scheduling.Trigger;
|
||||||
import org.springframework.scheduling.config.CronTask;
|
import org.springframework.scheduling.config.CronTask;
|
||||||
import org.springframework.scheduling.config.FixedDelayTask;
|
import org.springframework.scheduling.config.FixedDelayTask;
|
||||||
@ -49,6 +54,7 @@ import org.springframework.scheduling.support.ScheduledMethodRunnable;
|
|||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
@Endpoint(id = "scheduledtasks")
|
@Endpoint(id = "scheduledtasks")
|
||||||
|
@ImportRuntimeHints(ScheduledTasksEndpointRuntimeHints.class)
|
||||||
public class ScheduledTasksEndpoint {
|
public class ScheduledTasksEndpoint {
|
||||||
|
|
||||||
private final Collection<ScheduledTaskHolder> scheduledTaskHolders;
|
private final Collection<ScheduledTaskHolder> scheduledTaskHolders;
|
||||||
@ -295,4 +301,16 @@ public class ScheduledTasksEndpoint {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ScheduledTasksEndpointRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(), FixedRateTaskDescription.class,
|
||||||
|
FixedDelayTaskDescription.class, CronTaskDescription.class, CustomTriggerTaskDescription.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2021 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -16,12 +16,18 @@
|
|||||||
|
|
||||||
package org.springframework.boot.actuate.startup;
|
package org.springframework.boot.actuate.startup;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
import org.springframework.boot.SpringBootVersion;
|
import org.springframework.boot.SpringBootVersion;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||||
|
import org.springframework.boot.actuate.startup.StartupEndpoint.StartupEndpointRuntimeHints;
|
||||||
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup;
|
||||||
import org.springframework.boot.context.metrics.buffering.StartupTimeline;
|
import org.springframework.boot.context.metrics.buffering.StartupTimeline;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Endpoint @Endpoint} to expose the timeline of the
|
* {@link Endpoint @Endpoint} to expose the timeline of the
|
||||||
@ -33,6 +39,7 @@ import org.springframework.boot.context.metrics.buffering.StartupTimeline;
|
|||||||
* @since 2.4.0
|
* @since 2.4.0
|
||||||
*/
|
*/
|
||||||
@Endpoint(id = "startup")
|
@Endpoint(id = "startup")
|
||||||
|
@ImportRuntimeHints(StartupEndpointRuntimeHints.class)
|
||||||
public class StartupEndpoint {
|
public class StartupEndpoint {
|
||||||
|
|
||||||
private final BufferingApplicationStartup applicationStartup;
|
private final BufferingApplicationStartup applicationStartup;
|
||||||
@ -83,4 +90,26 @@ public class StartupEndpoint {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class StartupEndpointRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.reflection().registerType(
|
||||||
|
TypeReference
|
||||||
|
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep$DefaultTag"),
|
||||||
|
(hint) -> hint
|
||||||
|
.onReachableType(TypeReference
|
||||||
|
.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep"))
|
||||||
|
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||||
|
hints.reflection().registerType(
|
||||||
|
TypeReference
|
||||||
|
.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep$FlightRecorderTag"),
|
||||||
|
(hint) -> hint
|
||||||
|
.onReachableType(
|
||||||
|
TypeReference.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep"))
|
||||||
|
.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2020 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -28,9 +28,14 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.web.mappings.HandlerMethodDescription;
|
import org.springframework.boot.actuate.web.mappings.HandlerMethodDescription;
|
||||||
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider.DispatcherHandlersMappingDescriptionProviderRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.reactive.DispatcherHandler;
|
import org.springframework.web.reactive.DispatcherHandler;
|
||||||
@ -53,6 +58,7 @@ import org.springframework.web.util.pattern.PathPattern;
|
|||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(DispatcherHandlersMappingDescriptionProviderRuntimeHints.class)
|
||||||
public class DispatcherHandlersMappingDescriptionProvider implements MappingDescriptionProvider {
|
public class DispatcherHandlersMappingDescriptionProvider implements MappingDescriptionProvider {
|
||||||
|
|
||||||
private static final List<HandlerMappingDescriptionProvider<? extends HandlerMapping>> descriptionProviders = Arrays
|
private static final List<HandlerMappingDescriptionProvider<? extends HandlerMapping>> descriptionProviders = Arrays
|
||||||
@ -194,4 +200,16 @@ public class DispatcherHandlersMappingDescriptionProvider implements MappingDesc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class DispatcherHandlersMappingDescriptionProviderRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(),
|
||||||
|
DispatcherHandlerMappingDescription.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,15 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
import jakarta.servlet.Servlet;
|
import jakarta.servlet.Servlet;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.web.mappings.HandlerMethodDescription;
|
import org.springframework.boot.actuate.web.mappings.HandlerMethodDescription;
|
||||||
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletsMappingDescriptionProvider.DispatcherServletsMappingDescriptionProviderRuntimeHints;
|
||||||
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
import org.springframework.boot.web.servlet.ServletRegistrationBean;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.DispatcherServlet;
|
import org.springframework.web.servlet.DispatcherServlet;
|
||||||
@ -49,6 +54,7 @@ import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMappi
|
|||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(DispatcherServletsMappingDescriptionProviderRuntimeHints.class)
|
||||||
public class DispatcherServletsMappingDescriptionProvider implements MappingDescriptionProvider {
|
public class DispatcherServletsMappingDescriptionProvider implements MappingDescriptionProvider {
|
||||||
|
|
||||||
private static final List<HandlerMappingDescriptionProvider<?>> descriptionProviders;
|
private static final List<HandlerMappingDescriptionProvider<?>> descriptionProviders;
|
||||||
@ -195,4 +201,16 @@ public class DispatcherServletsMappingDescriptionProvider implements MappingDesc
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class DispatcherServletsMappingDescriptionProviderRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(),
|
||||||
|
DispatcherServletMappingDescription.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,13 @@ import java.util.stream.Collectors;
|
|||||||
import jakarta.servlet.Filter;
|
import jakarta.servlet.Filter;
|
||||||
import jakarta.servlet.ServletContext;
|
import jakarta.servlet.ServletContext;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.FiltersMappingDescriptionProvider.FiltersMappingDescriptionProviderRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +39,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(FiltersMappingDescriptionProviderRuntimeHints.class)
|
||||||
public class FiltersMappingDescriptionProvider implements MappingDescriptionProvider {
|
public class FiltersMappingDescriptionProvider implements MappingDescriptionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,4 +56,16 @@ public class FiltersMappingDescriptionProvider implements MappingDescriptionProv
|
|||||||
return "servletFilters";
|
return "servletFilters";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class FiltersMappingDescriptionProviderRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(),
|
||||||
|
FilterRegistrationMappingDescription.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,13 @@ import java.util.stream.Collectors;
|
|||||||
import jakarta.servlet.Servlet;
|
import jakarta.servlet.Servlet;
|
||||||
import jakarta.servlet.ServletContext;
|
import jakarta.servlet.ServletContext;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
import org.springframework.boot.actuate.web.mappings.MappingDescriptionProvider;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.ServletsMappingDescriptionProvider.ServletsMappingDescriptionProviderRuntimeHints;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
import org.springframework.context.aot.BindingReflectionHintsRegistrar;
|
||||||
import org.springframework.web.context.WebApplicationContext;
|
import org.springframework.web.context.WebApplicationContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +39,7 @@ import org.springframework.web.context.WebApplicationContext;
|
|||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(ServletsMappingDescriptionProviderRuntimeHints.class)
|
||||||
public class ServletsMappingDescriptionProvider implements MappingDescriptionProvider {
|
public class ServletsMappingDescriptionProvider implements MappingDescriptionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,4 +56,16 @@ public class ServletsMappingDescriptionProvider implements MappingDescriptionPro
|
|||||||
return "servlets";
|
return "servlets";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ServletsMappingDescriptionProviderRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
private final BindingReflectionHintsRegistrar bindingRegistrar = new BindingReflectionHintsRegistrar();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
this.bindingRegistrar.registerReflectionHints(hints.reflection(),
|
||||||
|
ServletRegistrationMappingDescription.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.aot;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.DeleteOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.Endpoint;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
||||||
|
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||||
|
import org.springframework.core.annotation.SynthesizedAnnotation;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ActuatorAnnotationsRuntimeHintsRegistrar}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ActuatorAnnotationsRuntimeHintsRegistrarTests {
|
||||||
|
|
||||||
|
private final ActuatorAnnotationsRuntimeHintsRegistrar sut = new ActuatorAnnotationsRuntimeHintsRegistrar();
|
||||||
|
|
||||||
|
private RuntimeHints runtimeHints;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
this.runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(this.runtimeHints, getClass().getClassLoader());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterReflectionHints() {
|
||||||
|
Set<Class<?>> annotations = Set.of(Endpoint.class, ReadOperation.class, WriteOperation.class,
|
||||||
|
DeleteOperation.class, EndpointExtension.class);
|
||||||
|
for (Class<?> annotation : annotations) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(annotation)
|
||||||
|
.withAnyMemberCategory(MemberCategory.INVOKE_DECLARED_METHODS)).accepts(this.runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterProxyHints() {
|
||||||
|
Set<Class<?>> synthesizedAnnotations = Set.of(Endpoint.class, EndpointExtension.class);
|
||||||
|
for (Class<?> synthesizedAnnotation : synthesizedAnnotations) {
|
||||||
|
assertThat(
|
||||||
|
RuntimeHintsPredicates.proxies().forInterfaces(synthesizedAnnotation, SynthesizedAnnotation.class))
|
||||||
|
.accepts(this.runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.annotation;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link OperationReflectiveProcessor}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class OperationReflectiveProcessorTests {
|
||||||
|
|
||||||
|
private final OperationReflectiveProcessor sut = new OperationReflectiveProcessor();
|
||||||
|
|
||||||
|
private RuntimeHints runtimeHints;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
this.runtimeHints = new RuntimeHints();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterMethodAsInvokable() {
|
||||||
|
Method method = ReflectionUtils.findMethod(Methods.class, "string");
|
||||||
|
runProcessor(method);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(method)).accepts(this.runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterReturnType() {
|
||||||
|
Method method = ReflectionUtils.findMethod(Methods.class, "dto");
|
||||||
|
runProcessor(method);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Dto.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(this.runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(NestedDto.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(this.runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterWebEndpointResponseReturnType() {
|
||||||
|
Method method = ReflectionUtils.findMethod(Methods.class, "webEndpointResponse");
|
||||||
|
runProcessor(method);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Dto.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(this.runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(NestedDto.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(this.runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(WebEndpointResponse.class)).rejects(this.runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotRegisterResourceReturnType() {
|
||||||
|
Method method = ReflectionUtils.findMethod(Methods.class, "resource");
|
||||||
|
runProcessor(method);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Resource.class)).rejects(this.runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runProcessor(Method method) {
|
||||||
|
this.sut.registerReflectionHints(this.runtimeHints.reflection(), method);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class Methods {
|
||||||
|
|
||||||
|
private String string() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Dto dto() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WebEndpointResponse<Dto> webEndpointResponse() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Resource resource() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Dto {
|
||||||
|
|
||||||
|
private final NestedDto nestedDto = new NestedDto();
|
||||||
|
|
||||||
|
public NestedDto getNestedDto() {
|
||||||
|
return this.nestedDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class NestedDto {
|
||||||
|
|
||||||
|
private final String string = "some-string";
|
||||||
|
|
||||||
|
public String getString() {
|
||||||
|
return this.string;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.jmx.annotation;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.jmx.annotation.JmxEndpointDiscoverer.JmxEndpointDiscovererRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link JmxEndpointDiscovererRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class JmxEndpointDiscovererRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final JmxEndpointDiscovererRuntimeHints sut = new JmxEndpointDiscovererRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(JmxEndpointFilter.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.annotation;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ControllerEndpointDiscovererRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ControllerEndpointDiscovererRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final ControllerEndpointDiscovererRuntimeHints sut = new ControllerEndpointDiscovererRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(ControllerEndpointFilter.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.annotation;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.ServletEndpointDiscoverer.ServletEndpointDiscovererRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ServletEndpointDiscovererRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ServletEndpointDiscovererRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final ServletEndpointDiscovererRuntimeHints sut = new ServletEndpointDiscovererRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(ServletEndpointFilter.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.annotation;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.annotation.WebEndpointDiscoverer.WebEndpointDiscovererRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link WebEndpointDiscovererRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class WebEndpointDiscovererRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final WebEndpointDiscovererRuntimeHints sut = new WebEndpointDiscovererRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(WebEndpointFilter.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS)).accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.reactive;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.AbstractWebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link AbstractWebFluxEndpointHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class AbstractWebFluxEndpointHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final AbstractWebFluxEndpointHandlerMappingRuntimeHints sut = new AbstractWebFluxEndpointHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of(
|
||||||
|
"org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.WriteOperationHandler")))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of(
|
||||||
|
"org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.ReadOperationHandler")))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.reactive;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping.WebFluxEndpointHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping.WebFluxLinksHandler;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link WebFluxEndpointHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class WebFluxEndpointHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final WebFluxEndpointHandlerMappingRuntimeHints sut = new WebFluxEndpointHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(WebFluxLinksHandler.class, "links"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.AbstractWebMvcEndpointHandlerMappingRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link AbstractWebMvcEndpointHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class AbstractWebMvcEndpointHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final AbstractWebMvcEndpointHandlerMappingRuntimeHints sut = new AbstractWebMvcEndpointHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(TypeReference.of(
|
||||||
|
"org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.OperationHandler")))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.endpoint.web.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.Link;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.WebMvcEndpointHandlerMappingRuntimeHints;
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.WebMvcLinksHandler;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link WebMvcEndpointHandlerMappingRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class WebMvcEndpointHandlerMappingRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final WebMvcEndpointHandlerMappingRuntimeHints sut = new WebMvcEndpointHandlerMappingRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(WebMvcLinksHandler.class, "links"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(Link.class)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.health;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.health.HealthEndpointWebExtension.HealthEndpointWebExtensionRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link HealthEndpointWebExtensionRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class HealthEndpointWebExtensionRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final HealthEndpointWebExtensionRuntimeHints sut = new HealthEndpointWebExtensionRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Set<Class<?>> bindingTypes = Set.of(Health.class, SystemHealth.class, CompositeHealth.class);
|
||||||
|
for (Class<?> bindingType : bindingTypes) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.info.BuildInfoContributor.BuildInfoContributorRuntimeHints;
|
||||||
|
import org.springframework.boot.info.BuildProperties;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link BuildInfoContributorRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class BuildInfoContributorRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final BuildInfoContributorRuntimeHints sut = new BuildInfoContributorRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(BuildProperties.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.info.GitInfoContributor.GitInfoContributorRuntimeHints;
|
||||||
|
import org.springframework.boot.info.GitProperties;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests forr {@link GitInfoContributorRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class GitInfoContributorRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final GitInfoContributorRuntimeHints sut = new GitInfoContributorRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(GitProperties.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.info.JavaInfoContributor.JavaInfoContributorRuntimeHints;
|
||||||
|
import org.springframework.boot.info.JavaInfo;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link JavaInfoContributorRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class JavaInfoContributorRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final JavaInfoContributorRuntimeHints sut = new JavaInfoContributorRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(JavaInfo.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.info.OsInfoContributor.OsInfoContributorRuntimeHints;
|
||||||
|
import org.springframework.boot.info.OsInfo;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link OsInfoContributorRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class OsInfoContributorRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final OsInfoContributorRuntimeHints sut = new OsInfoContributorRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(OsInfo.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.integration;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.integration.IntegrationGraphEndpoint.IntegrationGraphEndpointRuntimeHints;
|
||||||
|
import org.springframework.integration.graph.CompositeMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.DiscardingMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.EndpointNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableCompositeMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableDiscardingMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableEndpointNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableMessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.ErrorCapableRoutingNode;
|
||||||
|
import org.springframework.integration.graph.Graph;
|
||||||
|
import org.springframework.integration.graph.MessageChannelNode;
|
||||||
|
import org.springframework.integration.graph.MessageGatewayNode;
|
||||||
|
import org.springframework.integration.graph.MessageHandlerNode;
|
||||||
|
import org.springframework.integration.graph.MessageProducerNode;
|
||||||
|
import org.springframework.integration.graph.MessageSourceNode;
|
||||||
|
import org.springframework.integration.graph.PollableChannelNode;
|
||||||
|
import org.springframework.integration.graph.RoutingMessageHandlerNode;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link IntegrationGraphEndpointRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class IntegrationGraphEndpointRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final IntegrationGraphEndpointRuntimeHints sut = new IntegrationGraphEndpointRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Set<Class<?>> bindingTypes = Set.of(Graph.class, EndpointNode.class, CompositeMessageHandlerNode.class,
|
||||||
|
DiscardingMessageHandlerNode.class, ErrorCapableCompositeMessageHandlerNode.class,
|
||||||
|
ErrorCapableDiscardingMessageHandlerNode.class, ErrorCapableEndpointNode.class,
|
||||||
|
ErrorCapableMessageHandlerNode.class, ErrorCapableRoutingNode.class, MessageGatewayNode.class,
|
||||||
|
MessageProducerNode.class, PollableChannelNode.class, MessageChannelNode.class,
|
||||||
|
MessageHandlerNode.class, MessageSourceNode.class, RoutingMessageHandlerNode.class);
|
||||||
|
for (Class<?> bindingType : bindingTypes) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.management;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint.ThreadDumpDescriptor;
|
||||||
|
import org.springframework.boot.actuate.management.ThreadDumpEndpoint.ThreadDumperUnavailableException;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ThreadDumpEndpointWebExtension}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ThreadDumpEndpointWebExtensionTests {
|
||||||
|
|
||||||
|
private ThreadDumpEndpointWebExtension sut;
|
||||||
|
|
||||||
|
private ThreadDumpEndpoint delegateMock;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
this.delegateMock = Mockito.mock(ThreadDumpEndpoint.class);
|
||||||
|
this.sut = new ThreadDumpEndpointWebExtension(this.delegateMock);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldHandleThreadDumperUnavailable() {
|
||||||
|
Mockito.when(this.delegateMock.threadDump())
|
||||||
|
.thenThrow(new ThreadDumperUnavailableException("No thread dumper available"));
|
||||||
|
WebEndpointResponse<ThreadDumpDescriptor> response = this.sut.threadDump();
|
||||||
|
assertThat(response.getStatus()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldHandleThreadDumperUnavailableText() {
|
||||||
|
Mockito.when(this.delegateMock.textThreadDump())
|
||||||
|
.thenThrow(new ThreadDumperUnavailableException("No thread dumper available"));
|
||||||
|
WebEndpointResponse<String> response = this.sut.textThreadDump();
|
||||||
|
assertThat(response.getStatus()).isEqualTo(HttpStatus.SERVICE_UNAVAILABLE.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.metrics.cache;
|
||||||
|
|
||||||
|
import com.hazelcast.spring.cache.HazelcastCache;
|
||||||
|
import io.micrometer.core.instrument.binder.cache.HazelcastCacheMetrics;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.metrics.cache.HazelcastCacheMeterBinderProvider.HazelcastCacheMeterBinderProviderRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link HazelcastCacheMeterBinderProviderRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class HazelcastCacheMeterBinderProviderRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final HazelcastCacheMeterBinderProviderRuntimeHints sut = new HazelcastCacheMeterBinderProviderRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onMethod(HazelcastCache.class, "getNativeCache"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(HazelcastCacheMetrics.class)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.quartz;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzGroups;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobGroupSummary;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary;
|
||||||
|
import org.springframework.boot.actuate.quartz.QuartzEndpointWebExtension.QuartzEndpointWebExtensionRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link QuartzEndpointWebExtensionRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class QuartzEndpointWebExtensionRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final QuartzEndpointWebExtensionRuntimeHints sut = new QuartzEndpointWebExtensionRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Set<Class<?>> bindingTypes = Set.of(QuartzGroups.class, QuartzJobDetails.class, QuartzJobGroupSummary.class,
|
||||||
|
QuartzTriggerGroupSummary.class);
|
||||||
|
for (Class<?> bindingType : bindingTypes) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.scheduling;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CronTaskDescription;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.CustomTriggerTaskDescription;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedDelayTaskDescription;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.FixedRateTaskDescription;
|
||||||
|
import org.springframework.boot.actuate.scheduling.ScheduledTasksEndpoint.ScheduledTasksEndpointRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ScheduledTasksEndpointRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ScheduledTasksEndpointRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final ScheduledTasksEndpointRuntimeHints sut = new ScheduledTasksEndpointRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Set<Class<?>> bindingTypes = Set.of(FixedRateTaskDescription.class, FixedDelayTaskDescription.class,
|
||||||
|
CronTaskDescription.class, CustomTriggerTaskDescription.class);
|
||||||
|
for (Class<?> bindingType : bindingTypes) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.startup;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.TypeReference;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.startup.StartupEndpoint.StartupEndpointRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link StartupEndpointRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class StartupEndpointRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final StartupEndpointRuntimeHints sut = new StartupEndpointRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
Set<TypeReference> bindingTypes = Set.of(
|
||||||
|
TypeReference.of("org.springframework.boot.context.metrics.buffering.BufferedStartupStep$DefaultTag"),
|
||||||
|
TypeReference.of("org.springframework.core.metrics.jfr.FlightRecorderStartupStep$FlightRecorderTag"));
|
||||||
|
for (TypeReference bindingType : bindingTypes) {
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(bindingType)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS)).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.web.mappings.reactive;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.reactive.DispatcherHandlersMappingDescriptionProvider.DispatcherHandlersMappingDescriptionProviderRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link DispatcherHandlersMappingDescriptionProviderRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class DispatcherHandlersMappingDescriptionProviderRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final DispatcherHandlersMappingDescriptionProviderRuntimeHints sut = new DispatcherHandlersMappingDescriptionProviderRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(DispatcherHandlerMappingDescription.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.web.mappings.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.DispatcherServletsMappingDescriptionProvider.DispatcherServletsMappingDescriptionProviderRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link DispatcherServletsMappingDescriptionProviderRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class DispatcherServletsMappingDescriptionProviderRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final DispatcherServletsMappingDescriptionProviderRuntimeHints sut = new DispatcherServletsMappingDescriptionProviderRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(DispatcherServletMappingDescription.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.web.mappings.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.FiltersMappingDescriptionProvider.FiltersMappingDescriptionProviderRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link FiltersMappingDescriptionProviderRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class FiltersMappingDescriptionProviderRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final FiltersMappingDescriptionProviderRuntimeHints sut = new FiltersMappingDescriptionProviderRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(FilterRegistrationMappingDescription.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.actuate.web.mappings.servlet;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.MemberCategory;
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.actuate.web.mappings.servlet.ServletsMappingDescriptionProvider.ServletsMappingDescriptionProviderRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link ServletsMappingDescriptionProviderRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class ServletsMappingDescriptionProviderRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final ServletsMappingDescriptionProviderRuntimeHints sut = new ServletsMappingDescriptionProviderRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.reflection().onType(ServletRegistrationMappingDescription.class)
|
||||||
|
.withMemberCategories(MemberCategory.INVOKE_DECLARED_CONSTRUCTORS, MemberCategory.DECLARED_FIELDS))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -21,12 +21,18 @@ import java.time.Instant;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.info.BuildProperties.BuildPropertiesRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide build-related information such as group and artifact.
|
* Provide build-related information such as group and artifact.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(BuildPropertiesRuntimeHints.class)
|
||||||
public class BuildProperties extends InfoProperties {
|
public class BuildProperties extends InfoProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,4 +106,13 @@ public class BuildProperties extends InfoProperties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class BuildPropertiesRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.resources().registerPattern("META-INF/build-info.properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2019 the original author or authors.
|
* Copyright 2012-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -21,12 +21,18 @@ import java.time.format.DateTimeFormatter;
|
|||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.RuntimeHintsRegistrar;
|
||||||
|
import org.springframework.boot.info.GitProperties.GitPropertiesRuntimeHints;
|
||||||
|
import org.springframework.context.annotation.ImportRuntimeHints;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide git-related information such as commit id and time.
|
* Provide git-related information such as commit id and time.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
*/
|
*/
|
||||||
|
@ImportRuntimeHints(GitPropertiesRuntimeHints.class)
|
||||||
public class GitProperties extends InfoProperties {
|
public class GitProperties extends InfoProperties {
|
||||||
|
|
||||||
public GitProperties(Properties entries) {
|
public GitProperties(Properties entries) {
|
||||||
@ -126,4 +132,13 @@ public class GitProperties extends InfoProperties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class GitPropertiesRuntimeHints implements RuntimeHintsRegistrar {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
|
||||||
|
hints.resources().registerPattern("git.properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.info.BuildProperties.BuildPropertiesRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link BuildPropertiesRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class BuildPropertiesRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final BuildPropertiesRuntimeHints sut = new BuildPropertiesRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.resource().forResource("META-INF/build-info.properties"))
|
||||||
|
.accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012-2022 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.springframework.boot.info;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import org.springframework.aot.hint.RuntimeHints;
|
||||||
|
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
|
||||||
|
import org.springframework.boot.info.GitProperties.GitPropertiesRuntimeHints;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link GitPropertiesRuntimeHints}.
|
||||||
|
*
|
||||||
|
* @author Moritz Halbritter
|
||||||
|
*/
|
||||||
|
class GitPropertiesRuntimeHintsTests {
|
||||||
|
|
||||||
|
private final GitPropertiesRuntimeHints sut = new GitPropertiesRuntimeHints();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldRegisterHints() {
|
||||||
|
RuntimeHints runtimeHints = new RuntimeHints();
|
||||||
|
this.sut.registerHints(runtimeHints, getClass().getClassLoader());
|
||||||
|
assertThat(RuntimeHintsPredicates.resource().forResource("git.properties")).accepts(runtimeHints);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user