Hi,I'd like to add other cases where the lack of a standard annotation resolution mechanism hurts:
- @Stereotype annotations are only respected inside CDI. E.g. EJB annotations like @Stateless can't be moved out into a stereotype like @Boundary.
Just my 2¢Rüdiger
On Tuesday, June 2, 2020 at 7:34:25 AM UTC+1, Rüdiger zu Dohna wrote:Hi,I'd like to add other cases where the lack of a standard annotation resolution mechanism hurts:
- @Stereotype annotations are only respected inside CDI. E.g. EJB annotations like @Stateless can't be moved out into a stereotype like @Boundary.
@Stateless can be replaced by @Depended. I am not sure why you need a stereotype. By the way, @Stereotype is a CDI annotation and it only works with CDI. I don't think it can be lifted out without the mention of CDI.
- It's very common that if a method or field can be annotated, but is not, the same annotation on the class can serve as a fallback.
This is defined in the Jakarta Annotation spec.
- Sometimes it may be useful to have annotations on the package as a fallback for the class (or method/field) level annotations.
- E.g. annotating a POJO property with GraphQL @Name is basically another way of annotating it as a @JsonbProperty name; it's a kind of aliasing.
As for annotation on the package, where do you put the annoation? In order to support this, we might need to introduce the package-info.java concept. I am not sure how useful for support that as potentially the classes might not want to inherit the annotation. This also could introduce problems when adding more and more classes without noticing the package-level annotation as it is not directly visible.
> Instead of re-implementing these mechanisms again and again and living with inconsistent behavior because some features are supported for some annotations but not for others, we may define a meta-standard for annotation resolution.I think the commonly shared annotations should be defined in Jakarta Common Annotation as ementioned above.
@Stateless adds quite some functionality, e.g. pooling, transactions, etc. It currently has to be added directly to the class. The same is true for, e.g., JPA: if I have a POJO that I use as DTO, I'll add JSON-B annotations; and if I want to also store it in a DB, I have to add `@Entity`, etc. It would be nice, if I could annotate such a POJO with a custom stereotype annotation, but JPA, EJB, etc. don't consider those indirect annotations.
I've seen cases where several classes had more than 10 annotations, and most of them where the same. Stereotypes would make the code much more readable, as you specify the role of a class, not the technical bindings it needs for that role.
I've seen cases where several classes had more than 10 annotations, and most of them where the same. Stereotypes would make the code much more readable, as you specify the role of a class, not the technical bindings it needs for that role.I think you are asking for annotation aggregator not stereotype. The CDI stereotype has always a scope associated and only can be applied to CDI beans. If no explicit scope is specified, Dependent scope is used.
JsonbConfig config = new JsonbConfig()
.addClassCustomization(
ClassCustomization.builder(MyClass.class)
.property("originalName", "newName") // like @JsonbProperty
.transient("propertyName") // like @JsonbTransient
.creator(...) // custom instantiation
.build();
)
--
You received this message because you are subscribed to a topic in the Google Groups "Eclipse MicroProfile" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/microprofile/oWlIsvb2NEU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to microprofile...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/microprofile/28e0327b-bafd-4058-84d9-bf26edb5cc1co%40googlegroups.com.
What scope exactly did you have in mind Andy? Were you thinking in terms of use-case scope (i.e. mixins) or in terms of data format (json, xml, graphql-schema)I really like that Jackson is a generic databinding library -- it's not just limited to JSON<-->Java, but can do other things like XML/YAML/etc. It would be good to have this in MP also, but that might be a separate topic from what you are suggesting.As others have pointed out, Jakarta Common Annotations seems like a good place for this feature, and then it can be consumed by other specs. Or, since specs _can_ depend on other specs we could just put this functionality in JSON-B and add a soft/hard dependency from JAXRS-->JSONB.
To unsubscribe from this group and all its topics, send an email to microp...@googlegroups.com.