Protecting generated code when you rerun transformations

You can create a Java™ code template that the UML-to-Java and the UML-to-EJB transformation use to generate code. The transformation uses the template to enclose the generated method bodies. When you rerun the transformation, it does not overwrite the code that the template encloses.

To protect generated code when you rerun a transformation:
  1. Click Window > Preferences.
  2. In the Preferences window, from Configure generated code and comments list, expand Code and click Method body.
  3. Click Edit.
  4. In the Edit Template window, insert the following code:
    // begin-user-code
    // ${todo} Auto-generated method stub 
    ${body_statement} 
    // end-user-code
     
  5. To avoid syntax errors when you rerun the transformation, after // end-user-code, press Enter.
  6. Click OK.
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.