jsr342-experts@javaee-spec.java.net

[jsr342-experts] Re: allowing stereotypes to be used more widely

From: David Blevins <david.blevins_at_gmail.com>
Date: Fri, 31 Aug 2012 17:38:50 -0700

General note on duplication. We have duplication already.

Really the question is how do we address the duplication or if we address it.

The annotation inheritance concept exists in other specifications such as Bean Validation and JAX-RS. Here's how JAX-RS defines @POST, as a Stereotype/Metatype of @HttpMethod.

   @Target(value=METHOD)
   @Retention(value=RUNTIME)
   @HttpMethod(value="POST")
   public @interface POST

The only thing missing is @Stereotype/_at_Metatype.

If we want to do this in more specifications, for example in EJB add

   @Target(value=METHOD)
   @Retention(value=RUNTIME)
   @Schedule(second = "0", minute = "0", hour = "*", month = "*", dayOfWeek = "*", year = "*")
   public @interface Hourly

How would we want to do that?

Fundamentally there are three options:

  a) address duplication by requiring @Stereotype and CDI dependency
  b) address duplication by introducing one more duplicate (let's be fair), @Something in a common annotation or new spec
  c) don't address duplication, specifications can duplicate the reuse concept, some require CDI some do not


-David