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

Property codec registration doesnt work woth ServiceLoader #2196

Closed
daniel-exceed opened this issue Jan 8, 2023 · 3 comments
Closed

Property codec registration doesnt work woth ServiceLoader #2196

daniel-exceed opened this issue Jan 8, 2023 · 3 comments
Labels
Milestone

Comments

@daniel-exceed
Copy link
Contributor

I defined a codec provider that extends PropertyCodecProvider and define in manifest and module info the service i'm implementing so that MorphiaCodecProvider will load it using the ServiceLoader mechanism of java, but id didnt work.

To Reproduce
https://github.com/daniel-exceed/property-codec-service-loader

Expected behavior
any codec provider defined properly using the serviceloader mechanism will be loaded

  • Server Version: 6
  • Driver Version:4.7.2
  • Morphia Version:2.3.0

I created a pull request to fix this issue: #2190 and map the property codec providers through mapper options like the regular codec providers are mapped

@evanchooly
Copy link
Member

So I've been playing with your PR a bit the last couple of days and have run in to a few issues. The most pressing is that it breaks the kotlin module which uses SPI for a couple of things. I've put together a reproducer that uses modules and I can definitely seen things break with a module-info.java where they work without out. However if I add the following line to my module def it seems to pick up the new codec just fine:

    provides dev.morphia.mapping.codec.MorphiaPropertyCodecProvider with com.foo.MyCodecProvider;

Is there a problem with simply updating your module def appropriately?

@evanchooly evanchooly modified the milestones: 3.0.0, 2.4.0 Jun 4, 2023
@evanchooly
Copy link
Member

In 3.0, I'm thinking this will all be done via annotations at build time so there will be discovery at runtime either way. So the less I do now with this, the less there will be to unwind in the next version.

@evanchooly
Copy link
Member

Closing as there seems to be no issue here. I have updated the docs for the upcoming version to address this topic: https://morphia.dev/morphia/2.4/configuration.html#_some_notes_on_serviceloader

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