UML Modeling Techniques > Class modeling > Ports > Overview of ports
  
Overview of ports
A Port is an optionally named connection point that is typed by its interface. A Port is modeled through a Role or an Attribute (untyped or with a Class, Data Type, Interface or Signal set as its data type) in the context of a top-level Class, Data Type, Interface or Signal, and its contained Parts and Ports.
Each Port that does not use a Basic Type or Type Definition as its type can contain many Parts and Ports, and so on. A Port that uses a Basic Type or Type Definition cannot contain Parts or Ports.
An aggregate Role or Attribute is a Port only if the Port check box is selected on its Property Pages. Each Part and Port can contain many Parts and Ports, and so on.
When a Role or Attribute represents a Port (Port check box selected on Property Pages), its symbol in Modeler pane is as follows:
In the Packages and Parts pane, a Port's name is shown as follows:
A Port appears on a Composite Structure Diagram as a box on the boundary of a Class, Data Type, Interface, Signal, Part or Port.
Non-composite Ports are shown with a dashed outline.
Ports that are conjugated have the type prefixed with a tilde.
Through the View Options you can show or hide a Port's Name, Full Name, Type, Multiplicity and Default Value. In addition, you can make a Port snap to the boundary of the owning Part or Port – you can snap to the inside, middle or outside of the boundary.
Note that the Full Name of a Port is shown only when the Port is displayed on the diagram as a top-level item.
If a Port is unnamed, the name of the Port's type is displayed in square brackets when displayed in a Modeler pane.
Through the Options tab of a Port's Property Pages, you can model a behavior Port through the Behavior check box.
If a Port has no Stereotypes applied to it, you can display its type's Stereotypes on the Composite Structure Diagram.
Class, Data Type, Interface and Signal contained Ports
When a Class, Data Type, Interface or Signal contains a Port, the Port can be a Role or Attribute (untyped or with a Basic Type, Class, Data Type, Interface, Signal or Type Definition set as its data type), and the Port can be created on the Class Diagram or Composite Structure Diagram:
On a Class Diagram, you create a Port through a Role or Attribute:
By adding an Aggregation or Association (which creates a Role that is the Port) between the Class, Data Type, Interface or Signal and the Port's type, and then selecting the Port check box on the aggregate Role's Property Pages.
By adding an Attribute to the Class, Data Type, Interface or Signal, selecting the Port check box on the Attribute's Property Pages, and then setting its Data Type to the Port's type.
On a Composite Structure Diagram, you create a Port through the Port button:
If you create a Port on a Class, Data Type, Interface or Signal that uses a Class, Data Type, Interface or Signal as its type, Modeler uses a composite aggregate Role to create the Port.
If you create a Port on a Class, Data Type, Interface or Signal that is untyped or uses a Basic Type or Type Definition as its type, Modeler uses a composite Attribute to create the Port.
If you create a Port on a Part or Port, Modeler uses a composite aggregate Role to create the Port.
The following example shows how a Port created from an aggregate Role appears in Modeler. Class1 has a Port (aggregate Role) named Port1 whose type is Class2. The Composite property of Port1 is derived from the Composite Aggregation property of the associated Association. The Port check box is selected.
The following example shows how a Port created from a composite Attribute appears in Modeler. Class1 has a Port (composite Attribute) named Port1 whose type is Class2. The Composite and Port check boxes on Port1's Property Pages are selected.
If you create a Port for a Class or Signal, that Port (and its contained Parts and Ports) are available to any Part or Port that uses the Class or Signal as its type.
Class and Signal contained Ports are shown on the Packages pane and the Parts pane.
Part and Port contained Ports
When you create a Port for a Part or Port, you must do so through the Composite Structure Diagram: Modeler creates a typed Port as an aggregate Role, and creates an untyped Port as a composite Attribute.
The following example shows how a Port created for a Part on a Composite Structure Diagram appears in Modeler. The Port2 port has been added to Part1 part on the Composite Structure Diagram.
Note that adding the Port2 port to the Port1 part does not create a composite Aggregation between their types, that is, Class2 and Class3.
Part and Port contained Ports are shown on the Parts pane, but not the Packages pane.
Adding Ports to a Composite Structure Diagram
You can create new Ports for a Class, Data Type, Interface, Signal, Part or Port on a Composite Structure Diagram through the Port button on the Structure Diagram Toolbar.
Through the Port button you can also add existing Ports to a Class, Data Type, Interface, Signal, Part or Port by right-clicking the diagram item. When adding an existing Port, Modeler lists valid Ports that can be added, that is, the Ports that have previously been added to the item (Class, Data Type, Interface, Signal, Part or Port) and any Ports the item's type has.
You can show a Port on a Composite Structure Diagram as a top-level item - you do this by dragging the Port to free space on the Composite Structure Diagram. Use the Parts pane to find Ports in context.
You can use the Populate Ports command on the context menu of a Class, Data Type, Interface, Signal, Part or Port to add contained Ports on a Composite Structure Diagram.
Rescoping Ports
You can rescope Ports through the Parts pane and through Composite Structure Diagrams:
In the Parts pane, drag the Port you want to rescope to the required Class, Data Type, Interface, Signal, Part or Port.
On a Composite Structure Diagram, drag the Port you want to rescope from the Parts pane or from the Composite Structure Diagram, and drop the Port to the required Class, Data Type, Interface, Signal, Part or Port on the diagram.
Redefinitions
When you create a Port, you create that Port in the context of a top-level Class, Data Type, Interface or Signal, and its contained Parts and Ports. If a Port inherits Parts or Ports from its type (a Class, Data Type, Interface or Signal), the inherited Parts and Ports are used in a different context to that of the Class, Data Type, Interface or Signal. When a Part or Port is created in a different context, Modeler creates that Part or Port as a redefinition so that you can refine it independently of the item it redefines.
For more information about redefinitions, see Overview of part and port redefinitions.
Rolling up features
On a Composite Structure Diagram you can add the following features to a Port: Parts, Ports, Associations and Dependencies to Interfaces. After creating these features in the context of a Port, you can roll up the features to the Port's type (a Class, Data Type, Interface or Signal), so that the features are available to any Part or Port that uses that Class, Data Type, Interface or Signal as its type. Also, after rolling up a Port's features, those features can be shown on Class Diagrams.
For more information about rolling up features, see Overview of rolling up part and port features.