Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

sajas.proto
Class SubscriptionResponder
java.lang.Object
  sajas.core.behaviours.Behaviour
      sajas.core.behaviours.CompositeBehaviour
          sajas.core.behaviours.SerialBehaviour
              sajas.core.behaviours.FSMBehaviour
                  sajas.proto.SubscriptionResponder
All Implemented Interfaces:
jade.domain.FIPANames.InteractionProtocol, jade.util.leap.Serializable, Serializable

public class SubscriptionResponder
extends FSMBehaviour
implements jade.domain.FIPANames.InteractionProtocol
Note: this class has been re-implemented to redirect the use of the agent, behaviour and protocol classes to SAJaS versions.
Author:
hlc
See Also:
jade.proto.SubscriptionResponder

Nested Class Summary
static class
SubscriptionResponder.Subscription
          Inner calss Subscription
static interface
SubscriptionResponder.SubscriptionManager
          Inner interface SubscriptionManager.
Nested classes/interfaces inherited from class sajas.core.behaviours.Behaviour
Behaviour.RunnableChangedEvent
Field Summary
String
CANCEL_KEY
          key to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator to cancel a subscription.
mySubscriptionManager
          The SubscriptionManager used by this SubscriptionResponder to register subscriptions
String
RESPONSE_KEY
          key to retrieve from the DataStore of the behaviour the ACLMessage object sent as a response to the initiator.
String
SUBSCRIPTION_KEY
          key to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator as a subscription.
Fields inherited from class sajas.core.behaviours.FSMBehaviour
currentName, lastStates
Fields inherited from class sajas.core.behaviours.CompositeBehaviour
currentExecuted
Fields inherited from class sajas.core.behaviours.Behaviour
myAgent, myEvent, NOTIFY_DOWN, NOTIFY_UP, parent, STATE_BLOCKED, STATE_READY, STATE_RUNNING
Fields inherited from interface jade.domain.FIPANames.InteractionProtocol
FIPA_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 Summary
SubscriptionResponder(Agent a, jade.lang.acl.MessageTemplate mt)
          Construct a SubscriptionResponder behaviour that handles subscription messages matching a given template.
SubscriptionResponder(Agent a, jade.lang.acl.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, jade.lang.acl.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.
Method Summary
static jade.lang.acl.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.
createSubscription(jade.lang.acl.ACLMessage subsMsg)
          Utility method to correctly create a new Subscription object managed by this SubscriptionResponder
getSubscription(jade.lang.acl.ACLMessage msg)
          Utility method to correctly retrieve the Subscription object that is related to the conversation message msg belongs to.
getSubscription(String convId)
          Utility method to correctly retrieve the Subscription object that is related a given conversation.
Vector
getSubscriptions()
          Utility method that retrieves all Subscription-s managed by this SubscriptionResponder
Vector
getSubscriptions(AID subscriber)
          Utility method that retrieves all Subscription-s done by a given agent
protected jade.lang.acl.ACLMessage
handleCancel(jade.lang.acl.ACLMessage cancel)
          This method is called when a CANCEL message is received for a previous subscription.
protected jade.lang.acl.ACLMessage
handleSubscription(jade.lang.acl.ACLMessage subscription)
          This method is called when a subscription message is received that matches the message template specified in the constructor.
protected jade.lang.acl.ACLMessage
prepareResponse(jade.lang.acl.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(jade.lang.acl.MessageTemplate mt)
          This method resets the protocol and allows to change the MessageTemplate that defines what messages this SubscriptionResponder will react to.
Methods inherited from class sajas.core.behaviours.FSMBehaviour
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, stringifyTransitionTable
Methods inherited from class sajas.core.behaviours.SerialBehaviour
handle
Methods inherited from class sajas.core.behaviours.CompositeBehaviour
action, done, handleBlockEvent, handleRestartEvent, registerAsChild, resetChildren, setAgent
Methods inherited from class sajas.core.behaviours.Behaviour
actionWrapper, block, block, getAgent, getBehaviourName, getDataStore, getExecutionState, getParent, getRestartCounter, isRunnable, onStart, restart, root, setBehaviourName, setDataStore, setExecutionState
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
CANCEL_KEY
public final String CANCEL_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator to cancel a subscription.

mySubscriptionManager
protected SubscriptionResponder.SubscriptionManager mySubscriptionManager
The SubscriptionManager used by this SubscriptionResponder to register subscriptions

RESPONSE_KEY
public final String RESPONSE_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent as a response to the initiator.

SUBSCRIPTION_KEY
public final String SUBSCRIPTION_KEY
key to retrieve from the DataStore of the behaviour the ACLMessage object sent by the initiator as a subscription.
Constructor Detail
SubscriptionResponder
public SubscriptionResponder(Agent a,
                             jade.lang.acl.MessageTemplate mt)
Construct a SubscriptionResponder behaviour that handles subscription messages matching a given template.
See Also:
SubscriptionResponder(Agent,MessageTemplate,SubscriptionResponder.SubscriptionManager,DataStore)

SubscriptionResponder
public SubscriptionResponder(Agent a,
                             jade.lang.acl.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.
See Also:
SubscriptionResponder(Agent,MessageTemplate,SubscriptionResponder.SubscriptionManager,DataStore)

SubscriptionResponder
public SubscriptionResponder(Agent a,
                             jade.lang.acl.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.
Parameters:
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 events
store - the DataStore that will be used by protocol
Method Detail
createMessageTemplate
public static jade.lang.acl.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.
Parameters:
perf - The performative of the subscription message

reset
public void reset()
Reset this behaviour
Overrides:
reset in class FSMBehaviour

reset
public void reset(jade.lang.acl.MessageTemplate mt)
This method resets the protocol and allows to change the MessageTemplate that defines what messages this SubscriptionResponder will react to.

handleSubscription
protected jade.lang.acl.ACLMessage handleSubscription(jade.lang.acl.ACLMessage subscription)
                                               throws jade.domain.FIPAAgentManagement.NotUnderstoodException,
                                                      jade.domain.FIPAAgentManagement.RefuseException
This method is called when a subscription message is received that matches the message template specified in the constructor. The default implementation creates an new 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.
Parameters:
subscription - the received message
Returns:
the ACLMessage to be sent as a response: typically one of agree, refuse, not-understood or null if no response must be sent back.
Throws:
jade.domain.FIPAAgentManagement.NotUnderstoodException
jade.domain.FIPAAgentManagement.RefuseException

prepareResponse
protected jade.lang.acl.ACLMessage prepareResponse(jade.lang.acl.ACLMessage subscription)
                                            throws jade.domain.FIPAAgentManagement.NotUnderstoodException,
                                                   jade.domain.FIPAAgentManagement.RefuseException
Deprecated. Use handleSubscription() instead
Throws:
jade.domain.FIPAAgentManagement.NotUnderstoodException
jade.domain.FIPAAgentManagement.RefuseException

handleCancel
protected jade.lang.acl.ACLMessage handleCancel(jade.lang.acl.ACLMessage cancel)
                                         throws jade.domain.FIPAAgentManagement.FailureException
This method is called when a CANCEL message is received for a previous subscription. The default implementation retrieves the 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.
Parameters:
cancel - the received CANCEL message
Returns:
the ACLMessage to be sent as a response to the cancel operation: typically one of inform and failure or null if no response must be sent back.
Throws:
jade.domain.FIPAAgentManagement.FailureException

registerHandleSubscription
public void registerHandleSubscription(Behaviour b)
This method allows to register a user defined 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 key
Parameters:
b - the Behaviour that will handle this state

registerPrepareResponse
public void registerPrepareResponse(Behaviour b)
Deprecated. Use registerHandleSubscription() instead.

registerHandleCancel
public void registerHandleCancel(Behaviour b)
This method allows to register a user defined 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 key
Parameters:
b - the Behaviour that will handle this state

createSubscription
public SubscriptionResponder.Subscription createSubscription(jade.lang.acl.ACLMessage subsMsg)
Utility method to correctly create a new Subscription object managed by this SubscriptionResponder

getSubscription
public SubscriptionResponder.Subscription getSubscription(jade.lang.acl.ACLMessage msg)
Utility method to correctly retrieve the Subscription object that is related to the conversation message msg belongs to.
Parameters:
msg - The message whose conversation-id indicates the conversation
Returns:
the Subscription object related to the conversation the given message belongs to

getSubscription
public SubscriptionResponder.Subscription getSubscription(String convId)
Utility method to correctly retrieve the Subscription object that is related a given conversation.
Parameters:
convId - The id of the conversation
Returns:
the Subscription object related to the given conversation

getSubscriptions
public Vector getSubscriptions(AID subscriber)
Utility method that retrieves all Subscription-s done by a given agent
Parameters:
subscriber - The AID of the agent whose subscriptions must be retrieved
Returns:
A Vector including all Subscription-s made by the given agent

getSubscriptions
public Vector getSubscriptions()
Utility method that retrieves all Subscription-s managed by this SubscriptionResponder
Returns:
A Vector including all Subscription-s managed by this SubscriptionResponder

Overview  Package   Class  Tree  Deprecated  Index  Help 
PREV CLASS   NEXT CLASS FRAMES    NO FRAMES    All Classes
SUMMARY: NESTED | FIELD | CONSTR | METHOD DETAIL: FIELD | CONSTR | METHOD

Java API documentation generated with DocFlex/Doclet 1.6.1 using JavadocPro template set.
DocFlex/Doclet is both a multi-format Javadoc doclet and a free edition of DocFlex/Javadoc, which is a template-driven programming tool for rapid development of any Javadoc-based Java API documentation generators (i.e. doclets). If you need to customize your Javadoc without writing a full-blown doclet from scratch, DocFlex/Javadoc may be the only tool able to help you! Find out more at www.docflex.com