AMW Use Case - Model annotations in Java 1.4

AMW Logo

This use case how AMW can be used to annotate a Java 1.4 metamodel.

Overview

Models are annotated to add extra information that are not defined in the metamodel. Consider we have a Java 1.4 model Ma. Ma conforms to a Java 1.4 metamodel MMa. The metamodel allows creating the basic elements of Java, e.g., classes, properties, methods, if statements, and so on. However, this metamodel does not supports annotations like in Java 5. The annotations are not defined in the metamodel, and we do not want to extend the Java 1.4 metamodel.

The annotations are created as a pair property-value. These annotations are linked with the Java model elements. These links and annotations are defined in a weaving model Mw (see Figure below). This separation between weaving model and Java model avoids polluting the model with additional information that is not relevant for the semantics.



Annotation weaving model

This model conforms to an annotation extension to the core weaving metamodel (see below). It is important to note that the AnnotationModel class has a single-valued reference to AnnotatedModel. This means the annotations are created (i.e., woven) only in one model. The same analogy is true for the Annotation class, which is an extension to WLink. It contains a single-valued reference to the model elements, plus a list of properties. The properties have an identification key and the corresponding value.



Annotation metamodel extension

The annotations may be created and edited in two ways. First, the annotation weaving models are created directly with the AMW plug-in, as shown in the Figure below. Second, the annotations can be created in an annotation DSL (Domain Specific Language), to be later injected into an annotation weaving model. This model can also be edited in the AMW plug-in.



Annotating a Java model in AMW


Download

Annotation extension

This file contains the annotation extension to the core weaving metamodel.

Java annotation
example

This example uses AMW to add annotations to a simple Java model.