Introduction to IBM Rational XDE Java Code Model Importer

How to migrate Rational XDE Java Code Model projects from Rational XDE for Java to Rational Software Architect or Rational Systems Developer

Learn how to use the IBM® Rational® XDE Java Code Model Importer to migrate your projects from Rational XDE for Java to IBM® Rational® Software Architect or IBM® Rational® Systems Developer. By using this optional tool, you can migrate both your code and code model in a way that enables you to use them with the various UML and code modeling capabilities of Rational software. Get started by following these step-by-step instructions.

Share:

Krishna Kishore (krishna.kishore@in.ibm.com), Software Engineer, IBM

Krishna Kishore is a software engineer at the IBM Software Bangalore Lab. He works in the Rational Systems Developer team. His expertise includes UML visual modeling and UML Real Time modeling. He has a bachelors degree in Computer Science and Engineering from Osmania University in Hyderabad, India, and a Masters degree in Computer Science and Engineering from SSSIHL, AP, India.



31 July 2007

Also available in Chinese

The IBM® Rational® XDE Java Code Model Importer (model importer) is a utility provided as part the products IBM® Rational® Software Architect and IBM® Rational® Systems Developer (hereafter referred to collectively as Rational software). This utility lets you migrate Java™ code and the corresponding Java code model from Rational XDE for Java so that you can use the Rational UML and code modeling and transformation capabilities.

The Rational XDE Java Code Model Importer is installed automatically if you select installation of the IBM® Rational®XDE Base Model Importer (XMI) in the IBM Installation Manager. It migrates Rational XDE models, including any custom Unified Modeling Language (UML) profiles that you may have applied to those models. Before running the importer, you will use XMI to import the Java code models and their referenced models to your Rational Software Architect workspace.

About the importer


Migration prerequisites

The following products should be installed on your computer, and you need to be familiar with them:

  • Rational Software Architect or Rational Systems Developer with the optional Rational XDE Java Code Model Importer feature installed. Note: Trial versions are available and listed under Resources.
  • Rational XDE for Java

After installing Rational Software Architect or Rational Systems Developer, you must specify this VM (virtual machine) argument:

"-DXDE_JAVA_PRIMITIVETYPES"

You can specify this argument in either of two ways:

  • By modifying the eclipse.ini file (in the Rational installation directory, the same directory as the eclipse.exe file) and adding the two arguments shown previously under the -vmargs argument. This modification will apply these VM arguments whenever you run either of these Rational software products.
  • By giving the options to the command line when you run this Rational software. For example:
"install directory\eclipse.exe -product com.ibm.rational.rsd.product.ide
          -vmargs -DXDE_JAVA_PRIMITIVETYPES"

You also need to be familiar with these functions and features:

  • How each product reflects Java in UML terms. This knowledge is required to be able to evaluate the outcome of the migration and to verify that it has produced an acceptable outcome.
  • How each product works with combinations of UMl models and Java, including understanding the working of "round-trip engineering" (RTE) in Rational XDE and understanding the "model-code theories of operations." This knowledge is required to decide during import whether you want to replace the UML schematic elements in the imported Rational XDE Java code model with visual references to Java source code elements and, thereafter, to practice mixed modeling.

The next section explains the migration process in detail.


The migration path

Important:
Take a look at Figure 1, which illustrates the entire migration path, before you read the details of each step:

Figure 1. The migration process
The Migration Path

A Java code model project in Rational XDE software can contains two types of artifacts: Java source files and Rational XDE models. The Rational XDE models can be of various types. There can be either zero or one Java code models in the project. Normally, all of the models in the Rational XDE workspace (presumably representing a closure) should be imported to the Rational workspace by using the XMI. Then you can use the model importer to migrate the Java code and the code models during a second step.

The overall migration process can be divided into five major phases. Depending on the size and the complexity of the migration, one or more iterations of this five-step process might be required:

  1. Planning
  2. Preparing the Rational XDE projects (UML models and Java code)
  3. Importing the UML models
  4. Importing the Java project (which re-binds the Java code to the imported UML models)
  5. Running a UML-to-Java transformation in Rational software to finish updating the code in preparation for using the code

Step 1. Planning

There are two primary concerns when planning your Rational XDE to Rational Software Architect or Rational Systems Developer migration:

  • Your overall migration strategy. This, along with other considerations, will guide your decision whether to follow the approach of having your entire team start using Rational software all at once, or the approach of using both Rational XDE and Rational software in parallel during the migration process so that subsets of the team can adopt Rational software incrementally. The latter approach is considerably more challenging. because it involves maintaining parallel development streams, using tricks using model fusing techniques, and performing the actual model migration steps more than once. You need to consider factors such as model sizes and the number of modeling users. These factors will determine how long it will take to complete these tasks:
    • Get Rational software installed on all the desktops
    • Train all the users on Rational software
    • Perform the actual model migration processing
  • Whether you will use mixed modeling, architecture reconciliation, or conceptual model-driven development approach as your chosen alternative to Rational XDE round-trip engineering.

Step 2. Preparing the Rational XDE projects (base models and Java code)

Perform the following steps to prepare the Rational XDE base models and the Java project code for the Code Model Import:

  1. In Rational XDE for Java, synchronize the Java code models so that the UML models (.mdx file) and the Java project are in sync. This is a prerequisite, which you must do before the migration. Important: Do this with the Rational XDE Java preferences set so that the code marker tags are enabled (marker tags are the comments that are created by the Rational XDE code generator that begin with <@modelguid> and contain the unique identifier of the Rational XDE UML model element that correspond to the Java class).
  2. Make a backup copy of the Java projects, including the Rational XDE base models corresponding to Java code model.
  3. Double-check that, on the machines that will process the model imports, the JVM settings are as specified in the Prerequisites section of this article.

Step 3. Importing the UML models

Using Rational XDE Model Importer (XMI), import the Rational XDE UML models. This should include all Rational XDE Java code models, all Rational XDE content models that reference or are referenced by the code models, and the Rational XDE reference models (for example, jdk_min.mdx) referenced by the code models.

Step 4. Importing the Java projects

About the first path

This is an optional step, because the model importer can import the Rational XDE Java projects directly into the Rational software workspace). However, it is recommended if the Rational XDE Java project is complex, such as these examples:

  • The project has different encoding schemes: The project encoding scheme is different from the workspace encoding scheme, or the project uses more than on encoding scheme (for example, two or more Java files in the project have different encoding schemes).
  • The project defines a complex build process: The project uses a custom builder or build process.

There are two paths that you can follow when importing the Java projects from Rational XDE:

  • By following the first path, you can elect to import the Rational XDE Java projects into the Rational software workspace before invoking the model importer by using the "generic" Eclipse project import wizard: File > General > Existing projects info Workspace. This will import the Rational XDE Java projects (which are Eclipse 1 projects) into Rational software and update them to Eclipse 3 projects. When they are imported in this manner, the projects can be used as the input for the Rational XDE model importer.
  • By following the second path, you can import the Rational XDE Java projects into the Rational software workspace as an online part of the processing performed by the importer. Figure 2 shows the Rational XDE Java project import wizard (the Rational XDE Java Code Model Importer wizard). This is the control that you interact with to specify what you want the model importer to do with your Java code and the Rational software UMl models that were imported from Rational XDE previously, in Step 3. To launch this wizard, select File > Import > Other > Rational XDE Java Projects.
Figure 2. Rational XDE Java Code Model Importer wizard
screen capture of the XDE Java Code Model Importer wizard
  1. Specify the following in the model importer wizard:
    • Add the list of Java projects to the Selected projects table and, for each project, add the corresponding Rational UML model that was derived from the project's Rational XDE Java code model. Normally, you will put all of the Java projects in the Rational XDE workspace in this list. You will not include Rational XDE Web projects or Enterprise Java™Beans (EJB) projects, because the model importer does not migrate Rational XDE Web, EJB, or EJB deployment models. In Rational software, though, you work with Web and EJB artifacts directly and do not manipulate them through UML models.
    • For each Java project and model pair, specify these options:
      • The encoding scheme to be set for the Rational XDE Java project. This can be specified by selecting or typing in the encoding scheme in the Project Encoding box. If the selected Java project is an existing project in the workspace, this combo box is disabled.
      • Whether or not the Rational XDE Java project needs to be copied into the Rational workspace. This can be specified by checking the option that says Copy Rational XDE Java projects into workspace. If the selected Java project was previously imported, then this check box is disabled (see the previous discussion about complex projects).
      • Whether of not you want to replace the UML semantic elements in the Rational software models that was derived from the Rational XDE Java code model with direct references to the Java elements. By checking this options, you are declaring your intent that for this project you plan to use the "mixed modeling" approach in Rational software, as opposed to using architecture reconciliation or conceptual model driven development.

Important:
If you plan to use the second option, import only one project at a time instead of multiple projects. Just follow these steps:

  1. Check whether you want model importer to automatically delete the imported copies of Rational XDE Java reference models from the Rational workspace after the model importer's processing has concluded.
  2. Click Finish to start the migration.

Step 5. Running a UML-to-Java transformation on each imported code model

This is an optional step in the process. Perform this step only if you did not tell the model importer to Replace UML elements in the previous step. In other words, during Step 4, you effectively declared your intention not to use mixed modeling and, instead, to use an architecture reconciliation or conceptual model-driven development approach, thereby preserving the code model in Rational software as intact UML semantic models that are used with Rational UML-to-Java (and perhaps Java-to-UML) transformations.


Operations performed during migration

Now that you know the steps for performing the migration, this section will describe the conversion processing that is performed by the Rational XDE Java Code Model Importer to make the code model and Java code compatible with Rational software modeling and transformation components. Some of these operations are performed or bypassed according to the project, depending on whether you selected the option to Replace UML elements with Java elements for the project.

Creation of the mapping model

Performed according to the project: Performed only if the Replace UML Elements with Java Elements option was notselected. The importer also creates a mapping model that captures the existing mapping of UML model elements to Java source files after the migration processing. This mapping model is specified by default in UML-to-Java transformation configuration (the .tc file created as described in the Java transformation configuration subsection, which follows)) to ensure that this mapping is respected and preserved by the transformation.

Replacement of Java framework references to Java visualized types

Performed according to the project: Performed without regard to whether the Replace UML elements with Java elements option was selected. As imported from Rational XDE, the UML model elements that correspond to Java code elements may contain references to types from JDK (Java™ Developer Kit) libraries. For example, a UML class may have an attribute of type java.lang.String;. In Rational XDE, most type specifications (parameters, for instance) are plain text, but type specifications defined by UML associations could resolve against the Rational XDE Java reference models, such as jdk_min.mdx. When the Rational XDE code model is migrated to Rational software (using Rational XDE Base Model Importer), the references to the Rational XDE reference model become references to the imported versions of the Rational XDE Java reference models.

However, Rational software maintains its own direct representations of JDK types, and Rational software expects references to Java types to resolve against these. Therefore, the model importer looks at the references to the imported Rational XDE Java reference models and resolves them again, directly against the JDK. Wherever possible, it also re-resolves type specifications that were plain text in Rational XDE. This provides stronger typing rigor (at the UML level) than Rational XDE. It is a step that is necessary to make the imported Rational XDE code models compatible with the Rational Java modeling and with UML-to-Java and Java-to-UML transformations.

Migration of profiles

Performed according to the project: Performed without regard to whether the Replace UML Elements with Java Elements option was selected. The Rational software Java transformation defines and uses its own UML profile, which contains stereotypes that are applied to UML elements to represent various Java constructs. As part of the code model migration process, the importer applies this new profile to the Rational software UML model that resulted when the Rational XDE Java code model was imported with XMI. This makes the model compatible with the Rational software Java transformation components and thereby enables the model to participate in UML-to-Java (forward) and Java-to-UML (reverse) transformations. The stereotypes that are applied in this step supersede stereotypes that were migrated from the original Rational XDE Java code model.

The table that follows lists the stereotype property values that are migrated by the Rational XDE Java Code Model Importer.

Stereotype property values
This Rational XDE Java RTE profile stereotype propertyIs superseded by this Rational software Java 5 transformation stereotype property
Rational XDE_Java::Java_Attribute::JavaCollectionJavaTransformation5.0::JavaCollection::collectionType
Rational XDE_Java::Java_Attribute::JavaDimensionsJavaTransformation5.0::JavaArray::dimensions
Rational XDE_Java::Java_End::JavaCollectionJavaTransformation5.0::JavaCollection::collectionType
Rational XDE_Java::Java_End::JavaDimensionsJavaTransformation5.0::JavaArray::dimensions

Replacement of UML elements (morph option)

Performed according to the project: This is performed only when Replace UML Elementrs with Java Elements was selected. All of the UML schematic elements in the Rational software UML model are replaced by shortcuts to the corresponding code elements in the Java source files. This leaves the diagrams in the UML model depicting UML-like class shapes that directly represent the Java classes. Double-clicking on these shapes opens the Java class code in the Java code editor. This is consistent with the Rational software mixed-modeling approach. The effect is the same as if you had composed a new model and then applied the UML-to-Java transformation to that model by using the Replace UMl Elements option.

Tip:
You can subsequently add new UML semantic elements to the model and again apply the UML-to-Java transformation with the Replace UML Elements option to also convert the new elements into direct Java references. This means that you can practice mixed modeling in an iterative development process.

Tagging

Performed according to the project: Performed only when Replace UML Elements with Java Elements was not selected. The code elements in the Java source files are tagged by model importer as <@generated> if an equivalent UML element in the model exists. Model precisely, model importer will search for <@modelguid> tags in the imported code. Such tags will be present by virtue of having been generated by Rational XDE. This is why one of the preparation steps before running the model importer is to make sure that the Rational XDE preferences are set to generate these tags and then to synchronize the Rational XDE code model

Notes:

  • Any code elements that, for any reason, are not tagged with <@generated> markers during this step will not be modified (deleted or overwritten) by subsequent application of the UML-to-Java (forward) transformation. For instance, if you delete or rename the model element in Rational software (the UML class) that corresponds to a Java class that does not have the tag, and you then run the Rational UML-to-Java transformation, the class will not be modified. To change this behavior, you can manually add the <@generated> tag to the comments of the Java class in the source file. Thereafter, changes made to the UML class in the model will be applied to the Java class in the source code. See the documentation of the UML-to-Java (forward) transformation component for more details.
  • To tag the Java files, the Rational XDE Java Code Model Importer searches for <@modelguid> tags that are present as part of the Javadoc comments. Make sure that the <@modelguid> tag is present as Javadoc comments in the source files. You can verify this by synchronizing the Java code model in Rational XDE before starting the migration.

Creation of the Java transformation configuration file

Performed according to the project: This is performed only when Replace UML elements with Java elements was not selected. At the end of the migration, the Rational XDE importer will create a Java 5 transformation configuration (TC) file with a specific set of parameter values (such as the source model, target Java project, and so on). Use this TC file without modifications to run the UML-to-Java transformation one time on the migrated model, immediately after model importer has completed the import. This will clean up residual differences in the way that Rational XDE represented Java elements compared to how Rational Software Architect or Rational Systems Developer represent them.

Resources

Learn

Get products and technologies

  • Evaluate IBM Rational Software Architect V7.0 online by taking this three-hour test drive without installing or configuring it on your own system. This advanced model-driven development and static analysis tool is ideal for software architects and developers who are creating service-oriented architecture (SOA), Java™ Platform, Enterprise Edition (J2EE), and portal applications.
  • Try IBM Rational Systems Developer V7.0. The evaluation period for this trial is 30 days. All of the product's features are enabled.
  • Download IBM product evaluation versions and get your hands on application development tools and middleware products from DB2®, Lotus®, Rational®, Tivoli®, and WebSphere®.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational, Java technology
ArticleID=242644
ArticleTitle=Introduction to IBM Rational XDE Java Code Model Importer
publish-date=07312007