Setup instructions for the extension to Java transformations

Before you run the sample Java transformation extension, you must import the plug-in into your workspace, create a runtime workbench, and create a transformation configuration.

Import the sample

Before you begin

You must be in the Java perspective.

Procedure

  1. On the sample overview page, click Import the sample.
  2. In the Import sample wizard, specify the destination project name for the sample files.
  3. Click Finish.
  4. If you are prompted to switch to the Resource perspective, click No. The wizard creates the new project in your workspace. The Project Explorer view displays the new plug-in project.
  5. If the Build Automatically preference is enabled, you must disable it before you build the project: Click Project > Build Automatically, and verify that a check mark is not displayed beside this option.
  6. Click Project > Build Project.
  7. To verify that the project built correctly, check the Problems view for errors.

Results

The imported plug-in contains a Java class that contains the transformation extension rule. Examine the plugin.xml file to understand how to extend the UML-to-Java and Java-to-UML transformations. In the Java class named CustomInterface.java, examine the code in the createTarget method to understand how the transformation extension uses the public API to create a new compilation unit, implement the source interface, and create default methods. In the Java class named FilterImplRule.java, examine the canAccept method to understand how the transformation extension uses Java-to-UML proxy classes to determine which inputs to hide by using filters.

Create a runtime workbench

Procedure

  1. Click Run > Run Configurations.
  2. In the Run Configurations window, click Eclipse Application, and click the New launch configuration icon.
  3. Accept the default values and click Run.
  4. Click Run.

Create a UML-to-Java transformation configuration

Before you begin

You must be in the Modeling perspective.

Procedure

  1. In the runtime workbench that you created in the previous step, create a project that contains a UML model: Click File > New > Other > Modeling > Model Project.
  2. Click Next.
  3. On the Create Model Project page, in the Project name field, specify a name for the new project click Next.
  4. Under Categories, click General; under Templates, click Blank Package; then click Finish.
  5. In the model that you created in step 3, add a UML interface.
  6. Create a transformation configuration: Click File > New > Other > Transformations > Transformation Configuration and click Next.
  7. In the New Transformation Configuration wizard, on the Specify a Configuration Name and Transformation page, complete the following steps:
    1. Specify the name and destination of the transformation configuration.
    2. From the Transformation list, select Java Transformations > UML to Java.
    3. In the Protocol section, click Reconciled.
    4. Click Next.
  8. On the Source and Target page, under Selected source, expand the new project, expand the Models folder, and click the model.
  9. Under Selected target, click Create Target Container, and complete the steps in the New Java Project wizard; then click Finish.
  10. In the transformation configuration editor, on the Extensions page, select the com.ibm.rsa.javaTransformExtension.example and com.ibm.rsa.javaTransformExtension.example.JavaUML check boxes.
  11. Click File > Save.

Run the UML-to-Java transformation extension sample application

Procedure

In the transformation configuration editor, on the Main page, click Run. The transformation generates a Java interface and a Java class that implements the interface.

Feedback