Information Technology Reference
In-Depth Information
based on Maude [12], which allows both closed world and open world simulation
as well as guided simulation, and a graphic display of the simulations.
In the rest of this section, we specify the interfaces of a local data store for a
peer syntactically. Then, we implement parts of a peer as an example.
Each peer consists of a client object, a server object and a data-store object.
The
Client
interface provides the user with a search operation. The data-store pro-
vides the client object with an
add
operation to introduce new data and the server
object with a
find
operation to retrieve data. We model these two perspectives
on the data-store by two interfaces
StoreClientPerspective
and
StoreServerPerspective
.
The interfaces are structured in terms of inheritance and cointerface require-
ments. The cointerface of a method (denoted by the
with
keyword) is a static
restriction on the objects that may call the method. In the model, the cointerface
reflects the intended user of an interface. In Creol, object references are always
typed by interfaces. The caller of a method is available via the implicit variable
caller
. Specifying a concrete cointerface allows for callbacks. Finally, method
parameters are separated into input and output parameters, using
in
and
out
keywords, respectively.
interface
StoreClientPerspective
begin
1
with
Client
2
op
add(
in
key : Data ,
info : Data )
3
end
4
interface
StoreServerPerspective
begin
6
with
Server
7
op
find(
in
key : Data ;
out
info :Data)
8
end
9
interface
Store
11
inherits
StoreClientPerspective , StoreServerPerspective
12
begin end
13
The interfaces cover the intra-component communication while the facades cover
the inter-component communication (cf. Section 2.1). To implement a Creol
class, we can use only the ports and events specified in the facades. Note that
the use of ports is restricted to reading from an inport or writing to an outport.
Since the inter-component communication is coordinated exogenously by the
network, the components are not allowed to alter the port bindings; instead,
they have to raise an event to request a reconfiguration of the communication
network structure.
Next, we provide implementation models for the interfaces in terms of Creol
classes. The client offers a search method to the user. To perform a search, the
client makes a request to the broker. The event
openCS
<
req, ans
>
(key; found)
pro-
vides the ports
req
and
ans
to be reconfigured, plus the parameters
key
and
found
.
If the data identified by
key
is available, the broker connects the given ports to a
server holding the data and reports via
found
the success of the search. Otherwise,
the ports are left unchanged and the failure is reported via
found
. If successful the