Adapt to synthesized annotation changes in Framework
This commit is contained in:
		
							parent
							
								
									fc979397be
								
							
						
					
					
						commit
						d6e9a03136
					
				|  | @ -1,40 +0,0 @@ | |||
| /* | ||||
|  * 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.endpoint; | ||||
| 
 | ||||
| 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.Endpoint; | ||||
| import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension; | ||||
| 
 | ||||
| /** | ||||
|  * {@link RuntimeHintsRegistrar} for actuator support. | ||||
|  * | ||||
|  * @author Moritz Halbritter | ||||
|  */ | ||||
| class ActuatorAnnotationsRuntimeHints implements RuntimeHintsRegistrar { | ||||
| 
 | ||||
| 	@Override | ||||
| 	public void registerHints(RuntimeHints hints, ClassLoader classLoader) { | ||||
| 		Stream.of(Endpoint.class, EndpointExtension.class) | ||||
| 				.forEach((annotationType) -> RuntimeHintsUtils.registerSynthesizedAnnotation(hints, annotationType)); | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -30,7 +30,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||||
| import org.springframework.boot.convert.ApplicationConversionService; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.ImportRuntimeHints; | ||||
| import org.springframework.core.convert.ConversionService; | ||||
| import org.springframework.core.convert.converter.Converter; | ||||
| import org.springframework.core.convert.converter.GenericConverter; | ||||
|  | @ -46,7 +45,6 @@ import org.springframework.core.env.Environment; | |||
|  * @since 2.0.0 | ||||
|  */ | ||||
| @AutoConfiguration | ||||
| @ImportRuntimeHints(ActuatorAnnotationsRuntimeHints.class) | ||||
| public class EndpointAutoConfiguration { | ||||
| 
 | ||||
| 	@Bean | ||||
|  |  | |||
|  | @ -1,59 +0,0 @@ | |||
| /* | ||||
|  * 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.endpoint; | ||||
| 
 | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import org.junit.jupiter.api.BeforeEach; | ||||
| 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.annotation.Endpoint; | ||||
| import org.springframework.boot.actuate.endpoint.annotation.EndpointExtension; | ||||
| import org.springframework.core.annotation.SynthesizedAnnotation; | ||||
| 
 | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
| 
 | ||||
| /** | ||||
|  * Tests for {@link ActuatorAnnotationsRuntimeHints}. | ||||
|  * | ||||
|  * @author Moritz Halbritter | ||||
|  */ | ||||
| class ActuatorAnnotationsRuntimeHintsTests { | ||||
| 
 | ||||
| 	private final ActuatorAnnotationsRuntimeHints registrar = new ActuatorAnnotationsRuntimeHints(); | ||||
| 
 | ||||
| 	private RuntimeHints runtimeHints; | ||||
| 
 | ||||
| 	@BeforeEach | ||||
| 	void setUp() { | ||||
| 		this.runtimeHints = new RuntimeHints(); | ||||
| 		this.registrar.registerHints(this.runtimeHints, getClass().getClassLoader()); | ||||
| 	} | ||||
| 
 | ||||
| 	@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); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| } | ||||
|  | @ -20,7 +20,6 @@ import java.util.ArrayList; | |||
| import java.util.List; | ||||
| 
 | ||||
| import org.springframework.aot.generate.GenerationContext; | ||||
| import org.springframework.aot.hint.support.RuntimeHintsUtils; | ||||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; | ||||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; | ||||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; | ||||
|  | @ -67,8 +66,6 @@ class ConfigurationPropertiesBeanFactoryInitializationAotProcessor implements Be | |||
| 		@Override | ||||
| 		public void applyTo(GenerationContext generationContext, | ||||
| 				BeanFactoryInitializationCode beanFactoryInitializationCode) { | ||||
| 			RuntimeHintsUtils.registerSynthesizedAnnotation(generationContext.getRuntimeHints(), | ||||
| 					ConfigurationProperties.class); | ||||
| 			for (Class<?> type : this.types) { | ||||
| 				ConfigurationPropertiesReflectionHintsProcessor.processConfigurationProperties(type, | ||||
| 						generationContext.getRuntimeHints().reflection()); | ||||
|  |  | |||
|  | @ -45,7 +45,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition; | |||
| import org.springframework.context.ApplicationContext; | ||||
| import org.springframework.context.ApplicationContextAware; | ||||
| import org.springframework.context.EnvironmentAware; | ||||
| import org.springframework.core.annotation.SynthesizedAnnotation; | ||||
| import org.springframework.core.env.Environment; | ||||
| 
 | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
|  | @ -84,15 +83,6 @@ class ConfigurationPropertiesBeanFactoryInitializationAotProcessorTests { | |||
| 				.satisfies(javaBeanBinding(SampleProperties.class)); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	void registerConfigurationPropertiesAnnotation() { | ||||
| 		RuntimeHints runtimeHints = process(SampleProperties.class); | ||||
| 		assertThat(runtimeHints.proxies().jdkProxies()).singleElement() | ||||
| 				.satisfies((hint) -> assertThat(hint.getProxiedInterfaces()).containsExactly( | ||||
| 						TypeReference.of(ConfigurationProperties.class), | ||||
| 						TypeReference.of(SynthesizedAnnotation.class))); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
| 	void processJavaBeanConfigurationProperties() { | ||||
| 		RuntimeHints runtimeHints = process(SampleProperties.class); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue