Home
Exploring Java methods by using static method sequence diagrams
The static method sequence diagram feature provided by Rational Application Developer enables developers to visualize a Java method. Existing Java code can quickly be rendered in a sequence diagram in order to visually examine the behavior of an application. A static method sequence diagram from a Java method provides the full view of the entire method call sequence.
To create a static method sequence diagram for a Java method:
![]()
Right-click the desired method in the Enterprise Explorer or Package Explorer view and select Visualize Æ Add to New Diagram File Æ Static Method Sequence Diagram.
![]()
The diagram is created and shown in the corresponding diagram editor. A static method sequence diagram is a topic diagram, so the diagram content is stored in a file with a .tpx extension. Like other topic diagrams, it is read only; the tool palette, the tool bar, and the modeling assistant are not available.
When you right-click an empty space inside the diagram, the File submenu provides you the options to either save the diagram as an image using Save as Image File to convert this diagram to an editable UML sequence diagram using Save as Diagram File, or to print the entire diagram using Print.
Figure | -42 shows a basic example of a static sequence diagram. It describes the flow of control when the withdrawCash method provided by the ATM class is called from the main method of this class. The synchronous message from the diagram frame that invokes the method, in this case main, is called a found message. The corresponding return message is referred to as a lost message.
![]()
Figure 7-42 static method sequence diagram example
A static sequence diagram for a Java method has to be created only once. Like other topic diagrams, the query and context that have been specified when creating the diagram are stored in the diagram itself. So each time a sequence diagram is opened, Rational Application Developer queries the underlying elements and populates the diagram with the latest updates. To refresh the contents of a static sequence diagram to reflect the latest changes in the source code, right-click an empty space inside the diagram and select Refresh.
Note: At the time of writing RAD failed to update the contents of a static sequence diagram when the source code was changed.
A workaround is to restart Rational Application Developer with the -clean option.
ibm.com/redbooks