Hi Bill/All,
Still very much split myself. I'm in favor of CDI. I simply don't like to
see @Inject all over the place.
We already have a ton of custom annotations (e.g. @EJB) and if we treat
them as a legacy artifact only we will probably end up with a programming
model that needs good naming conventions (again) to be helpful.
@Inject
private MyBoundary boundaryEJB;
@Inject
private JobContext batchContext;
This moves the problem to the user but should be solved in the platform.
Having custom injection annotations makes this more readable and easier to
follow in the code (at least for me).
I would like to see the expansion of use of CDI stereotypes (aka
meta-annotations / stacked stereotypes) and require every EE spec to
provide a CDI based injection annotation.
They should be free to provide additional ways for supporting standalone
environments (e.g. via additional @Qualifiers).
- M
On 6 November 2012 01:10, Bill Shannon <bill.shannon_at_oracle.com> wrote:
> 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?
>