atteo / classindex

Index classes, do not scan them!
Apache License 2.0
263 stars 42 forks source link

Add @RegisterService annotation #63

Open ST-DDT opened 4 years ago

ST-DDT commented 4 years ago

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:

fprochazka commented 1 year ago

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