Skip to content
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 do I provide a custom SPI using Spring injection #198

Closed
gsbtech opened this issue May 25, 2018 · 1 comment
Closed

How do I provide a custom SPI using Spring injection #198

gsbtech opened this issue May 25, 2018 · 1 comment
Labels

Comments

@gsbtech
Copy link

gsbtech commented May 25, 2018

I could not find a Users Group for this. So, I am posting this question here.
If not appropriate, please indicate where I can post it.

I have created a custom CurrencyProviderSpi that I want to upload in my application without having to modify the *.properties file under META-INF in the release .jar

I tried injecting is as:

@configuration
public class MyCurrencyConfiguration {

@Bean
public CurrencyProviderSpi currencyProviderSpi() {
    return new MyCurrencyUnitSpi();
}

}

but it did not get loaded by the Bootstrap.

Do you have an example of how I can do it?
I am using Spring Boot 1.5.x, Spring Framework 4.

@keilw keilw changed the title How do I provide a custom SPI suing Spring injection How do I provide a custom SPI using Spring injection May 26, 2018
@keilw keilw added the invalid label May 26, 2018
@keilw
Copy link
Member

keilw commented May 26, 2018

It does not seem the right place here, as Moneta internally does not use Spring Injection.
The mentioned example also does not look like it would work because if you properly defined MyCurrencyUnitSpi to implement the SPI and also put it under META-INF/services, that already is Dependency Injection of its own kind and you do not need Spring for that.
Properly applied through the Service Loader mechanism, you'll get your provider from the JavaMoney.

I'll close this ticket and opened a stub in JavaMoney/javamoney-examples#34. The examples already contain CDI use cases, so in a similar way we could also offer something for Spring Boot. You're welcome to contribute there.

@keilw keilw closed this as completed May 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants