- •Table of Contents
- •Mastering UML with Rational Rose 2002
- •Chapter 1: Introduction to UML
- •Encapsulation
- •Inheritance
- •Polymorphism
- •What Is Visual Modeling?
- •Systems of Graphical Notation
- •Booch Notation
- •Object Management Technology (OMT)
- •Unified Modeling Language (UML)
- •Understanding UML Diagrams
- •Business Use Case Diagrams
- •Use Case Diagrams
- •Activity Diagrams
- •Sequence Diagrams
- •Collaboration Diagrams
- •Class Diagrams
- •Statechart Diagrams
- •Component Diagrams
- •Deployment Diagrams
- •Visual Modeling and the Software Development Process
- •Inception
- •Elaboration
- •Construction
- •Transition
- •Summary
- •Chapter 2: A Tour of Rose
- •What Is Rose?
- •Getting Around in Rose
- •Parts of the Screen
- •Exploring Four Views in a Rose Model
- •Use Case View
- •Logical View
- •Component View
- •Deployment View
- •Working with Rose
- •Creating Models
- •Saving Models
- •Exporting and Importing Models
- •Publishing Models to the Web
- •Working with Controlled Units
- •Using the Model Integrator
- •Working with Notes
- •Working with Packages
- •Adding Files and URLs to Rose Model Elements
- •Adding and Deleting Diagrams
- •Setting Global Options
- •Working with Fonts
- •Working with Colors
- •Summary
- •Chapter 3: Business Modeling
- •Introduction to Business Modeling
- •Why Model the Business?
- •Do I Need to Do Business Modeling?
- •Business Modeling in an Iterative Process
- •Business Actors
- •Business Workers
- •Business Use Cases
- •Business Use Case Diagrams
- •Activity Diagrams
- •Business Entities
- •Organization Unit
- •Where Do I Start?
- •Identifying the Business Actors
- •Identifying the Business Workers
- •Identifying the Business Use Cases
- •Showing the Interactions
- •Documenting the Details
- •Creating Business Use Case Diagrams
- •Deleting Business Use Case Diagrams
- •The Use Case Diagram Toolbar
- •Adding Business Use Cases
- •Business Use Case Specifications
- •Assigning a Priority to a Business Use Case
- •Viewing Diagrams for a Business Use Case
- •Viewing Relationships for a Business Use Case
- •Working with Business Actors
- •Adding Business Actors
- •Adding Actor Specifications
- •Assigning an Actor Stereotype
- •Setting Business Actor Multiplicity
- •Viewing Relationships for a Business Actor
- •Working with Relationships
- •Association Relationship
- •Generalization Relationship
- •Working with Organization Units
- •Adding Organization Units
- •Deleting Organization Units
- •Activity Diagrams
- •Adding an Activity Diagram
- •Adding Details to an Activity Diagram
- •Summary
- •Chapter 4: Use Cases and Actors
- •Use Case Modeling Concepts
- •Actors
- •Use Cases
- •Traceability
- •Flow of Events
- •Relationships
- •Use Case Diagrams
- •Activity Diagrams
- •Activity
- •Start and End States
- •Objects and Object Flows
- •Transitions
- •Synchronization
- •Working with Use Cases in Rational Rose
- •The Use Case Diagram Toolbar
- •Creating Use Case Diagrams
- •Deleting Use Case Diagrams
- •Adding Use Cases
- •Deleting Use Cases
- •Use Case Specifications
- •Naming a Use Case
- •Viewing Participants of a Use Case
- •Assigning a Use Case Stereotype
- •Assigning a Priority to a Use Case
- •Creating an Abstract Use Case
- •Viewing Diagrams for a Use Case
- •Viewing Relationships for a Use Case
- •Working with Actors
- •Adding Actors
- •Deleting Actors
- •Actor Specifications
- •Naming Actors
- •Assigning an Actor Stereotype
- •Setting Actor Multiplicity
- •Creating an Abstract Actor
- •Viewing Relationships for an Actor
- •Viewing an Actor's Instances
- •Working with Relationships
- •Association Relationship
- •Includes Relationship
- •Extends Relationship
- •Generalization Relationship
- •Working with Activity Diagrams
- •The Activity Diagram Toolbar
- •Creating Activity Diagrams
- •Deleting Activity Diagrams
- •Exercise
- •Problem Statement
- •Create a Use Case Diagram
- •Summary
- •Chapter 5: Object Interaction
- •Interaction Diagrams
- •What Is an Object?
- •What Is a Class?
- •Where Do I Start?
- •Finding Objects
- •Finding the Actor
- •Using Interaction Diagrams
- •Sequence Diagrams
- •The Sequence Diagram Toolbar
- •Collaboration Diagrams
- •The Collaboration Diagram Toolbar
- •Working with Actors on an Interaction Diagram
- •Working with Objects
- •Adding Objects to an Interaction Diagram
- •Deleting Objects from an Interaction Diagram
- •Setting Object Specifications
- •Naming an Object
- •Mapping an Object to a Class
- •Setting Object Persistence
- •Using Multiple Instances of an Object
- •Working with Messages
- •Adding Messages to an Interaction Diagram
- •Adding Messages to a Sequence Diagram
- •Deleting Messages from a Sequence Diagram
- •Reordering Messages in a Sequence Diagram
- •Message Numbering in a Sequence Diagram
- •Viewing the Focus of Control in a Sequence Diagram
- •Adding Messages to a Collaboration Diagram
- •Deleting Messages from a Collaboration Diagram
- •Message Numbering in a Collaboration Diagram
- •Adding Data Flows to a Collaboration Diagram
- •Setting Message Specifications
- •Naming a Message
- •Mapping a Message to an Operation
- •Setting Message Synchronization Options
- •Setting Message Frequency
- •End of a Lifeline
- •Working with Scripts
- •Switching Between Sequence and Collaboration Diagrams
- •Exercise
- •Problem Statement
- •Create Interaction Diagrams
- •Summary
- •Chapter 6: Classes and Packages
- •Logical View of a Rose Model
- •Class Diagrams
- •What Is a Class?
- •Finding Classes
- •Creating Class Diagrams
- •Deleting Class Diagrams
- •Organizing Items on a Class Diagram
- •Using the Class Diagram Toolbar
- •Working with Classes
- •Adding Classes
- •Class Stereotypes
- •Analysis Stereotypes
- •Class Types
- •Interfaces
- •Web Modeling Stereotypes
- •Other Language Stereotypes
- •Class Specifications
- •Naming a Class
- •Setting Class Visibility
- •Setting Class Multiplicity
- •Setting Storage Requirements for a Class
- •Setting Class Persistence
- •Setting Class Concurrency
- •Creating an Abstract Class
- •Viewing Class Attributes
- •Viewing Class Operations
- •Viewing Class Relationships
- •Using Nested Classes
- •Viewing the Interaction Diagrams That Contain a Class
- •Setting Java Class Specifications
- •Setting CORBA Class Specifications
- •Working with Packages
- •Adding Packages
- •Deleting Packages
- •Exercise
- •Problem Statement
- •Creating a Class Diagram
- •Summary
- •Chapter 7: Attributes and Operations
- •Working with Attributes
- •Finding Attributes
- •Adding Attributes
- •Deleting Attributes
- •Setting Attribute Specifications
- •Setting the Attribute Containment
- •Making an Attribute Static
- •Specifying a Derived Attribute
- •Working with Operations
- •Finding Operations
- •Adding Operations
- •Deleting Operations
- •Setting Operation Specifications
- •Adding Arguments to an Operation
- •Specifying the Operation Protocol
- •Specifying the Operation Qualifications
- •Specifying the Operation Exceptions
- •Specifying the Operation Size
- •Specifying the Operation Time
- •Specifying the Operation Concurrency
- •Specifying the Operation Preconditions
- •Specifying the Operation Postconditions
- •Specifying the Operation Semantics
- •Displaying Attributes and Operations on Class Diagrams
- •Showing Attributes
- •Showing Operations
- •Showing Visibility
- •Showing Stereotypes
- •Mapping Operations to Messages
- •Mapping an Operation to a Message on an Interaction Diagram
- •Exercise
- •Problem Statement
- •Add Attributes and Operations
- •Summary
- •Chapter 8: Relationships
- •Relationships
- •Types of Relationships
- •Finding Relationships
- •Associations
- •Using Web Association Stereotypes
- •Creating Associations
- •Deleting Associations
- •Dependencies
- •Creating Dependencies
- •Deleting Dependencies
- •Package Dependencies
- •Creating Package Dependencies
- •Deleting Package Dependencies
- •Aggregations
- •Creating Aggregations
- •Deleting Aggregations
- •Generalizations
- •Creating Generalizations
- •Deleting Generalizations
- •Working with Relationships
- •Setting Multiplicity
- •Using Relationship Names
- •Using Stereotypes
- •Using Roles
- •Setting Export Control
- •Using Static Relationships
- •Using Friend Relationships
- •Setting Containment
- •Using Qualifiers
- •Using Link Elements
- •Using Constraints
- •Exercise
- •Problem Statement
- •Adding Relationships
- •Summary
- •Chapter 9: Object Behavior
- •Statechart Diagrams
- •Creating a Statechart Diagram
- •Adding States
- •Adding State Details
- •Adding Transitions
- •Adding Transition Details
- •Adding Special States
- •Using Nested States and State History
- •Exercise
- •Problem Statement
- •Create a Statechart Diagram
- •Summary
- •Chapter 10: Component View
- •What Is a Component?
- •Types of Components
- •Component Diagrams
- •Creating Component Diagrams
- •Adding Components
- •Adding Component Details
- •Adding Component Dependencies
- •Exercise
- •Problem Statement
- •Summary
- •Chapter 11: Deployment View
- •Deployment Diagrams
- •Opening the Deployment Diagram
- •Adding Processors
- •Adding Processor Details
- •Adding Devices
- •Adding Device Details
- •Adding Connections
- •Adding Connection Details
- •Adding Processes
- •Exercise
- •Problem Statement
- •Create Deployment Diagram
- •Summary
- •Chapter 12: Introduction to Code Generation and Reverse Engineering Using Rational Rose
- •Preparing for Code Generation
- •Step One: Check the Model
- •Step Two: Create Components
- •Step Three: Map Classes to Components
- •Step Five: Select a Class, Component, or Package
- •Step Six: Generate Code
- •What Gets Generated?
- •Introduction to Reverse Engineering Using Rational Rose
- •Model Elements Created During Reverse Engineering
- •Summary
- •Chapter 13: ANSI C++ and Visual C++ Code Generation and Reverse Engineering
- •Generating Code in ANSI C++ and Visual C++
- •Converting a C++ Model to an ANSI C++ Model
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Package (Class Category) Properties
- •Component (Module Specification) Properties
- •Role Properties
- •Generalization Properties
- •Class Model Assistant
- •Component Properties
- •Project Properties
- •Visual C++ and ATL Objects
- •Generated Code
- •Code Generated for Classes
- •Code Generated for Attributes
- •Code Generated for Operations
- •Visual C++ Code Generation
- •Reverse Engineering ANSI C++
- •Reverse Engineering Visual C++
- •Summary
- •Overview
- •Introduction to Rose J
- •Beginning a Java Project
- •Selecting a Java Framework
- •Linking to IBM VisualAge for Java
- •Linking to Microsoft Visual J++
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Properties
- •Role Properties
- •Generating Code
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Interfaces
- •Java Beans
- •Support for J2EE
- •EJBs
- •Servlets
- •JAR and WAR Files
- •Automated J2EE Deployment
- •Reverse Engineering
- •Summary
- •Starting a Visual Basic Project
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Specification Properties
- •Role Properties
- •Generalization Properties
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Reverse Engineering
- •Summary
- •Overview
- •Introduction to XML DTD
- •Elements
- •Attributes
- •Entities and Notations
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Role Properties
- •Component Properties
- •Generating Code
- •Generated Code
- •Classes
- •Attributes
- •Reverse Engineering DTD
- •Summary
- •Project Properties
- •Class Properties
- •Attribute Properties
- •Operation Properties
- •Module Properties
- •Association (Role) Properties
- •Dependency Properties
- •Generated Code
- •Classes
- •Attributes
- •Operations
- •Bidirectional Associations
- •Unidirectional Associations
- •Associations with a Multiplicity of One to Many
- •Associations with a Multiplicity of Many to Many
- •Associations with Bounded Multiplicity
- •Reflexive Associations
- •Aggregations
- •Dependency Relationships
- •Generalization Relationships
- •Reverse Engineering CORBA Source Code
- •Summary
- •Chapter 18: Rose Data Modeler
- •Object Models and Data Models
- •Creating a Data Model
- •Logic in a Data Model
- •Adding a Database
- •Adding Tablespaces
- •Adding a Schema
- •Creating a Data Model Diagram
- •Creating Domain Packages and Domains
- •Adding Tables
- •Adding Columns
- •Setting a Primary Key
- •Adding Constraints
- •Adding Triggers
- •Adding Indexes
- •Adding Stored Procedures
- •Adding Relationships
- •Adding Referential Integrity Rules
- •Working with Views
- •Generating an Object Model from a Data Model
- •Generating a Data Model from an Object Model
- •Generating a Database from a Data Model
- •Updating an Existing Database
- •Reverse Engineering a Database
- •Summary
- •Chapter 19: Web Modeling
- •Modeling a Web Application
- •Web Class Stereotypes
- •Relationships
- •Reverse Engineering a Web Application
- •Generating Code for a Web Application
- •Summary
- •Appendix: Getting Started with UML
- •Building a Business Use Case Diagram
- •Building a Workflow (Activity) Diagram
- •Building a Use Case Diagram
- •Building an Interaction Diagram
- •Building a Class Diagram
- •Web Modeling
- •Adding Class Relationships
- •Building a Statechart Diagram
- •Building a Component Diagram
- •Building a Deployment Diagram
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
};
#endif
Before you can generate code, each of the attributes must have a case specifier. Open the specification window for each of the attributes, and enter a value in the Case Specifier property. The values you enter will control the case statements generated in the code. In the above example, the case specifier for Attribute1 is 1, and the specifier for Attribute2 is 2.
Attributes
As you may have noticed in the previous examples, attributes are generated in the code along with the class. This isn't true for all CORBA types, however. In this section, we'll examine the code generated for attributes for each of the types: interface, typedef, enumeration, constant, exception, structure, and union. For each of these types, we'll take a look at what is generated for the following class:
Attributes Generated for an Interface
In an interface, all of the attributes of the class will appear in the generated code. For each attribute, Rose will include:
∙
Data type
∙
Documentation
This is the interface that is generated for the SampleClass class:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
interface SampleClass { attribute string Attribute1; attribute string Attribute2;
};
#endif
588
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
Attributes Generated for a TypeDef
If the class stereotype is set to CORBATypeDef, attributes do not appear in the generated code.
Attributes Generated for an Enumeration
With an enumeration, Rose will place the attributes in the generated code. However, Rose will ignore the data types, default values, and other specifications of the attribute. Here is the enumeration generated for the SampleClass class:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
enum SampleClass {
Attribute1,
Attribute2
};
#endif
Attributes Generated for a Constant
If the class stereotype is set to CORBAConstant, attributes do not appear in the generated code.
Attributes Generated for an Exception
If the class stereotype is set to CORBAException, all attributes of the class will be included in the code. For each attribute, the code will include:
∙
Data type
∙
Documentation
Here is the code generated for SampleClass when the stereotype is set to CORBAException:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
exception SampleClass {
589
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
string Attribute1; string Attribute2;
};
#endif
Attributes Generated for a Structure
If the class stereotype is set to CORBAStruct, all attributes of the class will be included in the code. For each attribute, the code will include:
∙
Data type
∙
Documentation
Here is the code generated when the SampleClass stereotype is set to CORBAStruct:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
struct SampleClass { string Attribute1; string Attribute2; };
#endif
Attributes Generated for a Union
If the class stereotype is set to CORBAUnion, the attributes of the class will appear as case statements in the union. Here is the code generated for SampleClass:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
union SampleClass switch(long) { case 1: string Attribute1;
case 2: string Attribute2; };
590
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
#endif
The values used in the case statements are set by the values you enter in the Case Specifier field in each attribute's specification window.
Operations
The operations you define in your Rose model will appear in the generated IDL. Like attributes, though, operations are included only for certain CORBA types. In this section, we'll take a look at the code generated for operations of the following class:
We'll examine how the code is generated as the stereotype of the class changes.
Operations Generated for an Interface
With an interface, all of the operations for the class will appear in the generated code, along with their parameters, parameter data types, and return type. For the SampleClass class, the following interface was generated:
//Source file: C:/corba/SampleClass.idl
#ifndef __SAMPLECLASS_DEFINED #define __SAMPLECLASS_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "IncludedClass.idl"
interface SampleClass { /*
@roseuid 39B5C1A0006A */ string Operation1 ();
};
#endif
Operations Generated for Other CORBA/IDL Types
Operations are shown in the generated IDL only for interfaces. If the class stereotype is a typedef, enumeration, const, exception, struct, or union, operations will not be generated in the code.
Bidirectional Associations
To support bidirectional associations, Rose will generate attributes in the code. Each of the classes in the relationship will contain an attribute to support the association. The names of the generated attributes will be controlled by the role names on the association relationship. You must enter role names before you can generate code.
591
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
The code generated for the two classes shown above will resemble the following:
interface Class_A {
attribute Class_B Class_B_Role; };
and
interface Class_B {
attribute Class_A Class_A_Role; };
As you can see, Rose will automatically generate attributes on both sides of the bidirectional association relationship. With the Class_B_Role attribute, Class_A can easily access Class_B. Using the Class_A_Role attribute, Class_B can easily access Class_A.
The full code generated for Class_A is:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
interface Class_A {
attribute Class_B Class_B_Role;
};
As you can see, Class_A now includes an attribute of type Class_B. Class_B will also include an attribute of type Class_A. These two attributes support the relationship between Class_A and Class_B.
Bidirectional Associations Generated for a TypeDef
If the stereotype for Class_A is set to CORBATypeDef, a Class_B attribute will not be included in the code for Class_A. However, an #include statement will be added to the code in Class_A, as follows:
592
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
#include "Class_B.idl"
Bidirectional Associations Generated for an Enumeration
If the stereotype of Class_A is set to CORBAEnum, an include statement for Class_B.IDL will be included in the code. An attribute will not, however, be generated in Class_A. The code for Class_A looks like this:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
enum Class_A {
};
#endif
Bidirectional Associations Generated for a Constant
If Class_A is a constant, it will have an include statement for Class_B, but will not have an attribute that supports the relationship. Here is the code generated for Class_A:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
const long Class_A = 4;
#endif
Bidirectional Associations Generated for an Exception
If Class_A is an exception, an attribute of type Class_B will be generated inside it. Here is the code generated for Class_A:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
exception Class_A {
593
Chapter 17: CORBA/IDL Code Generation and Reverse Engineering
Class_B Class_B_Role; };
#endif
Bidirectional Associations Generated for a Structure
If the stereotype of Class_A is CORBAStruct, an attribute will be created inside Class_A when you generate the IDL.
The code for Class_A is as follows:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
struct Class_A { Class_B Class_B_Role; };
#endif
Bidirectional Associations Generated for a Union
If the stereotype for Class_A is set to CORBAUnion, the generated code will have an include statement for Class_B, and will include an instance of Class_B within the switch statement. Here is the code generated for Class_A:
//Source file: C:/corba/Class_A.idl
#ifndef CLASS_A_DEFINED #define CLASS_A_DEFINED
/* CmIdentification %X% %Q% %Z% %W% */
#include "Class_B.idl"
union Class_A switch() {
case 1: Class_B Class_B_Role; };
#endif
Note that the attribute generated from the association needs a case specifier, as do the other attributes of Class_A. The case specifier can be set using the Case Specifier Role code−generation property for the relationship.
594