Re: Platform wide guideline for build-in annotation literals?
On Tue, Sep 19, 2017 at 12:09 pm, Bill Shannon wrote:
I'm not sure if there's any inconsistency, other than creating literals for the JSR 330 spec and including them in 299. Or is that what you're referring to?
They're mostly used for the various builders that CDI has for dynamically adding annotations to beans. CDI already has a helper class for that that makes it somewhat easier (https://docs.jboss.org/cdi/api/2.0/javax/enterprise/util/AnnotationLiteral.html), but even with the helper class it's still a bit verbose.
For a practical example see: http://arjan-tijms.omnifaces.org/2017/08/dynamically-adding-interceptor-to-build.html
It's also used for lookups, as in this code:
For the full context see: https://github.com/javaee-samples/javaee8-samples/blob/master/cdi/qualified-lookup/src/test/java/org/javaee8/cdi/qualified/lookup/QualifiedLookupTest.java#L41
In that latter example a bean is selected that has the @Named("northern") annotation applied to it.
Perhaps, but without members the annotation instance is a totally static singleton, like enum values basically. With members this is obviously not the case.
Possibly indeed, but not sure how feasible it is to get that in.
For now Java EE support throughout all applicable specs (basically the specs that already leverage CDI) isn't that hard at all. Had I learned about this annotation literals a tiny bit earlier I could have added them trivially to JSF and Java EE security (if the spec lead and EG would have agreed, of course).