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

Add @RegisterService annotation #63

Open
ST-DDT opened this issue Jun 19, 2020 · 1 comment
Open

Add @RegisterService annotation #63

ST-DDT opened this issue Jun 19, 2020 · 1 comment

Comments

@ST-DDT
Copy link

ST-DDT commented Jun 19, 2020

Usage

@RegisterService(SomeOneElsesInterface.class)
public class MyImplOfSomeOneElsesInterface implements SomeOneElsesInterface {
    ...
}

The annotation (the related annoation processor) adds the MyImplOfSomeOneElsesInterface to the /META-INF/services/com.foo.bar.SomeOneElsesInterface file for the service loader.

The usecase for this annotation is to simplify the registration for the service loader for interfaces, that don't use this library on their own. And thus avoid issues due to renaming classes.

The annotation can probably use RetentionType.SOURCE as it isn't needed at runtime/for other dependencies.

Other name suggestions for the annotation:

  • @RegisterForServiceLoader
@fprochazka
Copy link

Why not use https://www.baeldung.com/google-autoservice ?

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