Java Reference
In-Depth Information
resource :
ResourceAllocator
provider :
BasicNegotiator
mediator :
Mediator
User
new
prefs :
ResourcePreferences
startNegotiation(client,provide)
book()
preference(prefs)
Figure 20.8
Initialization scenario
resource. Each resource is described by the values of the attributes; such
values can be seen as coordinates in an
n
-dimensional space, thus the
description of a resource is implemented as a
Map
that maps the name of the
attribute (or dimension) into the value of the attribute (or coordinate). In
addition it has two counters that represent the available and the booked
items. Method
match()
matches the coordinates of the resource against a set
of values for the attributes.
package
booking;
import
java.util.*;
class
Resource {
// the description of the resource expressed as
// coordinates in an n-dimensional space, one dimension
// for each attribute.
Map coordinates;
int
available; // number of available resources
int
booked; // number of booked resources
Resource(Map coordinates,
int
available){
this
.coordinates
#
coordinates;
this
.available
#
available;
booked
#
0;
}
// compares the resource coordinates with other
// coordinates