org.cougaar.pizza.plugin
Class InvitePlugin

java.lang.Object
  extended byorg.cougaar.util.GenericStateModelAdapter
      extended byorg.cougaar.core.blackboard.BlackboardClientComponent
          extended byorg.cougaar.core.plugin.ComponentPlugin
              extended byorg.cougaar.pizza.plugin.InvitePlugin
All Implemented Interfaces:
org.cougaar.core.blackboard.BlackboardClient, org.cougaar.core.component.Component, org.cougaar.util.GenericStateModel, org.cougaar.core.plugin.PluginBase

public class InvitePlugin
extends org.cougaar.core.plugin.ComponentPlugin

Sends a simple relay invitation to all "FriendsOfMark" (members of the community), whose responses are automatically collected in the PizzaPreferences object.

Waits for a set amount of time, WAIT_FOR_RSVP_DURATION, until it publishes the pizza preference list to the blackboard. While it's waiting, replies come back from invitees and update the PizzaPreferences object in memory.

It must wait because people may take a while to join the FriendsOfMark community, and the PlaceOrderPlugin will place the orders as soon as the PizzaPreferences object is published.

An alternate way to do this instead of an alarm would be to tell this Plugin in advance how many people to expect, or allow it to publishChange the PizzaPreferences object.

See Also:
PizzaPreferences, PlaceOrderPlugin

Nested Class Summary
 
Nested classes inherited from class org.cougaar.core.blackboard.BlackboardClient
org.cougaar.core.blackboard.BlackboardClient.Local
 
Field Summary
protected  PizzaPreferences pizzaPreferences
          my list of pizza preferences generated from RSVPs
protected  boolean publishedPreferences
          Have we published preferences
protected  long waitForRSVPDuration
          How long to wait before publish preferences
 
Fields inherited from class org.cougaar.core.blackboard.BlackboardClientComponent
agentId, agentIdentificationService, alarmService, blackboard, blackboardClientName
 
Fields inherited from interface org.cougaar.core.plugin.PluginBase
INSERTION_POINT
 
Fields inherited from interface org.cougaar.util.GenericStateModel
ACTIVE, IDLE, LOADED, UNINITIALIZED, UNLOADED
 
Fields inherited from interface org.cougaar.core.blackboard.BlackboardClient
current
 
Constructor Summary
InvitePlugin()
           
 
Method Summary
protected  void checkTimer()
          If the timer has expired, assume all the members of the community have joined, gotten the ABA targeted RSVP Relay, and replied.
protected  void execute()
          Onc we have the self org, publish the invite RSVPRelay if we haven't yet.
protected  org.cougaar.planning.ldm.asset.Entity getSelfEntity()
          Returns the Entity representing the agent.
protected  long getTimerExpirationTime()
          When will (has) the timer expire(d)?
protected  long getWaitParameter()
          Looks for argument to plugin like: "WAIT_FOR_RSVP_DURATION:60000".
protected  void publishRelay()
          Create a PizzaPreferences object to collect local results, and publish my RSVP relay inviting people to the party.
 void setLoggingService(org.cougaar.core.service.LoggingService log)
           
 void setParameter(java.lang.Object o)
          "setParameter" is only called if a plugin has parameters
 void setUIDService(org.cougaar.core.service.UIDService uids)
           
protected  void setupSubscriptions()
          We have one subscription, to the relays (the invitation) we produce.
protected  void startTimer(long delay)
          Schedule a update wakeup after some interval of time
protected  boolean timerExpired()
          Test if the timer has expired.
 
Methods inherited from class org.cougaar.core.plugin.ComponentPlugin
getConfigFinder
 
Methods inherited from class org.cougaar.core.blackboard.BlackboardClientComponent
currentTimeMillis, cycle, getAgentIdentifier, getAlarmService, getBindingSite, getBlackboardClientName, getBlackboardService, getMessageAddress, getParameter, getParameters, getServiceBroker, halt, load, precycle, requestCycle, resume, setAgentIdentificationService, setAlarmService, setBindingSite, setBlackboardService, setSchedulerService, setServiceBroker, setSuicideService, shouldExecute, start, stop, suspend, toString, unload, wasAwakened
 
Methods inherited from class org.cougaar.util.GenericStateModelAdapter
getModelState, initialize, transitState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.cougaar.util.GenericStateModel
getModelState, halt, initialize, load, resume, start, stop, suspend, unload
 

Field Detail

pizzaPreferences

protected PizzaPreferences pizzaPreferences
my list of pizza preferences generated from RSVPs


waitForRSVPDuration

protected long waitForRSVPDuration
How long to wait before publish preferences


publishedPreferences

protected boolean publishedPreferences
Have we published preferences

Constructor Detail

InvitePlugin

public InvitePlugin()
Method Detail

setParameter

public void setParameter(java.lang.Object o)
"setParameter" is only called if a plugin has parameters


setLoggingService

public void setLoggingService(org.cougaar.core.service.LoggingService log)

setUIDService

public void setUIDService(org.cougaar.core.service.UIDService uids)

getWaitParameter

protected long getWaitParameter()
Looks for argument to plugin like: "WAIT_FOR_RSVP_DURATION:60000".

 

For example :

WAIT_FOR_RSVP_DURATION:60000

Returns:
millis to wait

setupSubscriptions

protected void setupSubscriptions()
We have one subscription, to the relays (the invitation) we produce.

Here we also publish the pizza preferences. Initially it only holds the preference for Alice, the inviting agent.

Sets a timer that fires when we have waited long enough for responses to return.


execute

protected void execute()
Onc we have the self org, publish the invite RSVPRelay if we haven't yet. When the timer expires, assume all replies have come in, and publish the collected PizzaPreferences object for the PlaceOrderPlugin.


publishRelay

protected void publishRelay()
Create a PizzaPreferences object to collect local results, and publish my RSVP relay inviting people to the party. The relay itself will update the PizzaPreferences object as replies come in.


getSelfEntity

protected org.cougaar.planning.ldm.asset.Entity getSelfEntity()
Returns the Entity representing the agent. Checks the entity subscription and returns the first element. In this example, there should be only one self entity.

Returns:
local Entity, null if none yet

checkTimer

protected void checkTimer()
If the timer has expired, assume all the members of the community have joined, gotten the ABA targeted RSVP Relay, and replied. So publish the PizzaPreferences object, so the PlaceOrderPlugin can begin.


startTimer

protected void startTimer(long delay)
Schedule a update wakeup after some interval of time

Parameters:
delay - how long to delay before the timer expires.

timerExpired

protected boolean timerExpired()
Test if the timer has expired.

Returns:
false if the timer is not running or has not yet expired

getTimerExpirationTime

protected long getTimerExpirationTime()
When will (has) the timer expire(d)?