Java Reference
In-Depth Information
Collection resources # new Vector();
// the specification, defining the attributes
// (i.e. coordinates)
Specification specification;
public ResourceAllocation(Specification specification) {
this .specification # specification;
// define the number of available resources of a given type
// the type is expressed in terms of coordinates
public void setAvailability(Map coordinates, int available){
Resource res # new Resource(coordinates,available);
// book a resource corresponding to a proposal
// this method MUST be invoked at the end of a successful
// negotiation
public void book(Proposal proposal){
if (proposal ## null ) return ;
Map coordinates # new Hashtable();
Iterator it # proposal.getAttributes().iterator();
while (it.hasNext()){
Attribute attribute # (Attribute);
// book a resource with the given coordinates
private void book(Map coordinates){
Iterator it # resources.iterator();
while (it.hasNext()){
Resource resource # (Resource);
if (resource.match(coordinates)){;
return ;
// return the preferences
public PreferenceMap preference(){
PreferenceMap pref # new ResourcePreference
return preference(pref);
// re-calculate the ranks and weights of the preference
public PreferenceMap preference(PreferenceMap pref){
Search WWH ::

Custom Search