You are on page 1of 26

Developing Real-Time Software with Rational Rose RealTime

Version 2001A.04.00

Module 10: Capsule Structure: Ports, Protocols, and Sub-capsules

Ports, Protocols, and Components Topics


Capsule Interfaces Ports Protocol Classes Capsule Structure

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

The Encapsulation Shell


Abstracts the functionality of the capsule Keeps changes within the capsule from affecting elements that interact with it Protects objects it contains

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Capsule Interfaces
A capsules interface is completely defined by its ports.

Ports
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports, Protocols, and Components Topics


Capsule Interfaces Ports Protocol Classes Capsule Structure

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports
Capsules communicate by sending and receiving messages through ports A port can only send and receive specific sets of messages Defined by a protocol class

Stimulus message
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Response messages

Ports (cont.)
Ports are interface elements between a capsules structure and behavior Ports have a composition relationship with the capsule they serve
Ports are created and destroyed along with the capsule that owns them

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports: Port Compatibility


Only ports with compatible protocols can communicate with each other
Two ports are compatible if they are of the same protocol or subclass In order for two ports to be connected, they must be opposite in conjugation
Conjugated port Base port

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports: Port Termination


End ports: terminate connectors; deliver messages from a capsules structure to capsules behavior, and vice versa Relay ports: relay messages to/from a subcapsule to a capsule outside its container
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

End Port

Relay Port Containing Capsule Boundary Contained Capsule Role

Ports: Wired vs. Unwired Ports (Java)


Wired ports: use connectors to set up message channels
Explicit visible associations
Unwired port Wired ports

Unwired ports: use name binding to set up message channels


No connectors used Dynamic connections Mechanism used with Connexis
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports: Port Visibility (Java)


Public ports: define a capsules external interface
Appear on capsules boundary in a structure diagram Use UML + in the name
Public port

Protected ports: connect a capsule to its subcapsules


Not accessible from outside a capsule, unless published Use UML # in the name
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Protected port

Ports, Protocols, and Components Topics


Capsule Interfaces Ports Protocol Classes Capsule Structure

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Protocol Class
Specifies which messages can be sent to and received from a port A message is defined by a named signal and any optional data
<<Protocol>> DeviceControl isOn (void) isOff (void) turnOn (void) turnOff (void)

Protocol Class
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Protocol Classes: Contractual Interaction Patterns


Protocol classes act as a contract between capsules, specifying what messages can be sent between them
Example: operator-assisted call
Caller
call ack number

Operator

ringBack
connected time

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Protocol Roles
A protocol class specifies the communication patterns between capsules, viewed from either end of the connection. The protocol role represents only a single view (base or conjugate), specifying which messages can be sent to and received by that specific port type The protocol role of the port determines which signals are incoming and outgoing Two ports must realize compatible protocols to permit a connector to be established between them
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Protocol Roles: Example


A protocol role specifies the protocol from significant sequence the perspective of one party
One protocol definition defines two roles: Base Conjugate
Base Protocol Role
<<Protocol>> ProtocolRoleA call (void) number (void) ack (void) ringBack (void) connected (void)
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

caller

operator

call ack number ringBack connected

Conjugate Protocol Role


<<Protocol>> ProtocolRoleB
ack (void) ringBack (void) connected (void) call (void) number (void)

Defining Protocols
Protocols capture the interactions related to each role a capsule plays in its collaborations Capsules that play similar roles may reuse protocol definitions Protocols should not be overloaded and should have a clear purpose:
Capture a complete message dialog between collaborating capsules

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Ports, Protocols, and Components Topics


Capsule Interfaces Ports Protocol Classes Capsule Structure

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Capsule Structure
Capsules contain component elements:
Subcapsules Passive classes Ports Connectors

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Structure Diagram
A specialized form of the collaboration diagram Specifies the capsule's interface and its internal composition
Ports Connector

Capsule Subcapsule

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Connectors
Objects that show key communication relationships between capsules
Connect ports that play complementary roles in the protocol they are associated with Can connect ports associated with different protocols if the ports are conjugate and the protocols have compatible in- and out-signals.
Connector

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Collaboration Diagram to Structure Diagram


A structure diagram is a more specialized form of collaboration diagram.

Structure Diagram Collaboration Diagram

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Showing Structure in a Class Diagram


A class diagram provides more detailed system decomposition
Class Diagram
/ client : Client + / link : Link + / link : Link~ / server : Server <<Capsule>> TheSystem

Structure Diagram
/ client <<Protocol>> Link response (void) command (void) / server

<<Capsule>> + / link Client <<Port>> + / link : Link

+ / link~ <<Port>>

<<Capsule>> Server + / link : Link~

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Review: Designing Ports and Protocols


Why are ports used to connect capsules? Why must connected end ports be opposite in conjugation? Why use a class diagram instead of a structure diagram?

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Low Temp Dyeing


fill start done Operator drain Controller level Tank

The Dying System

Level Filling Dyeing

Draining Empty

Time
Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

Developing Real-time Software With Rational Rose RealTime, v2001A.04.00 Copyright 2001 Rational Software, all rights reserved

You might also like