A port is a distinct interaction point between
a class and its environment or between (the behavior of) a class and
its internal parts. Use ports to specify classes that are independent
of the environment in which they are embedded. The internal parts
of the class can be isolated from the environment and vice versa.
A
port can have the following interfaces:
- Provided interfaces characterize the requests
that can be made from the environment to the class through the port.
A provided interface is denoted by a lollipop or ball notation.
- Required interfaces characterize the requests
that can be made from the class through the port to its environment
(external objects). A required interface is denoted by a socket notation.
The following figure shows the AbsHardware class with a port (the
small square at the bottom edge of the class element) that has a provided
interface (lollipop or ball) and a required interface (socket).
These interfaces are specified using a contract,
which by itself is a provided interface. For more information, see Specifying the port contract.
If a port is behavioral, the messages of
the provided interface are forwarded to the owner class; if it is non-behavioral,
the messages are sent to one of the internal parts of the class. Classes
can distinguish between events of the same type if they are received
from different ports.
Note: The product provides a C++ sample project (HomeAlarmWithPorts)
that shows a home alarm security system that illustrates the usage
of UML 2 ports to specify part interaction points. See <product
installation folder>\Samples\CppSamples\.