# Incremental Construction for Scalable Component-Based Systems
## 4 Incremental Construction in CBD
### Architecture Description Languages
#### 4.2.3 The Basic Publish-Subscribe Component Model  
In the publish-subscribe architectural style, messages flow from one publisher component to many subscriber components. The publish-subscribe style is suitable to construct a system where many different components have to perform their specific computations subject to an event in one common component. In CBD, many component models (e.g., ACME, C2 [49] and SOFA) support this style.  
In the basic publish-subscribe (basic-ps) component model, a component is an AU with zero or more publisher ports (pub-ports) and with one or more subscriber ports (sub-ports) (Figure 17a). A message signature is associated with each port that represents the type of message allowed to be communicated through the port. The functionality of a component is a set of services and a service is a relation between a subset of pub-ports and one sub-port (Figure 17b shows the functionality of a specific component \(K\)). A sub-port only allows a message to pass into the component and a pub-port only allows a message to go out of the component. In basic-ps, for a component, one pub-port may be related to many sub-ports, as shown in Figure 17b for \(K\). A component may have services in which no event is raised within the service. The behavior of a component can also be represented as a set of sub-ports; sub-ports are simply functions of pub-ports, as shown in Figure 17c for \(K\). Components in basic-ps have their own control. Figure 17c shows the execution semantics of a service of a component. A service executes by receiving notification on the associated sub-port and raises event(s) on associated pub-port(s).  
Figure 16: A basic-cs system in ArchJava: (**a**) First system and (**b**) Second System.  
In basic-ps, components are composed by port connection between matching ports, as shown in Figure 17d; the result of composition is a composite. In basic-ps, for simplicity, we consider that a sub-port may be connected to one pub-port at a time and a pub-port may be connected to zero or more sub-ports. All unconnected ports of the composed components are the respective ports of the composite. In Figure 17d, considering component \(A\) as initial system \(S_{0}\) and component \(C\) as increment \(inc_{0}\). Composite \(AC\) is the incremented system \(S_{1}\) and service s5 of \(S_{1}\) contains s2 and s3. As the relation of behavior containment between the two systems holds (\(B_{A}\subseteq B_{AC}\)), basic-ps component model supports incremental construction.  
To illustrate incremental construction, a system to evaluate a mathematical expression (\(c=a^{2}+b^{3}\)) is constructed from three components \(calc\), \(sCom\) and \(cCom\) in ArchJava as shown in Figure 18. The \(op\) service of \(calc\) accepts two numbers (of type integer) as arguments and broadcasts on its ports 'b' and 'c'. Service _getSq_ receives the result on port 'e' and raises an event on port 'd' if port 'f' has been notified. Service _getCu_ receives result on port 'f' and raises an event on port 'd' if port 'e' has been notified. Component \(sCom\) offers service \(sq\) to square a number and to broadcast the result on port 'h'. Similarly a component \(cCom\) offers service \(cu\) to cube a number and to broadcast the result on port 'h'.