stance, the pump component’s pump method is trans-
lated in lines 63-72, which essentially consists of
three parts. In the first part (lines 64–65), the interac-
tion contracts imposed on the pump method are trans-
lated. Apparently, the method is not constrained with
any delaying interaction contracts (waits) - neither by
the component port nor the connector roles. How-
ever, the method is constrained with an accepting in-
teraction contract, translated as a selection construct
in lines 64-65. So, if the pump has not been released
yet, a Java exception will be thrown, which will halt
the system execution. If the interaction constraints
are satisfied (i.e., no exception thrown), the functional
contract translated in lines 66-69 is executed. If the
payment amount recorded for the customer is not zero
(i.e., the first requires pre-condition), the correspond-
ing ensures assigns the pump-released data to false to
be able to release the gas again upon request. Other-
wise, a Java exception is thrown and the program is
halted (line 69) to indicate the incomplete behaviour
specification (i.e., the case when the payment infor-
mation is not received is not considered by the pump
specification). Lastly, inline 70, the Object class’s no-
tify method is called and the result (i.e., the payment
amount) is returned to the caller.
To enhance the understandability of the generated
Java code, the translation algorithms have been de-
signed using the adapter design pattern. For any con-
nector link that connects the compatible ports of any
two components, the translated Java class from the
connector link acts as an adapter, the providing com-
ponent class (i.e., the one with the provided/consumer
port) acts as an adaptee, and the requiring compo-
nent class (i.e., with the required/emitter port) acts
as a client. The requiring component class uses the
connector class to call the methods of the providing
class indirectly. So, the classes of the two compo-
nents whose required and provided (or emitter and
consumer) ports are interconnected and request the
methods (or events) of each other do not know each
other thanks to the connector.
Practitioners may also test the executable Java
programs produced from the XCD specifications. In-
deed, as discussed in Section 4.2.1 and 4.2.2, the
translation algorithms consider the incomplete func-
tional behaviours and wrong use of component port
services. Whenever such issues occur during the
system execution, a Java exception is thrown with
the necessary explanation message. When the Java
source-code in Figure 3 produced from the gas station
specification was run, a Java exception was thrown
due to the wrong use of services and the program
halted. According to the error message, the error has
essentially been resulted from the pump method of the
pump component (see lines 63-72 in Figure 3). Dur-
ing the system execution, the accepting interaction
contract in lines 64-65 has been violated as the pump
method has been called before the pump has been re-
leased. Note though that unlike formal analysis, soft-
ware testing does not check every possible system
paths for the aforementioned properties. Therefore,
the non-existence of any errors during the software
testing does not guarantee that every single path can
also be executed successfully.
6 RELATED WORK
According to Malavolta etal.’s recent survey on the
ALs, there are 125 different ALs that have been de-
veloped so far (Ivano Malavolta, 2017). The exist-
ing ALs have been analysed in this study for (i) the
support for structural, behavioural, and interaction
design decisions, (ii) the exhaustive model checking
of those design decisions, and (iii) generating soft-
ware code from the design decision specifications.
According to the analysis results, only 6 ALs sup-
port all those requirements, i.e., Prisma (P
´
erez et al.,
2003), Ambient-Prisma (Ali et al., 2010), Aspect-
Leda (Navasa et al., 2007), Korrigan (Choppy et al.,
2001), pi-ADL (Oquendo, 2004), and XCD (Ozkaya
and Kloukinas, 2014). Table 1 shows the notations
that the ALs use for specifying the structural, be-
havioural, and interaction decisions, the supported
properties for analysis, and the programming lan-
guage used in generating software code.
Prisma offers a UML-like graphical notation for
specifying system structures in terms of compo-
nents and connectors, and their behaviours/proto-
cols are specified as an aspect that is specified in
the pi-calculus process algebra (Milner et al., 1992).
Prisma’s modelling toolset allows for specifying user-
defined requirements in temporal logics and checking
the consistencies of the specifications and analysing
them for the requirement specifications. Prisma’s
toolset also generates C# code, which can be ex-
ecuted on the .NET platform. Ambient-Prisma is
the extension of Prisma with the notion of ambi-
ents for specifying mobile software systems. Un-
like Prisma, Ambient-Prisma is based on Ambient-
calculus (Cardelli and Gordon, 1998), in which the
aspects are specified formally. Like Ambient-Prisma,
pi-ADL also focuses on the software architecture
specifications of mobile systems. Pi-ADL is based
on the pi-calculus process algebra. Pi-ADL supports
the specifications of user-defined requirements in pi-
calculus (or temporal logic) and supports the exhaus-
tive model checking via the CADP verification tool
Implementing Contract-based Software Architectures in Java: The Structural, Behavioural, and Interaction Design Decisions
353