public class SubscriptionResponder extends FSMBehaviour implements FIPANames.InteractionProtocol
SubscriptionInitiator,
Serialized Form| Modifier and Type | Class and Description |
|---|---|
static class |
SubscriptionResponder.Subscription
Inner calss Subscription
This class represents a subscription.
|
static interface |
SubscriptionResponder.SubscriptionManager
Inner interface SubscriptionManager.
|
| Modifier and Type | Field and Description |
|---|---|
java.lang.String |
CANCEL_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object sent by the initiator to cancel a subscription.
|
protected SubscriptionResponder.SubscriptionManager |
mySubscriptionManager
The
SubscriptionManager used by this
SubscriptionResponder to register subscriptions |
java.lang.String |
RESPONSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object sent as a response to the initiator.
|
java.lang.String |
SUBSCRIPTION_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage
object sent by the initiator as a subscription.
|
currentName, lastStatesFIPA_BROKERING, FIPA_CONTRACT_NET, FIPA_DUTCH_AUCTION, FIPA_ENGLISH_AUCTION, FIPA_ITERATED_CONTRACT_NET, FIPA_PROPOSE, FIPA_QUERY, FIPA_RECRUITING, FIPA_REQUEST, FIPA_REQUEST_WHEN, FIPA_SUBSCRIBE, ITERATED_FIPA_REQUEST| Constructor and Description |
|---|
SubscriptionResponder(Agent a,
MessageTemplate mt)
Construct a SubscriptionResponder behaviour that handles subscription messages matching a given template.
|
SubscriptionResponder(Agent a,
MessageTemplate mt,
SubscriptionResponder.SubscriptionManager sm)
Construct a SubscriptionResponder behaviour that handles subscription messages matching a given template and
notifies a given SubscriptionManager about subscription/un-subscription events.
|
SubscriptionResponder(Agent a,
MessageTemplate mt,
SubscriptionResponder.SubscriptionManager sm,
DataStore store)
Construct a SubscriptionResponder behaviour that handles subscription messages matching a given template,
notifies a given SubscriptionManager about subscription/un-subscription events and uses a given DataStore.
|
| Modifier and Type | Method and Description |
|---|---|
static MessageTemplate |
createMessageTemplate(int perf)
This static method can be used
to set the proper message Template (based on the performative of the
subscription message) into the constructor of this behaviour.
|
SubscriptionResponder.Subscription |
createSubscription(ACLMessage subsMsg)
Utility method to correctly create a new
Subscription object
managed by this SubscriptionResponder |
SubscriptionResponder.Subscription |
getSubscription(ACLMessage msg)
Utility method to correctly retrieve the
Subscription object that is related to the conversation
message msg belongs to. |
SubscriptionResponder.Subscription |
getSubscription(java.lang.String convId)
Utility method to correctly retrieve the
Subscription object that is related a given conversation. |
java.util.Vector |
getSubscriptions()
Utility method that retrieves all Subscription-s managed by this
SubscriptionResponder |
java.util.Vector |
getSubscriptions(AID subscriber)
Utility method that retrieves all Subscription-s done by a given agent
|
protected ACLMessage |
handleCancel(ACLMessage cancel)
This method is called when a CANCEL message is received for a previous subscription.
|
protected ACLMessage |
handleSubscription(ACLMessage subscription)
This method is called when a subscription
message is received that matches the message template
specified in the constructor.
|
protected ACLMessage |
prepareResponse(ACLMessage subscription)
Deprecated.
Use handleSubscription() instead
|
void |
registerHandleCancel(Behaviour b)
This method allows to register a user defined
Behaviour
in the HANDLE_CANCEL state. |
void |
registerHandleSubscription(Behaviour b)
This method allows to register a user defined
Behaviour
in the HANDLE_SUBSCRIPTION state. |
void |
registerPrepareResponse(Behaviour b)
Deprecated.
Use registerHandleSubscription() instead.
|
void |
reset()
Reset this behaviour
|
void |
reset(MessageTemplate mt)
This method resets the protocol and allows to change the
MessageTemplate
that defines what messages this SubscriptionResponder
will react to. |
checkTermination, deregisterDefaultTransition, deregisterState, deregisterTransition, forceTransitionTo, getChildren, getCurrent, getLastExitValue, getName, getPrevious, getState, handleInconsistentFSM, handleStateEntered, hasDefaultTransition, onEnd, registerDefaultTransition, registerDefaultTransition, registerFirstState, registerLastState, registerState, registerTransition, registerTransition, resetStates, scheduleFirst, scheduleNext, stringifyTransitionTableaction, done, resetChildren, setAgentblock, block, getAgent, getBehaviourName, getDataStore, getParent, isRunnable, onStart, restart, root, setBehaviourName, setDataStorepublic final java.lang.String SUBSCRIPTION_KEY
public final java.lang.String CANCEL_KEY
public final java.lang.String RESPONSE_KEY
protected SubscriptionResponder.SubscriptionManager mySubscriptionManager
SubscriptionManager used by this
SubscriptionResponder to register subscriptionspublic SubscriptionResponder(Agent a, MessageTemplate mt)
public SubscriptionResponder(Agent a, MessageTemplate mt, SubscriptionResponder.SubscriptionManager sm)
public SubscriptionResponder(Agent a, MessageTemplate mt, SubscriptionResponder.SubscriptionManager sm, DataStore store)
a - is the reference to the Agent performing this behaviour.mt - is the MessageTemplate that must be used to match
subscription messages sent by the initiators. Take care that
if mt is null every message is consumed by this protocol.sm - The SubscriptionManager object that is notified about subscription/un-subscription eventsstore - the DataStore that will be used by protocolpublic static MessageTemplate createMessageTemplate(int perf)
perf - The performative of the subscription messagepublic void reset()
reset in class FSMBehaviourpublic void reset(MessageTemplate mt)
MessageTemplate
that defines what messages this SubscriptionResponder
will react to.protected ACLMessage handleSubscription(ACLMessage subscription) throws NotUnderstoodException, RefuseException
Subscription
object, stores it internally and notify the SubscriptionManager
used by this responder if any. Then it returns null which has
the effect of sending no response. Programmers in general do not need
to override this method. In case they need to manage Subscription objects in an application specific
way they should rather use a SubscriptionManager with the register() method properly implemented.
However they could override it in case they need to react to the reception of a
subscription message in a different way, e.g. by sending back an AGREE message.subscription - the received messageagree, refuse, not-understood or null if no response must be sent back.NotUnderstoodExceptionRefuseExceptionprotected ACLMessage prepareResponse(ACLMessage subscription) throws NotUnderstoodException, RefuseException
protected ACLMessage handleCancel(ACLMessage cancel) throws FailureException
Subscription
object the received cancel message refers to, notifies the
SubscriptionManager used by this responder if any and remove the Subscription from its internal structures.
Then it returns null which has the effect of sending no response.
Programmers in general do not need
to override this method. In case they need to manage Subscription objects in an application specific
way they should rather use a SubscriptionManager with the deregister() method properly implemented.
However they could override it in case they need to react to the reception of a
cancel message in a different way, e.g. by sending back an INFORM.cancel - the received CANCEL messageinform and failure or null if no response must be sent back.FailureExceptionpublic void registerHandleSubscription(Behaviour b)
Behaviour
in the HANDLE_SUBSCRIPTION state.
This behaviour overrides the homonymous method.
This method also sets the
data store of the registered Behaviour to the
DataStore of this current behaviour.
It is responsibility of the registered behaviour to put the
response (if any) to be sent back into the datastore at the
RESPONSE_KEY key.
The incoming subscription message can be retrieved from the
datastore at the SUBSCRIPTION_KEY keyb - the Behaviour that will handle this statepublic void registerPrepareResponse(Behaviour b)
public void registerHandleCancel(Behaviour b)
Behaviour
in the HANDLE_CANCEL state.
This behaviour overrides the homonymous method.
This method also sets the
data store of the registered Behaviour to the
DataStore of this current behaviour.
It is responsibility of the registered behaviour to put the
response (if any) to be sent back into the datastore at the
RESPONSE_KEY key.
The incoming CANCEL message can be retrieved from the
datastore at the CANCEL_KEY keyb - the Behaviour that will handle this statepublic SubscriptionResponder.Subscription createSubscription(ACLMessage subsMsg)
Subscription object
managed by this SubscriptionResponderpublic SubscriptionResponder.Subscription getSubscription(ACLMessage msg)
Subscription object that is related to the conversation
message msg belongs to.msg - The message whose conversation-id indicates the conversationSubscription object related to the conversation the given message belongs topublic SubscriptionResponder.Subscription getSubscription(java.lang.String convId)
Subscription object that is related a given conversation.convId - The id of the conversationSubscription object related to the given conversationpublic java.util.Vector getSubscriptions(AID subscriber)
subscriber - The AID of the agent whose subscriptions must be retrievedVector including all Subscription-s made by the given agentpublic java.util.Vector getSubscriptions()
SubscriptionResponderVector including all Subscription-s managed by this SubscriptionResponder