Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Mastering UML with Rational Rose 2002.pdf
Скачиваний:
137
Добавлен:
02.05.2014
Размер:
9.68 Mб
Скачать

Chapter 10: Component View

Adding Component Details

As with other Rose model elements, there are a number of detailed specifications you can add to each component. These include stereotypes, languages, declarations, and classes.

Stereotypes

The first detail is a component stereotype. The stereotype controls which icon will be used to represent the component.

As listed earlier, the stereotypes are <none> (which uses the Component icon), subprogram specification, subprogram body, main program, package specification, package body, executable, DLL, task specification, and task body.

In addition, Rose includes a number of other stereotypes for the different languages it supports. The language−specific stereotypes available in Rose are included in Table 10.1.

Table 10.1: Language−Specific Component Stereotypes

Language

Stereotypes

Java

EJBDeploymentDescriptor, EJB JAR, ServletDeploymentDescriptor,

 

and WAR

Oracle8

Database, Schema

Visual Basic

ActiveX Control

You can create additional stereotypes if you'd like to represent new types of components in your particular programming language and application.

To assign a stereotype:

1.

Open the desired component's standard specification window.

2.

Select the General tab, as shown in Figure 10.2.

367

Chapter 10: Component View

Figure 10.2: Assigning a stereotype to a component

3.

Enter the stereotype in the Stereotype field.

OR

1.

Select the desired component.

2.

Type the stereotype within the double angle brackets: << Name >>.

If the component is a Java, XML, or CORBA component, an additional component specification window is provided, as shown below:

368

Chapter 10: Component View

Languages

In Rose, you can assign languages on a component−by−component basis. Therefore, you can generate part of your model in C++, part in Java, part in Visual Basic, and so on, provided you have the Enterprise version of Rose installed.

Rose Enterprise contains add−ins for ANSI C++, Ada 83, Ada 95, CORBA, C++, Java, Visual Basic, Visual C++, Web Modeler, XML/DTD, and Oracle 8. Many more add−ins are available from various vendors to extend the capabilities of Rose. Add−ins for other languages (PowerBuilder, Forte, Visual Age for Java, etc.) may be purchased as well. For a complete list of Rose Link Partners, visit the Rational Rose website at http://www.rational.com/.

To assign a language:

1.

Open the desired component's standard specification window.

2.

Select the General tab.

3.

Enter the language in the Language field.

Declarations

In Rose, there is a place to include supplementary declarations that will be added during code generation for each component. Declarations include language−specific statements that are used to declare variables, classes, and so on. A C++ #include statement is also considered a declaration.

To add declarations:

1.

Open the desired component's standard specification window.

2.

369

Chapter 10: Component View

Select the Detail tab, as shown in Figure 10.3.

Figure 10.3: Adding declarations to a component

3.

Enter the declarations in the Declarations field.

Classes

Before code can be generated for a class, it must be mapped to a component. This mapping helps Rose know in which physical file the code for the class should be stored.

You can map one or more classes to each component. After you have mapped a class to a component, the component name will appear in parentheses after the class name in the Logical view.

370

Chapter 10: Component View

To map classes to a component:

1.

Open the desired component's standard specification window.

2.

Select the Realizes tab, as shown in Figure 10.4.

371