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.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; | ||||||
|  | @ -46,7 +45,6 @@ import org.springframework.core.env.Environment; | ||||||
|  * @since 2.0.0 |  * @since 2.0.0 | ||||||
|  */ |  */ | ||||||
| @AutoConfiguration | @AutoConfiguration | ||||||
| @ImportRuntimeHints(ActuatorAnnotationsRuntimeHints.class) |  | ||||||
| public class EndpointAutoConfiguration { | public class EndpointAutoConfiguration { | ||||||
| 
 | 
 | ||||||
| 	@Bean | 	@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 java.util.List; | ||||||
| 
 | 
 | ||||||
| import org.springframework.aot.generate.GenerationContext; | 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.BeanFactoryInitializationAotContribution; | ||||||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; | import org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor; | ||||||
| import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; | import org.springframework.beans.factory.aot.BeanFactoryInitializationCode; | ||||||
|  | @ -67,8 +66,6 @@ class ConfigurationPropertiesBeanFactoryInitializationAotProcessor implements Be | ||||||
| 		@Override | 		@Override | ||||||
| 		public void applyTo(GenerationContext generationContext, | 		public void applyTo(GenerationContext generationContext, | ||||||
| 				BeanFactoryInitializationCode beanFactoryInitializationCode) { | 				BeanFactoryInitializationCode beanFactoryInitializationCode) { | ||||||
| 			RuntimeHintsUtils.registerSynthesizedAnnotation(generationContext.getRuntimeHints(), |  | ||||||
| 					ConfigurationProperties.class); |  | ||||||
| 			for (Class<?> type : this.types) { | 			for (Class<?> type : this.types) { | ||||||
| 				ConfigurationPropertiesReflectionHintsProcessor.processConfigurationProperties(type, | 				ConfigurationPropertiesReflectionHintsProcessor.processConfigurationProperties(type, | ||||||
| 						generationContext.getRuntimeHints().reflection()); | 						generationContext.getRuntimeHints().reflection()); | ||||||
|  |  | ||||||
|  | @ -45,7 +45,6 @@ import org.springframework.beans.factory.support.RootBeanDefinition; | ||||||
| import org.springframework.context.ApplicationContext; | import org.springframework.context.ApplicationContext; | ||||||
| import org.springframework.context.ApplicationContextAware; | import org.springframework.context.ApplicationContextAware; | ||||||
| import org.springframework.context.EnvironmentAware; | import org.springframework.context.EnvironmentAware; | ||||||
| import org.springframework.core.annotation.SynthesizedAnnotation; |  | ||||||
| import org.springframework.core.env.Environment; | import org.springframework.core.env.Environment; | ||||||
| 
 | 
 | ||||||
| import static org.assertj.core.api.Assertions.assertThat; | import static org.assertj.core.api.Assertions.assertThat; | ||||||
|  | @ -84,15 +83,6 @@ class ConfigurationPropertiesBeanFactoryInitializationAotProcessorTests { | ||||||
| 				.satisfies(javaBeanBinding(SampleProperties.class)); | 				.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 | 	@Test | ||||||
| 	void processJavaBeanConfigurationProperties() { | 	void processJavaBeanConfigurationProperties() { | ||||||
| 		RuntimeHints runtimeHints = process(SampleProperties.class); | 		RuntimeHints runtimeHints = process(SampleProperties.class); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue