spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Consider dropping ApplicationContextAotInitializer

Open philwebb opened this issue 3 years ago • 3 comments

Spring Boot recently introduced AotApplicationContextInitializer to aid with AOT testing support. This class replaces the need to call org.springframework.context.aot.ApplicationContextAotInitializer from Spring Boot.

If we're the only consumer, then the Framework class could potentially be dropped.

philwebb avatar Sep 15 '22 06:09 philwebb

Thanks for the suggestion. This class is meant to be used by consumers of AOT, Spring Boot being one of them but we anticipate any custom framework built on top of Spring Framework to find it useful as well. I can see that the use in Spring Boot has been replaced by AotApplicationContextInitializer in Spring Boot.

Shouldn't this be the other way around, with AotApplicationContextInitializer being contributed here, rather than being a Spring Boot-specific class? Looking at the code it's not obvious to me why that is.

snicoll avatar Sep 15 '22 06:09 snicoll

That's an alternative. I wanted to get the test support into Spring Boot without derailing the Spring Framework release. We need a way for the test code to plug in an ApplicationContextInitializer that acts as a signal that the convention based one should not be used. If we're happy for the one here to be a real ApplicationContextInitializer then we could rework things after the next Boot milestone.

philwebb avatar Sep 15 '22 19:09 philwebb

We need a way for the test code to plug in an ApplicationContextInitializer that acts as a signal that the convention based one should not be used. I

I don't think I've understood that but I believe that general entry points should be provided by framework so that custom framework should build upon them the same way Spring Boot does. I've also created #29181 to move/refactor the current AotProcessor.

snicoll avatar Sep 21 '22 11:09 snicoll

I've pushed a new AotApplicationContextInitializer interface and deprecated the existing one. I've also refactored Spring Boot to use it. If you're happy with the new one we can probably delete ApplicationContextAotInitializer before RC1

philwebb avatar Sep 29 '22 23:09 philwebb

Cool. I like it.

snicoll avatar Sep 30 '22 06:09 snicoll