In composite structure diagrams, a port defines the interaction point between a classifier instance and its environment or between the behavior of the classifier and its internal parts.
Because all interactions between the external environment and the internal parts must pass through a port, you can use a port to isolate the internal parts of an object from its environment. Connectors link ports to properties of the classifier and invoke communication between two or more instances. You can define multiple ports for a classifier to show different interactions depending on the port from which the interaction originates.
As the following figure illustrates, a port is displayed in the diagram frame as a small square with the name of the port.
You can add ports to the border of a composite structure diagram and to the interior parts of the composite structure diagram. In the above example, a delegate connector links the Port:Car port on the external structure compartment to the internal part named e:Engine. An assembly connector links the two internal parts of front:Wheel[2] and rear:Wheel[2] to the internal port named Port:Engine.
A port can interact in both directions and you can add required and provided interfaces to specify the types of interactions that can occur between a classifier and its environment.
As the following figures illustrates, a port is an interaction point between a classifier and its environment and it can group any number of required and provided interfaces into a logical interaction that a classifier can have with the outside world.
In the above example, the Car classifier has two ports. The external port Engine:PowerGenerator has a required interface Gasoline that the Car class needs to operate the car. The internal port DriverSeatbelt:Seatbelt has a provided interface SafetyDevice that the Car class offers to the driver to operate the car.
You can change the position of a port in a composite structure diagram by using the isService property of the port. If the isService property is set to true, the port appears on the border of the composite structure diagram, indicating that the port is required by its environment. If you set the property to false, the port moves inside the structure compartment, indicating that the port is used only for internal implementation of the classifier and is not required by its environment. When the isService property is set to false, you can delete or modify the port without affecting the use of the classifier.