-
1. Re: stereotypes solves annotation hell
marcelkolsteren Sep 24, 2010 9:38 AM (in response to nimo22)That's not legal. Quote from chapter 12 of the Weld reference documentation:
A stereotype encapsulates any combination of:
a default scope, and
a set of interceptor bindings.
A stereotype may also specify that:
all beans with the stereotype have defaulted bean EL names, or that
all beans with the stereotype are alternatives.Your AnnotationHell stereotype is illegal because the @Getter and @Setter annotations are not among the mentioned categories of annotations.
-
2. Re: stereotypes solves annotation hell
nimo22 Sep 27, 2010 3:01 AM (in response to nimo22)Yes, it is illegal due to the specification.
But it would be nice, if the CDI-Specification supported something like this!
Dont you think so?
-
3. Re: stereotypes solves annotation hell
marcelkolsteren Sep 27, 2010 5:20 AM (in response to nimo22)Yea, would be nice, but it would be far beyond the scope of a contexts and dependency injection framework. Let alone that implementing such a feature that works for all annotations is challenging, and maybe even impossible without byte code manipulation.
-
4. Re: stereotypes solves annotation hell
nimo22 Sep 27, 2010 9:40 AM (in response to nimo22)
it would be far beyond the scope of a contexts and dependency injection framework.far beyond the scope? I think, aggregating objects (and in this case annotations) to a CONTEXT and use this CONTEXT is not far beyond that scope. I would have a reusable annotation which can be injected into a context.
Let alone that implementing such a feature that works for all annotations is challengingyes, indeed, that is true. I think, the (actual) specification of annotations in java is not prepared for that. However, in this case, the specification of annotations is really far beyond the scope of a contexts and dependency injection framework.
-
5. Re: stereotypes solves annotation hell
marcelkolsteren Sep 27, 2010 10:30 AM (in response to nimo22)I don't get your point about aggregating annotations to a context, and having annotations injected into contexts.
The stereotypes are just a way of making it easier to configure multiple similar beans in one place. It's not strange that it only supports annotations that are under control of CDI. How could a CDI implementation ever ensure that the behavior that is linked to an arbitrary annotation, would actually be transferred to all places where the stereotype is used?
-
6. Re: stereotypes solves annotation hell
nimo22 Sep 28, 2010 2:23 AM (in response to nimo22)
It's not strange that it only supports annotations that are under control of CDI.Stereotypes show us how annotation hell can be solved: by aggregating annotations together to a new annotation. However, you are right with that:
How could a CDI implementation ever ensure that the behavior that is linked to an arbitrary annotation, would actually be transferred to all places where the stereotype is used?It is not the problem of CDI and its stereotypes, maybe something is missing in the Specification of Annotation JSR 175..something, which would enable us a syntactically grouping of annotations to avoid annotation hell and secure DRY. But that is far beyond CDI.