|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--anthill.nestor.LocalNest
A Nest class collects the components of a Nest site: (i) a AntView object, which is the view of a Nest for an Ant; (ii) a Gate object, which manage the communication between nests; (iii) an Manager, i.e. the object which manage the activities performed by different agents.
Implementation note: this implementation is supposed to be used as
simple implementation of Nest
in the off-line
environment. Here, we assume that the Manager object used is single-threaded;
in this way, we avoid the costs of synchronized methods.
Field Summary | |
static java.lang.String |
NEST_TTL
String name of the parameter used to determine the ttl used by these nests. |
Constructor Summary | |
LocalNest(Factory factory)
Constructs a new nest. |
Method Summary | |
void |
addAntNeighbour(NestId aid)
Add the identifier of a new neighbour nest to the set of neighbours known to this Nest , on behalf of
an ant. |
void |
addClientNeighbour(NestId aid)
Add the identifier of a new neighbour nest to the set of neighbours known to this Nest , on behalf of
an Nest client. |
void |
addResource(Resource resource)
Add a resource to the nest. |
void |
clear()
Restores the object to its initial state. |
void |
deliver(AntDescriptor desc)
Receive an agent from outside and deliver it to the to the activity manager. |
NestId |
getId()
Return the identifier of this Nest |
Manager |
getManager()
Return the Manager associated to this Nest |
Neighbour[] |
getNeighbours()
Return the neighbours known to this Nest |
java.lang.Object |
getPheromone(java.lang.Class cl)
Return the pheromone associated to the link to this neighbour. |
Resource |
getResource(java.lang.Object key)
Performs the specified request on the local resource storage and returns the resources satisfying the request. |
Resource[] |
getResources(java.lang.Object request)
Performs the specified request on the local resource storage and returns the resources satisfying the request. |
Storage |
getStorage(java.lang.String name)
Return a storage object identified by the given name. |
void |
insert(Resource resource)
Insert a new resource in this nest. |
int |
intValue(java.lang.String name)
Read from statistics |
void |
removeNeighbour(NestId aid)
Remove a neighbour identifier from the set of neighbour |
void |
request(RequestId rid,
java.lang.Object request,
ResponseListener listener)
Accepts a request from the nest user. |
void |
setPheromone(java.lang.Object pheromone,
java.lang.Class cl)
Return the pheromone associated to the link to this neighbour. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String NEST_TTL
Constructor Detail |
public LocalNest(Factory factory)
Method Detail |
public void clear()
clear
in interface Clearable
public void deliver(AntDescriptor desc)
deliver
in interface AntListener
anthill.nest.AntListener
sender
- the identifier of the nest from which this ant
has been receiveddesc
- the ant descriptor of the received antjava.rmi.RemoteException
- added to the throw clause to respect
the conventions for remote interfaces.public NestId getId()
getId
in interface Nest
public Manager getManager()
getManager
in interface Nest
public void request(RequestId rid, java.lang.Object request, ResponseListener listener)
Implementation note: If the resource can be found locally,
the listener is immediately contacted. Otherwise, a new
Ant
is generated and is delivered to the ant
manager.
request
in interface Nest
request
- the request to be performedlistener
- The listener object which will be notified
when the request is completed.public void insert(Resource resource)
insert
in interface Nest
resource
- the resource to be inserted.public void addClientNeighbour(NestId aid)
Nest
, on behalf of
an Nest client.addClientNeighbour
in interface Nest
aid
- neighbour identifierpublic void addAntNeighbour(NestId aid)
Nest
, on behalf of
an ant.addAntNeighbour
in interface Nest
aid
- neighbour identifierpublic void removeNeighbour(NestId aid)
removeNeighbour
in interface Nest
aid
- neighbour identifierpublic Neighbour[] getNeighbours()
getNeighbours
in interface Nest
public java.lang.Object getPheromone(java.lang.Class cl)
public void setPheromone(java.lang.Object pheromone, java.lang.Class cl)
public Storage getStorage(java.lang.String name) throws StorageNotFoundException
getStorage
in interface Nest
anthill.nest.Nest
name
- name of the storage to obtain a reference to.Storage
referenceStorageNotFoundException
- if the specified name does not
correspond to a storage currently available from this nest.public Resource[] getResources(java.lang.Object request)
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
request
- The request to be performedpublic Resource getResource(java.lang.Object key)
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
request
- The request to be performedpublic void addResource(Resource resource) throws CapacityException
Depending on the implementation of Resource
and Nest
, adding a resource to a nest through
an AntView may result to actual copy the content of the
resource, or to simply insert a reference to the actual
position of the resource itself.
This method may be invoked more than once from an ant, in
order to insert more resources. Nevertheless, the actual
insertion of a resource in a nest depends on the policies
of the particular Nest
implementation. For
example, a nest may limit the number of resources originated
by another nest, in order to avoid "spamming".
The exact behavior of this method depends on the implementation of the current nest hosting the ant. Please refer to the documentation of the nest implementation for more details.
resource
- resource to be addedpublic java.lang.String toString()
toString
in class java.lang.Object
public int intValue(java.lang.String name)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |