23 enero 2009

Taylor's model driven architecture

"Stereotype".equals("Annotation")

Java Annotations are one of the most controversial new features of Java 5. However, they are very powerful when combined with a Model Driven Architecture. In fact Java 5 Annotations are exactly equal to UML Stereotypes. Stereotypes are the UML approach for extending the UML language. Stereotypes have all the same features as annotations:

  • They have a name.
  • They specify which components they can be applied to: class, field, method, etc..
  • They can have attritbutes.
  • Those attributes can be arbitrarily complex.

Stereotypes are then grouped into profiles that can be applied to a model. Taylor comes with several profiles that correspond to the standard Java annotations:

  • EJB3 - for defining Session Beans
  • JPA - for defining Entity Beans
  • JWS - for flagging Session Beans to be exposed as Web Services
  • Types - a platform independent set of basic types

These profiles are automatically applied when a Taylor model is created. Many stereotypes are automatically applied when dragging components to a canvas, while others are applied on demand through the navigator. The defaults of the stereotypes also match the defaults of the annotations to comply with the configuration-by-exception approach of EJB3. On the screen shots page you can see the stereotypes in the Navigator and in the Properties view. The label of each node shows the applied stereotypes (e.g. <>). Stereotype attributes are set via the Properties view. The stereotypes are then generated verbatim into the source code as Java 5 Annotations. Hence the Power of Annotations in an MDA.

No hay comentarios: