public class AMSService extends FIPAService
Agent.setup()
method and just
after Agent.takeDown()
method returns; so there is no need for a normal
programmer to call them.
However, under certain circumstances, a programmer might need to call its
methods. To give some examples: when an agent wishes to register with the
AMS of a remote agent platform, or when an agent wishes to modify its
description by adding a private address to the set of its addresses, ...
It includes methods to register, deregister, modify and search with an AMS.
Each of this method has version with all the needed parameters, or with a
subset of them where, those parameters that can be omitted have been
defaulted to the default AMS of the platform, the AID of the sending agent,
the default Search Constraints.
Notice that all these methods blocks every activity of the agent until the
action (i.e. register/deregister/modify/search) has been successfully
executed or a jade.domain.FIPAException exception has been thrown
(e.g. because a FAILURE message has been received by the AMS).
In some cases, instead, it is more convenient to execute this task in a
non-blocking way. The method getNonBlockingBehaviour() returns a
non-blocking behaviour of type RequestFIPAServiceBehaviour that can be
added to the queue of the agent behaviours, as usual, by using
Agent.addBehaviour()
.
The MIDP version of this class only includes the
getFailedReceiver()
method.
Constructor and Description |
---|
AMSService()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
deregister(Agent a)
A default AMSAgentDescription is used for this agent, where only AID and state
are set.
|
static void |
deregister(Agent a,
AID AMSName)
A default AMSAgentDescription is used for this agent, where only AID and state
are set (state is set to ACTIVE).
|
static void |
deregister(Agent a,
AID AMSName,
AMSAgentDescription amsd)
Deregister a AMSAgentDescription from a AMS agent.
|
static void |
deregister(Agent a,
AMSAgentDescription amsd)
The AID of the AMS is defaulted to the AMS of this platform.
|
static AID |
getFailedReceiver(Agent a,
ACLMessage failure)
Extracts the receiver a message could not be delivered to from
a FAILURE message received by the AMS.
|
static java.lang.String |
getFailureReason(Agent a,
ACLMessage failure) |
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
AID amsName,
java.lang.String actionName)
the default SearchContraints are used.
|
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
AID amsName,
java.lang.String actionName,
AMSAgentDescription amsd)
the default AMS is used.
|
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
AID AMSName,
java.lang.String actionName,
AMSAgentDescription amsd,
SearchConstraints constraints)
In some cases it is more convenient to execute this tasks in a non-blocking way.
|
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
java.lang.String actionName)
the default AMS is used.
|
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
java.lang.String actionName,
AMSAgentDescription amsd)
the default AMS is used.
|
static RequestFIPAServiceBehaviour |
getNonBlockingBehaviour(Agent a,
java.lang.String actionName,
AMSAgentDescription amsd,
SearchConstraints constraints)
the default AMS is used.
|
static void |
modify(Agent a,
AID AMSName,
AMSAgentDescription amsd)
Modifies data contained within a AMS
agent.
|
static void |
modify(Agent a,
AMSAgentDescription amsd)
The AID of the AMS is defaulted to the AMS of this platform.
|
static void |
register(Agent a,
AID AMSName,
AMSAgentDescription amsd)
Register a AMSAgentDescription with a AMS agent.
|
static void |
register(Agent a,
AMSAgentDescription amsd)
registers a
AMSAgentDescription with the default AMS |
static AMSAgentDescription[] |
search(Agent a,
AID AMSName,
AMSAgentDescription amsd)
searches with the passed AMS by using the default SearchConstraints.
|
static AMSAgentDescription[] |
search(Agent a,
AID AMSName,
AMSAgentDescription amsd,
SearchConstraints constraints)
Searches for data contained within a AMS agent.
|
static AMSAgentDescription[] |
search(Agent a,
AMSAgentDescription amsd)
searches with the default AMS and the default SearchConstraints.
|
static AMSAgentDescription[] |
search(Agent a,
AMSAgentDescription amsd,
SearchConstraints constraints)
searches with the default AMS
|
doFipaRequestClient, doFipaRequestClient, parseAID
public static void register(Agent a, AID AMSName, AMSAgentDescription amsd) throws FIPAException
a
- is the Agent performing the registrationAMSName
- The AID of the AMS agent to register with.amsd
- A AMSAgentDescriptor
object containing all
data necessary to the registration. If the Agent name is empty, than
it is set according to the a
parameter. If the Agent state is
empty, than it is set to ACTIVE.FIPAException
- A suitable exception can be thrown when
a refuse
or failure
messages are
received from the AMS to indicate some error condition or when
the method locally discovers that the amsdescription is not valid.public static void register(Agent a, AMSAgentDescription amsd) throws FIPAException
AMSAgentDescription
with the default AMSFIPAException
register(Agent,AID,AMSAgentDescription)
public static void deregister(Agent a, AID AMSName, AMSAgentDescription amsd) throws FIPAException
AMSName
- The AID of the AMS agent to deregister from.amsd
- A AMSAgentDescription
object containing all
data necessary to the deregistration.FIPAException
- A suitable exception can be thrown when
a refuse
or failure
messages are
received from the AMS to indicate some error condition or when
the method locally discovers that the amsdescription is not valid.public static void deregister(Agent a, AMSAgentDescription amsd) throws FIPAException
FIPAException
deregister(Agent a, AID AMSName, AMSAgentDescription amsd)
public static void deregister(Agent a, AID AMSName) throws FIPAException
FIPAException
deregister(Agent a, AID AMSName, AMSAgentDescription amsd)
public static void deregister(Agent a) throws FIPAException
FIPAException
deregister(Agent a, AID AMSName, AMSAgentDescription amsd)
public static void modify(Agent a, AID AMSName, AMSAgentDescription amsd) throws FIPAException
AMSName
- The GUID of the AMS agent holding the data
to be changed.amsd
- The new AMSAgentDescriptor
object
that should modify the existing one.FIPAException
- A suitable exception can be thrown when
a refuse
or failure
messages are
received from the AMS to indicate some error condition or when
the method locally discovers that the amsdescription is not valid.public static void modify(Agent a, AMSAgentDescription amsd) throws FIPAException
FIPAException
modify(Agent a, AID AMSName, AMSAgentDescription amsd)
public static AMSAgentDescription[] search(Agent a, AID AMSName, AMSAgentDescription amsd, SearchConstraints constraints) throws FIPAException
a
- is the Agent performing the searchAMSName
- The GUID of the AMS agent to start search from.amsd
- A AMSAgentDescriptor
object containing
data to search for; this parameter is used as a template to match
data against.constraints
- of the searchAMSAgentDescription
containing all found
items matching the given
descriptor, subject to given search constraints for search depth
and result size.FIPAException
- A suitable exception can be thrown when
a refuse
or failure
messages are
received from the AMS to indicate some error condition.public static AMSAgentDescription[] search(Agent a, AMSAgentDescription amsd, SearchConstraints constraints) throws FIPAException
FIPAException
search(Agent,AID,AMSAgentDescription,SearchConstraints)
public static AMSAgentDescription[] search(Agent a, AMSAgentDescription amsd) throws FIPAException
FIPAException
search(Agent,AID,AMSAgentDescription,SearchConstraints)
public static AMSAgentDescription[] search(Agent a, AID AMSName, AMSAgentDescription amsd) throws FIPAException
FIPAException
search(Agent,AID,AMSAgentDescription,SearchConstraints)
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, AID AMSName, java.lang.String actionName, AMSAgentDescription amsd, SearchConstraints constraints) throws FIPAException
Agent.addBehaviour()
.
Several ways are available to get the result of this behaviour and the programmer can select one according to his preferred programming style:
a
- is the agent performing the taskAMSName
- is the AID that should perform the requested actionactionName
- is the name of the action (one of the constants defined
in FIPAManagementOntology: REGISTER / DEREGISTER / MODIFY / SEARCH).amsd
- is the agent descriptionconstraints
- are the search constraints (can be null if this is
not a search operation)FIPAException
- A suitable exception can be thrown
to indicate some error condition
locally discovered (e.g.the amsdescription is not valid.)FIPAManagementOntology
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, java.lang.String actionName, AMSAgentDescription amsd, SearchConstraints constraints) throws FIPAException
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, java.lang.String actionName) throws FIPAException
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, AID amsName, java.lang.String actionName) throws FIPAException
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, java.lang.String actionName, AMSAgentDescription amsd) throws FIPAException
public static RequestFIPAServiceBehaviour getNonBlockingBehaviour(Agent a, AID amsName, java.lang.String actionName, AMSAgentDescription amsd) throws FIPAException
public static AID getFailedReceiver(Agent a, ACLMessage failure) throws FIPAException
a
- The agent that is calling this method.failure
- The FAILURE message received by thye AMS.FIPAException
public static java.lang.String getFailureReason(Agent a, ACLMessage failure) throws FIPAException
FIPAException