unsw.cse.mica.blackboard
Class DefaultBlackboard

java.lang.Object
  extended by unsw.cse.mica.blackboard.DefaultBlackboard
All Implemented Interfaces:
Blackboard, BlackboardActions, BlackboardMessageSender, MicaConstants
Direct Known Subclasses:
SimpleBlackboard, SQLBlackboard

public abstract class DefaultBlackboard
extends java.lang.Object
implements Blackboard, BlackboardMessageSender, MicaConstants

An abstract class implementing much of the basic functionality of a blackboard This functionality includes support for:

Author:
jhw
See Also:
SimpleBlackboard, SQLBlackboard

Field Summary
 
Fields inherited from interface unsw.cse.mica.util.MicaConstants
DEFAULT_DB_PATH, DEFAULT_HOST, DEFAULT_MICA_HOME, DEFAULT_PERSISTENCE, DEFAULT_PERSISTENT, DEFAULT_PORT, DEFAULT_TYPE_PATH, INTERNAL_SLOT_NAMES, PARAM_DB_PATH, PARAM_DEBUG, PARAM_HOST, PARAM_MICA_HOME, PARAM_PERSISTENT, PARAM_PORT, PARAM_TYPE_PATH, PERSISTENCE_CONNECTED, PERSISTENCE_PERMANENT, PERSISTENCE_TRANSIENT, PERSISTENCES, RESULT_ERROR, RESULT_NOSUCHAGENT, RESULT_NOSUCHMOB, RESULT_SUCCESS, SLOT_CREATIONTIME, SLOT_CREATOR, SLOT_DELETER, SLOT_DELETIONTIME, SLOT_MODIFICATIONTIME, SLOT_MODIFIER, UNKNOWN_AGENT
 
Constructor Summary
DefaultBlackboard()
           
 
Method Summary
 java.lang.String connect(java.lang.String proposedName)
          The connect message should be the first message sent once the agent connects to the Blackboard.
 int countAgentRegistrations(java.lang.String agent)
           
 java.lang.String disconnect(java.lang.String agentName)
          Disconnect the agent from the Blackboard
 java.lang.String[] getAgentNames()
           
 java.lang.String[] getAgentRegistrations(java.lang.String agent)
           
 java.lang.String getNextPermanentID()
          Persistent mobs are named 0,1,2,...
 java.lang.String getNextTransientID()
          Transient mobs are named -1,-2,-3,...
 BlackboardTransport getTransport()
          Get the corresponding transport for this blackboard.
 TypeManager getTypeManager()
          Acccessor methods for debugging & XMLOverTCPBlackboard
 void init(MicaProperties args)
          Initialise the blackboard.
 java.lang.String register(java.lang.String agentName, java.lang.String mobType)
          Register the agent for notification of blackboard events involving a particular mobType.
 void sendDeletedMob(java.lang.String agentName, Mob mob)
          This method is called by the QueuedMessageSender.
 void sendNewMob(java.lang.String agentName, Mob mob)
          This method is called by the QueuedMessageSender.
 void sendReplacedMob(java.lang.String agentName, Mob oldMob, Mob newMob)
          This method is called by the QueuedMessageSender.
 void sendTypeManagerChanged(java.lang.String agentName)
          This method is called by the QueuedMessageSender.
 void setTransport(BlackboardTransport transport)
          set the transport for this blackboard.
 void terminate()
          Ask a blackboard to shut down
 java.lang.String unregister(java.lang.String agentName, java.lang.String mobType)
          Forget that we were interested in this frame type.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface unsw.cse.mica.blackboard.BlackboardActions
deleteMob, mobSearch, readMob, replaceMob, writeMob
 

Constructor Detail

DefaultBlackboard

public DefaultBlackboard()
Method Detail

init

public void init(MicaProperties args)
          throws MicaException
Initialise the blackboard. The type manager is created as a LocalTypeManager, with values read from a directory specified by parameters whose key is the value of MicaConstants.PARAM_MICA_HOME and MicaConstants.PARAM_TYPE_PATH.

Specified by:
init in interface Blackboard
Parameters:
args - the parameters used for initialisation
Throws:
MicaException
See Also:
LocalTypeManager.loadTypesDirectory(unsw.cse.mica.util.MicaProperties)

getNextTransientID

public java.lang.String getNextTransientID()
Transient mobs are named -1,-2,-3,...

Returns:
the next transient mob name

getNextPermanentID

public java.lang.String getNextPermanentID()
Persistent mobs are named 0,1,2,...

Returns:
the next transient mob name

getTransport

public BlackboardTransport getTransport()
Description copied from interface: Blackboard
Get the corresponding transport for this blackboard.

Specified by:
getTransport in interface Blackboard
Returns:
the blackboard's transport

setTransport

public void setTransport(BlackboardTransport transport)
Description copied from interface: Blackboard
set the transport for this blackboard.

Specified by:
setTransport in interface Blackboard
Parameters:
transport - the transport which this blackboard should use.

getTypeManager

public TypeManager getTypeManager()
Acccessor methods for debugging & XMLOverTCPBlackboard

Specified by:
getTypeManager in interface BlackboardActions
Returns:
the blackboard's type manager (which should never be null, although it could initially be empty)

getAgentNames

public java.lang.String[] getAgentNames()

countAgentRegistrations

public int countAgentRegistrations(java.lang.String agent)

getAgentRegistrations

public java.lang.String[] getAgentRegistrations(java.lang.String agent)

terminate

public void terminate()
               throws MicaException
Description copied from interface: Blackboard
Ask a blackboard to shut down

Specified by:
terminate in interface Blackboard
Throws:
MicaException

connect

public java.lang.String connect(java.lang.String proposedName)
Description copied from interface: BlackboardActions
The connect message should be the first message sent once the agent connects to the Blackboard.

Specified by:
connect in interface BlackboardActions
Parameters:
proposedName - The agent name proposed by the agent.
Returns:
The actual agent name (usually the requested name with a suffix) or MicaConstants.RESULT_ERROR if an error occurred

disconnect

public java.lang.String disconnect(java.lang.String agentName)
Description copied from interface: BlackboardActions
Disconnect the agent from the Blackboard

Specified by:
disconnect in interface BlackboardActions
Parameters:
agentName - the name of the agent that is disconnecting
Returns:
MicaConstants.RESULT_SUCCESS, MicaConstants.RESULT_NOSUCHAGENT or MicaConstants.RESULT_ERROR

register

public java.lang.String register(java.lang.String agentName,
                                 java.lang.String mobType)
Description copied from interface: BlackboardActions
Register the agent for notification of blackboard events involving a particular mobType. Once registered, the agent will be notified whenever changes are made

Specified by:
register in interface BlackboardActions
Parameters:
agentName - the agent that wants to register
mobType - The mob type we are interested in listening to.
Returns:
MicaConstants.RESULT_SUCCESS, MicaConstants.RESULT_NOSUCHAGENT or MicaConstants.RESULT_ERROR

unregister

public java.lang.String unregister(java.lang.String agentName,
                                   java.lang.String mobType)
Description copied from interface: BlackboardActions
Forget that we were interested in this frame type.

Specified by:
unregister in interface BlackboardActions
Returns:
MicaConstants.RESULT_SUCCESS, MicaConstants.RESULT_NOSUCHAGENT or MicaConstants.RESULT_ERROR

sendNewMob

public void sendNewMob(java.lang.String agentName,
                       Mob mob)
This method is called by the QueuedMessageSender. agentName is ignored here as we are still dealing with messages for many agents. However, from this function onwards message are passed per-agent.

Specified by:
sendNewMob in interface BlackboardMessageSender
Parameters:
agentName - the name of the agent for which the message is intended
mob - the mob that has been written to the blackboard

sendDeletedMob

public void sendDeletedMob(java.lang.String agentName,
                           Mob mob)
This method is called by the QueuedMessageSender. agentName is ignored here as we are still dealing with messages for many agents. However, from this function onwards message are passed per-agent.

Specified by:
sendDeletedMob in interface BlackboardMessageSender
Parameters:
agentName - the name of the agent for which the message is intended
mob - the mob that has been deleted from the blackboard

sendReplacedMob

public void sendReplacedMob(java.lang.String agentName,
                            Mob oldMob,
                            Mob newMob)
This method is called by the QueuedMessageSender. agentName is ignored here as we are still dealing with messages for many agents. However, from this function onwards message are passed per-agent.

Specified by:
sendReplacedMob in interface BlackboardMessageSender
Parameters:
agentName - the name of the agent for which the message is intended
oldMob - the old value of the mob
newMob - the new value of the mob

sendTypeManagerChanged

public void sendTypeManagerChanged(java.lang.String agentName)
This method is called by the QueuedMessageSender. agentName is ignored here as we are still dealing with messages for many agents. However, from this function onwards message are passed per-agent.

Specified by:
sendTypeManagerChanged in interface BlackboardMessageSender
Parameters:
agentName - the name of the agent for which the message is intended