I'd like to follow up on an issue we raised at the Java EE 7 BOF
about the use of custom injection annotations.
For example, should the Batch spec define
@BatchContext
private JobContext ctx;
or should it use
@Inject
private JobContext ctx;
The former is effectively a custom injection annotation unrelated to CDI.
The latter introduces a dependency on CDI.
In your opinion, which is preferred? It seemed that the EE 7 BOF audience was
pretty evenly split on this one, and I can see arguments for either position.
If @Inject is preferred, should we allow custom annotations at the discretion
of the spec author, or should we disallow custom annotations entirely?
If custom injection annotations are allowed, should CDI make it easy to
define them, e.g., using something like:
@Stereotype
@Inject
public @interface BatchContext { }
If CDI supported this easily, applications could even define their own
injection annotations.
Should custom injection annotations be a legacy artifact that we need
to continue to support, or should we recognize it as a part of the
Java EE programming model and use it widely?