Repository navigation
·
1 commit
to master
since this release
Spring AOT (spring-boot:process-aot, native images) with REST clients (#341):
spring-addons-starter-rest
- The bean definitions of the clients declared under
com.c4-soft.springaddons.rest.clientno longer embed the resolvedSystemProxyPropertiesandSpringAddonsRestProperties, which Spring AOT can't write as code (Code generation does not support com.c4_soft.springaddons.rest.SystemProxyProperties). The client factory beans bind them from the environment when they create their client, as the post-processors did when they registered the definitions: same properties, same values, and in an AOT-processed application, the values of the runtime environment. - The three bean definition registry post-processors (
RestClient, servlet and reactiveWebClient) implementBeanFactoryInitializationAotProcessor, which keeps them out of the AOT generated code: in an AOT-processed application, they no longer run at startup, where they registered the clients a second time over the generated definitions (BeanDefinitionOverrideException). - With Spring AOT, as for any bean definition, the clients, their type (
RestClientorWebClient), whether they expose a builder and whether they use OAuth2 are those of the environment at build time (process-aotprofiles and properties); their configuration (base URL, proxy, headers, ...) comes from the runtime environment.
HTTP service groups with a second properties bean (#344):
spring-addons-starter-rest
- The HTTP service group configurers bind
SpringAddonsRestPropertiesandSystemProxyPropertiesfrom the environment, as the clients do since #341, instead of injecting the beans: an application declaring a second bean of either type no longer fails to start withNoUniqueBeanDefinitionException. The groups no longer read these beans: their configuration comes from thecom.c4-soft.springaddons.restproperties and from theHTTP_PROXY,HTTPS_PROXYandNO_PROXYenvironment variables (or their lower-case versions).
spring-addons-starter-recaptcha
- The auto-configured
C4ReCaptchaValidationServiceno longer fails to start with a secondSystemProxyPropertiesbean, or a secondRestClient.Builderbean: a singlespring-addons-starter-restclient declared withexpose-builderwas enough, next to Spring Boot's builder. It bindsSystemProxyPropertiesfrom the environment instead of reading the bean (the per-service proxy is still set withcom.c4-soft.springaddons.recaptcha.http.proxy.*), and uses the application'sRestClient.Builderwhen it is unique or primary, a default builder otherwise.
Native images with reCAPTCHA (#345):
spring-addons-starter-recaptcha
- The auto-configuration registers the reflection hints Jackson needs to bind the
siteverifyresponses (V2ValidationResponseDto,V3ValidationResponseDto) in a GraalVM native image.
JsonPath functions in native images (#346):
spring-addons-oauth2
- A
RuntimeHintsRegistrar(found by Spring AOT throughMETA-INF/spring/aot.factories) registers the constructors of the JsonPath functions, which JsonPath creates by reflection: a claim path usingkeys(),first(),concat(), ... (inClaimSet.getByJsonPath, or anauthorities[].path) failed in a native image withFunction of name: keys cannot be created.
Method security expressions in native images (#347):
spring-addons-oauth2
- A
RuntimeHintsRegistrarregisters the public methods ofSpringAddonsMethodSecurityExpressionRoot, which SpEL calls by reflection: withSpringAddonsMethodSecurityExpressionHandler, an expression usingthis,returnObject(@PostAuthorize) orfilterObjectfailed in a native image (Property or field 'returnObject' cannot be found). The methods an application adds in its own expression root need hints from the application:@RegisterReflection(classes = MyExpressionRoot.class, memberCategories = MemberCategory.INVOKE_PUBLIC_METHODS), as the handler's Javadoc shows.
Documentation and build (#349, #350):
- A Spring AOT and native images page: what
process-aotdecides at build time, the runtime hints the libraries contribute and those an application adds, Spring Cloud's refresh scope. - The CI processes the samples ahead of time and runs their tests on the generated contexts (the
aotprofile of the samples).
Available on Maven Central: com.c4-soft.springaddons 9.7.1