-
Notifications
You must be signed in to change notification settings - Fork 40
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
How to inject a custom SPI using Spring Injection #34
Comments
Having to modify a 3rd-party .jar, as to having to edit the *.properties file, is not something that I would pursue, i.e., JavaMoney API CDI example. That is why I asked if you have considered a different path, using Spring. Spring DI is an application of the CDI concept, just using a known and popular framework. |
The Java ServiceLoader concept exists ever since Java 6, it is a popular framework within the JDK: It is theoretically possible for you to combine them as described here: But as a dependency in the RI Spring seemed unreasonable. Spring also uses Moneta, that could have lead to circular dependencies or other dependency issues. And of course you don't have to patch or put anything into the Moneta JARs ;-O They show, how to use the service loader to add new exchange rate providers. |
Thank you. I will take a look at these recommendations. |
I tried to follow the examples. I wanted to use the ServiceListFactoryBean but it did not work with spring boot/java 8. Somehow the ServiceLoader invoked by the bootstrap is always winning. Using spring.factories and also overriding the META-INF/services files works, but I was trying to avoid this. I wonder if there is a way to reload the configurations. I mean, let the Money API do its thing, and before my app is available, reload all desired overrides. On a related point, I do not see the public jars for moneta 1.2.*, only pom files. |
Most of those are Spring issues. Spring Framework itself uses the ServiceLoader on various occasions and since it is a Java platform mechanism it usually has preference over extra layers of injection. Moneta 1.2+ is a Parent POM holding together the individual modules, so the parent has no JAR. |
So, if I want to user moneta 1.2.1, how do I download a public .jar?, better said, what is the snippet to add to my pom.xml? |
No Maven does that automatically. See http://javamoney.github.io/ri.html for the right snippet. Note, the version is |
From JavaMoney/jsr354-ri#198, as it is not really the place in the Moneta issue tracker.
The text was updated successfully, but these errors were encountered: