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

Enhancement: Annotate Annotations to create specific service providers. #6

Open
GoogleCodeExporter opened this issue May 1, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Imagine I want to create a new annotation.  That annotation that accepts 
additional fields for configuring the service implementation.  My implementing 
classes can of course have my new annotation and the ProviderFor annotation, 
but it's a bit redundant.  

Instead, I want to apply the ProviderFor annotation on my new annotation.  Then 
any class with my new annotation should automatically work as if the 
providerFor annotation were applied.


@ProviderFor(RequestHandler.class)
public @interface CustomAnnotation {
    String name();
    int value();
}

@CustomAnnoation(name="example", value=25)
public class HelloHandler {
...
}

When I do a ServiceLoader.load(RequestHandler.class), HelloHandler should be 
loaded.  I don't need to apply @ProviderFor to it, because I already indicated 
in the CustomAnnotation that any class with that annotation applied is a 
provider for the RequestHandler class.

Obviously you can't automatically add the provider for annotation to the 
implementing class.  Instead I would expect the annotation processor to 
determine that CustomAnnotation had ProviderFor applied.  Then the annotation 
processor would know anything with CustomAnnotation should be operated on as if 
ProviderFor(RequestHandler.class) had been present.

Original issue reported on code.google.com by [email protected] on 17 Apr 2013 at 5:21

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

No branches or pull requests

1 participant