OpenFeign / feign

Feign makes writing java http clients easier
Apache License 2.0
9.37k stars 1.91k forks source link

Support ServiceLoader #944

Open SchulteMarkus opened 5 years ago

SchulteMarkus commented 5 years ago

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 https://github.com/oracle/graal/issues/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

velo commented 5 years ago

@SchulteMarkus do you think a generated implementation would solve the graalVM problem?

https://github.com/velo/feign/pull/3/files

Could you test and help me automate tests with graal VM so I can continue developing this feature?