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

Support ServiceLoader #38

Closed
SchulteMarkus opened this issue Apr 11, 2019 · 3 comments
Closed

Support ServiceLoader #38

SchulteMarkus opened this issue Apr 11, 2019 · 3 comments

Comments

@SchulteMarkus
Copy link

Java has a class java.util.ServiceLoader (in this package available from JDK6 onwards).

A facility to load implementations of a service.
A service is a well-known interface or class for which zero, one, or many service providers exist. A service provider (or just provider) is a class that implements or subclasses the well-known interface or class. A ServiceLoader is an object that locates and loads service providers deployed in the run time environment at a time of an application's choosing. Application code refers only to the service, not to service providers, and is assumed to be capable of choosing between multiple service providers (based on the functionality they expose through the service), and handling the possibility that no service providers are located.

Feature request: Please support ServiceLoader by placing the required files in META-INF/services.

Background

You may already have heard of SubstrateVM (part of GraalVM)

Substrate VM is a framework that allows ahead-of-time (AOT) compilation of Java applications under closed-world assumption into executable images or shared objects (ELF-64 or 64-bit Mach-O).

SubstrateVM supports META-INF/services as part of the compilation process (done in oracle/graal#563, released https://www.graalvm.org/docs/release-notes/#10-rc8).

So, if you support ServiceLoader, you add (part of) support for SubstrateVM, too.

Example

Micronaut can be compiled using SubstrateVM. One example for META-INF/services can be found at https://github.com/micronaut-projects/micronaut-core/tree/master/inject/src/main/resources/META-INF/services

@cowtowncoder
Copy link
Member

I am bit confused by this request mostly because Jackson components already included SPI files for all JsonFactory subtypes (for pluggable formats), sub-classes of ObjectMapper (for formats that have format-specific mapper), and for all implementations of Module.
So are there things missing that would benefit from this information?

SPI functionality itself is only exposed via ObjectMapper.findAndRegisterModules() although it could perhaps be useful for locating JsonFactory instances too.

@SchulteMarkus
Copy link
Author

Thanks for your response.

I did only search for META-INF/services in https://github.com/FasterXML/jackson-databind/find/master and found only https://github.com/FasterXML/jackson-databind/blob/master/src/main/resources/META-INF/services/com.fasterxml.jackson.databind.ObjectMapper . That's because I thought there would be place for improvement ;-)
If you say SPI support is complete, I am happy to close this issue.

@cowtowncoder
Copy link
Member

@SchulteMarkus ok that makes sense. Just wanted to make sure. If there are missing cases just let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants