Using a JavaAnnotation within a model

About this task

To have classes in your Java design use a JavaAnnotation:

Procedure

  1. Open your IBM® Rational® Rhapsody® project in Java.
  2. On a diagram (for example, an object model diagram), drag your JavaAnnotation from the browser onto your diagram.

    Notice that from a model perspective, the JavaAnnotation is shown with two stereotypes.
  3. Create a class on your diagram that represents a user-defined Java class in the system that wants to use the JavaAnnotation.
  4. Draw a dependency from your class to your JavaAnnotation Your diagram resembles something like the following figure:
  5. Double-click the Dependency link. The Features window opens.
  6. On the General tab, from the Stereotype list, select AnnotationUsage in PredefinedTypesJava.

    Using this stereotype ensures that the code is generated correctly.
    Note: AnnotationUsage displays in the Stereotype box.
  7. Click OK.

    Your diagram resembles something like the following figure:

Results

The following figure shows how the annotation is used within the Java class:


Feedback