-
Notifications
You must be signed in to change notification settings - Fork 40.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow other strategies than META-INF/spring.factories for configuring Spring Boot infrastructure #15704
Comments
I think there are maybe a few different requirements in this issue that we need to clarify or possibly split out.
Do we need to totally replace
Is this a different requirement? Which specific usages do you need to disable and why?
Are there any other options before we consider a wholesale migration to a different mechanism? Perhaps GraalVM should offer an extension mechanism that would allow us to make it aware of the information without needing an additional configuration?
This is a good point, although I'm not sure it's always possible since we need a way to decouple things. For example,
I wasn't aware of the history of |
An example of the problem I think we need to address is that So something as simple as protected method in @SpringBootApplication
@CustomizedWith(SpringFooCustomizer.class)
public class MyApplication {...} And |
I want to clarify that this issue is about making Boot infrastructure configurable with other strategies than using That would enable experimenting on other flavors like I mentioned GraalVM as a concrete use case for such approach. In such native world, ASM parsing is not an option,
What I would like is a more flexible approach where those classes can be configured by providing |
It's not clear that the benefits on offer here justify the time it'll take to implement. The opportunity cost is too high at the moment. |
What? But we had a prototype and a plan to improve it. The cost of implementation is not high, is it? Or was there something missing? |
I can see there are still some design decisions pending (#15956 in particular). The rest seems mainly mechanical, and it would be much appreciated in 2.2. I can send some pull requests next week probably, if it helps. |
Some pull requests could certainly help. It would also help to have some more information about exactly what use case the functionality will unlock. We still don't feel like we understand the full picture. Also, in discussing this general requirement with @sdeleuze recently, he was in agreement that waiting till after 2.2 would give us the time to know exactly what's needed and the form that it should take. |
Here's a concrete proposal: https://github.com/dsyer/spring-boot/tree/gh-15704. It takes the prototype from @wilkinsona and strips down the |
We had moved this into 2.2.x, but #16880 has muddied the waters with this one again so it's back in 2.x now. In addition to #16880, we also have Andy Clement's Graal feature work with which I think there's some overlap here. We're back to really needing an answer to this:
Without it, I don't think we can justify adding public API that may be quickly superseded by #16880 or the Graal feature work. |
I think if we implemented #16880 I would say this would be low priority again for me. The main use case is really just flexibility, and the ability to override something without needing reflection. But I don't think that's urgent for 2.2 if we can add the conditional processing. |
I agree and I also think we should at some point improve |
In order to make Spring Boot a better citizen with GraalVM native image generation, in Spring Fu I would like to replace
META-INF/spring.factories
mechanism by a custom way to provideApplicationContextInitializer
,ApplicationListener
,PropertySourceLoader
,EnvironmentPostProcessor
andSpringApplicationRunListener
instances. ButSpringFactoriesLoader
usage is currently impossible to disable. I think @dsyer have also a similar need.In my use case, the functional configuration provided by the user will be used to provide the implementations. This will make the configuration more modular and will make Boot infrastructure a better citizen with GraalVM native image which requires currently a huge mount of reflection configuration because these classes are defined in a property file invisible to GraalVM static code analysis.
In term of software design, I tend to think providing constructors or setters where one can provide a list of instances instead of using internally
META-INF/spring.factories
, and makingSpringFactoriesLoader
only the default way to get implementations for those classes would improve testability, extensibility, and would make dependencies more explicit.I am also wondering if such improvement could be used to replace
SpringFactoriesLoader
(which was initially designed to customize Spring Framework internals for Scala support if I am not mistaken) by another mechanism like JavaServiceLoader
which is natively compatible with GraalVM native image.The text was updated successfully, but these errors were encountered: