org.cougaar.core.blackboard
Class BlackboardClientComponent

java.lang.Object
  extended by org.cougaar.util.GenericStateModelAdapter
      extended by org.cougaar.core.blackboard.BlackboardClientComponent
All Implemented Interfaces:
BlackboardClient, org.cougaar.core.component.Component, org.cougaar.util.GenericStateModel
Direct Known Subclasses:
ComponentPlugin

public abstract class BlackboardClientComponent
extends org.cougaar.util.GenericStateModelAdapter
implements org.cougaar.core.component.Component, BlackboardClient

This component is a standard base class for Components that use the BlackboardService.

Plugins are the most common example of such components.
ComponentPlugin is an extension of this class.

Create a derived class by implementing setupSubscriptions() and execute().

Note that both "precycle()" and "cycle()" will be run by the scheduler. This means that the scheduling order in relation to other scheduled Components may be *random* (i.e. this BlackboardClientComponent might load first but be precycled last!). In general a Component should not make assumptions about the load or schedule ordering.

See Also:
ComponentPlugin

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.cougaar.core.blackboard.BlackboardClient
BlackboardClient.Local
 
Field Summary
protected  MessageAddress agentId
           
protected  AgentIdentificationService agentIdentificationService
           
protected  AlarmService alarmService
           
protected  BlackboardService blackboard
           
protected  java.lang.String blackboardClientName
           
 
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
BlackboardClientComponent()
           
 
Method Summary
 long currentTimeMillis()
          Get the current execution time (bug 2515).
protected  void cycle()
           
protected abstract  void execute()
          Called every time this component is scheduled to run.
protected  MessageAddress getAgentIdentifier()
          Get the local agent's address.
protected  AlarmService getAlarmService()
          Get the alarm service, for subclass use.
protected  org.cougaar.core.component.BindingSite getBindingSite()
          Get the binding site, for subclass use.
 java.lang.String getBlackboardClientName()
          Return a name for this BlackboardClient.
protected  BlackboardService getBlackboardService()
          Get the blackboard service, for subclass use.
protected  MessageAddress getMessageAddress()
          Deprecated. Use getAgentIdentifier()
 java.lang.Object getParameter()
           
 java.util.Collection getParameters()
          Get any Component parameters passed by the instantiator.
protected  org.cougaar.core.component.ServiceBroker getServiceBroker()
          Get the ServiceBroker, for subclass use.
 void halt()
           
 void load()
           
protected  void precycle()
           
protected  void requestCycle()
           
 void resume()
           
 void setAgentIdentificationService(AgentIdentificationService ais)
           
 void setAlarmService(AlarmService s)
           
 void setBindingSite(org.cougaar.core.component.BindingSite bs)
          Binding site is set by reflection at creation-time.
 void setBlackboardService(BlackboardService bs)
           
 void setParameter(java.lang.Object param)
          Called just after construction (via introspection) by the loader if a non-null parameter Object was specified by the ComponentDescription.
 void setSchedulerService(SchedulerService ss)
           
 void setServiceBroker(org.cougaar.core.component.ServiceBroker sb)
          ServiceBroker is set by reflection at creation-time.
 void setSuicideService(SuicideService ss)
           
protected abstract  void setupSubscriptions()
          Called once after initialization, as a pre-execute().
protected  boolean shouldExecute()
           
 void start()
           
 void stop()
           
 void suspend()
           
 java.lang.String toString()
           
 void unload()
           
protected  boolean wasAwakened()
          True IFF were we awakened explicitly (i.e. we were asked to run even if no subscription activity has happened).
 
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, initialize
 

Field Detail

agentId

protected MessageAddress agentId

blackboard

protected BlackboardService blackboard

alarmService

protected AlarmService alarmService

agentIdentificationService

protected AgentIdentificationService agentIdentificationService

blackboardClientName

protected java.lang.String blackboardClientName
Constructor Detail

BlackboardClientComponent

public BlackboardClientComponent()
Method Detail

setParameter

public void setParameter(java.lang.Object param)
Called just after construction (via introspection) by the loader if a non-null parameter Object was specified by the ComponentDescription.


getParameter

public java.lang.Object getParameter()
Returns:
the parameter set by setParameter(java.lang.Object)

getParameters

public java.util.Collection getParameters()
Get any Component parameters passed by the instantiator.

Returns:
The parameter specified if it was a collection, a collection with one element (the parameter) if it wasn't a collection, or an empty collection if the parameter wasn't specified.

setBindingSite

public void setBindingSite(org.cougaar.core.component.BindingSite bs)
Binding site is set by reflection at creation-time.


getBindingSite

protected org.cougaar.core.component.BindingSite getBindingSite()
Get the binding site, for subclass use.


setServiceBroker

public void setServiceBroker(org.cougaar.core.component.ServiceBroker sb)
ServiceBroker is set by reflection at creation-time.


getServiceBroker

protected org.cougaar.core.component.ServiceBroker getServiceBroker()
Get the ServiceBroker, for subclass use.


setSchedulerService

public final void setSchedulerService(SchedulerService ss)

setBlackboardService

public final void setBlackboardService(BlackboardService bs)

setAlarmService

public final void setAlarmService(AlarmService s)

setAgentIdentificationService

public final void setAgentIdentificationService(AgentIdentificationService ais)

setSuicideService

public void setSuicideService(SuicideService ss)

getBlackboardService

protected BlackboardService getBlackboardService()
Get the blackboard service, for subclass use.


getAlarmService

protected AlarmService getAlarmService()
Get the alarm service, for subclass use.


requestCycle

protected final void requestCycle()

load

public void load()
Specified by:
load in interface org.cougaar.util.GenericStateModel
Overrides:
load in class org.cougaar.util.GenericStateModelAdapter

start

public void start()
Specified by:
start in interface org.cougaar.util.GenericStateModel
Overrides:
start in class org.cougaar.util.GenericStateModelAdapter

suspend

public void suspend()
Specified by:
suspend in interface org.cougaar.util.GenericStateModel
Overrides:
suspend in class org.cougaar.util.GenericStateModelAdapter

resume

public void resume()
Specified by:
resume in interface org.cougaar.util.GenericStateModel
Overrides:
resume in class org.cougaar.util.GenericStateModelAdapter

stop

public void stop()
Specified by:
stop in interface org.cougaar.util.GenericStateModel
Overrides:
stop in class org.cougaar.util.GenericStateModelAdapter

halt

public void halt()
Specified by:
halt in interface org.cougaar.util.GenericStateModel
Overrides:
halt in class org.cougaar.util.GenericStateModelAdapter

unload

public void unload()
Specified by:
unload in interface org.cougaar.util.GenericStateModel
Overrides:
unload in class org.cougaar.util.GenericStateModelAdapter

precycle

protected void precycle()

cycle

protected void cycle()

shouldExecute

protected boolean shouldExecute()

getAgentIdentifier

protected MessageAddress getAgentIdentifier()
Get the local agent's address. Also consider adding a "getMessageAddress()" method backed by the NodeIdentificationService.


getMessageAddress

protected MessageAddress getMessageAddress()
Deprecated. Use getAgentIdentifier()


setupSubscriptions

protected abstract void setupSubscriptions()
Called once after initialization, as a pre-execute().


execute

protected abstract void execute()
Called every time this component is scheduled to run.


wasAwakened

protected final boolean wasAwakened()
True IFF were we awakened explicitly (i.e. we were asked to run even if no subscription activity has happened). The value is valid only within the scope of the cycle() method.


getBlackboardClientName

public java.lang.String getBlackboardClientName()
Description copied from interface: BlackboardClient
Return a name for this BlackboardClient. All clients in an agent should have distinct names.

Specified by:
getBlackboardClientName in interface BlackboardClient

currentTimeMillis

public long currentTimeMillis()
Description copied from interface: BlackboardClient
Get the current execution time (bug 2515).

Specified by:
currentTimeMillis in interface BlackboardClient

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object