UML Modeling Techniques > Class modeling > Creating class modeling items > Creating a port
  
Creating a port
You can create a Port on a type or on another Part:
When you create a Port on a type (Class, Data Type, Interface or Signal), that Port is available to any Part or Port that uses that Class, Data Type, Interface or Signal as its type.
When you create a Port on a Part, that Port is created in the context of its container items.
You can create a Port as an Attribute or Role. However, untyped Ports can be created only as Attributes.
On a Composite Structure Diagram, you can create an Association and Ports to connect that Association in one operation.
To create a port (as a role) on a type:
1. On a Composite Structure Diagram , add the type (Class, Data Type, Interface or Signal) on which you are going to create a Port.
2. On the Structure Diagram toolbar, click the Port button.
3. Click the edge of the Class, Data Type, Interface or Signal on which you want to create the Port.
4. From the Select Object dialog, select the item you want to use as the Port's type, and then click OK
or
Click the appropriate button to create a new type for the Port or an untyped Port.
5. Type the name of the Port, and then press the Enter key.
Alternatively,
1. On a Composite Structure Diagram, add the type (Class, Data Type, Interface or Signal) on which you are going to create a Port.
2. In a Modeler pane, locate the item you want to use as the Port's type.
3. Drag the item you want to use as the Port's type from the Modeler pane to the edge of the type on the Composite Structure Diagram.
4. Select the Port that is created on the diagram, and through its Property Pages set the name of the Port.
Alternatively,
1. On a Class Diagram, add the item on which you want to create the Port.
2. On the same diagram, add the item that you want to use as the Port's type.
3. On the Class Diagram toolbar, click the Composite Aggregation button.
4. Click the item on which you are creating the Port, and then click the item that you want to use as the Port's type.
Type the name of the composite aggregation, and then press the Enter key.
5. Open the aggregation's Property Pages.
6. Click the General tab.
7. In the Name box, type the name of the Port.
8. Click the End Role ab, and then click the Properties button.
9. Click the Options tab., Select the Port check box.
To create a port (as an attribute) on a type:
1. On a Class Diagram, add the item on which you want to create the Port.
2. On the Class Diagram toolbar, click the Attribute button.
3. Click the item on which you are creating the Port.
4. Type the name of the Port, and then press the Enter key.
5. Open the Attribute's property pages.
6. Click the Options tab.
7. Select the Port check box.
8. Click the Data Type tab.
9. Click the Select button, and select the item that you want to use as the Port's type.
Alternatively,
1. In a Modeler pane, locate the item on which you want to create a Port.
2. Right-click the item, point to New, and then click Attribute.
3. Type the name of the Port, and then press the Enter key.
4. Open the Attribute's property pages.
5. Click the Options tab.
6. Select the Port check box.
7. Click the Data Type tab.
8. Click the Select button, and select the item that you want to use as the Port's type.
To create a port on a part:
1. On a Composite Structure Diagram , ensure that the Part on which you want to create a new Port is shown.
2. On the Structure Diagram toolbar, click the Port button.
3. Click on the edge of the Part on which you want to create a Port.
Note that you cannot click on a Part that uses a Basic Type or Type Definition as its type.
4. From the Select Object dialog, select the item you want to use as the Port's type, and then click OK.
or
Click the appropriate button to create a new type for the Port or an untyped Port.
The Port is created in the context of its container items. The Port is created as a Role, unless you created an untyped Port, in which case it is created as an Attribute.
Alternatively,
1. On a Composite Structure Diagram , ensure that the Part on which you want to create a new Port is shown.
2. In a Modeler pane, locate the item you want to use as the new Port's type.
3. Drag the item you want to use as the Port's type from the Modeler pane to the edge of the Part on the Composite Structure Diagram.
4. Select the new Port that is created on the diagram, and through its Property Pages set the name of the Port.
To create an association and ports to connect that association in one operation:
1. On a Composite Structure Diagram, ensure that the items you want to connect are shown.
2. On the Structure Diagram toolbar, click the Complete Association button.
3. Click the source Class, Part or Port.
4. Click the destination Class, Part or Port.
5. If the Select Object dialog is displayed, create or select the type of the Ports that will be created, or click Untyped to create untyped Ports, and then click OK.
Note that if you create a complete association between a Port and a Class or Part, the new Port will use the same type as the connected Port.