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

Provider method workaround for classpath #12

Open
charphi opened this issue Oct 9, 2019 · 1 comment
Open

Provider method workaround for classpath #12

charphi opened this issue Oct 9, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@charphi
Copy link
Member

charphi commented Oct 9, 2019

In Java 9+, a provider method is a public static no-arg method called provider where the return type is the service type.

Since this feature is not available on Java 8, a possible workaround would be to generate a delegate wrapper around this method.

@charphi charphi added the enhancement New feature or request label Oct 9, 2019
@charphi
Copy link
Member Author

charphi commented Mar 20, 2020

Workaround could be extended to:

  • public static method that returns service
  • public enum that implements service

Examples:

public interface HelloService {}

public class SomeClass {
  @ServiceProvider
  public static HelloService create() { ... }
}

@ServiceProvider
public enum SomeEnum implements HelloService { ... }

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

No branches or pull requests

1 participant