unsw.cse.mica.blackboard
Class SQLBlackboard

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

public class SQLBlackboard
extends DefaultBlackboard

A blackboard with a relational object database backend. This is the most efficient blackboard currently implemented and the one that should be used.

Author:
waleed

Field Summary
static int COLUMN_MOB
           
static int COLUMN_NAME
           
static int COLUMN_PERSISTENCE
           
static int COLUMN_TYPE
           
static java.lang.String[] CREATE_ALIASES
           
static java.lang.String[] CREATE_TABLE
           
static java.lang.String GET_MAX_MOB_ID
           
 java.sql.Connection sqlConnection
           
 
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
SQLBlackboard()
           
 
Method Summary
 java.lang.String deleteMob(java.lang.String agentName, java.lang.String mobName)
          Delete a frame from the blackboard.
 void init(MicaProperties args)
          params used are dbPath and typePath
 java.util.List mobSearch(java.lang.String agentName, java.lang.String query)
          Finds all frame meeting the criteria.
 Mob readMob(java.lang.String agentName, java.lang.String mobName)
          Retrieve a mob by its name.
 java.lang.String replaceMob(java.lang.String agentName, Mob newMob)
          replace a mob on the blackboard.
 boolean running()
           
 void terminate()
          terminate closes the connection and shutsdown the server
 java.lang.String writeMob(java.lang.String agentName, Mob mob)
          Makes a frame on the blackboard.
 
Methods inherited from class unsw.cse.mica.blackboard.DefaultBlackboard
connect, countAgentRegistrations, disconnect, getAgentNames, getAgentRegistrations, getNextPermanentID, getNextTransientID, getTransport, getTypeManager, register, sendDeletedMob, sendNewMob, sendReplacedMob, sendTypeManagerChanged, setTransport, unregister
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN_NAME

public static final int COLUMN_NAME
See Also:
Constant Field Values

COLUMN_TYPE

public static final int COLUMN_TYPE
See Also:
Constant Field Values

COLUMN_PERSISTENCE

public static final int COLUMN_PERSISTENCE
See Also:
Constant Field Values

COLUMN_MOB

public static final int COLUMN_MOB
See Also:
Constant Field Values

CREATE_ALIASES

public static final java.lang.String[] CREATE_ALIASES

CREATE_TABLE

public static final java.lang.String[] CREATE_TABLE

GET_MAX_MOB_ID

public static java.lang.String GET_MAX_MOB_ID

sqlConnection

public java.sql.Connection sqlConnection
Constructor Detail

SQLBlackboard

public SQLBlackboard()
Method Detail

init

public void init(MicaProperties args)
          throws MicaException
params used are dbPath and typePath

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

running

public boolean running()

terminate

public void terminate()
               throws MicaException
terminate closes the connection and shutsdown the server

Specified by:
terminate in interface Blackboard
Overrides:
terminate in class DefaultBlackboard
Throws:
MicaException

readMob

public Mob readMob(java.lang.String agentName,
                   java.lang.String mobName)
Description copied from interface: BlackboardActions
Retrieve a mob by its name.

Parameters:
agentName - the agent requesting the mob
mobName - the name of the desired mob
Returns:
The desired mob, or null if it was not found or an error occurred

writeMob

public java.lang.String writeMob(java.lang.String agentName,
                                 Mob mob)
Description copied from interface: BlackboardActions
Makes a frame on the blackboard.

Parameters:
agentName - the name of the agent that sent the mob
mob - the mob to write to the blackboard
Returns:
The name that has been given to the frame, or MicaConstants.RESULT_ERROR if an error occurred.

deleteMob

public java.lang.String deleteMob(java.lang.String agentName,
                                  java.lang.String mobName)
Description copied from interface: BlackboardActions
Delete a frame from the blackboard.

Parameters:
agentName - the name of the agent that wants the mob deleted
mobName - the name of the mob to delete
Returns:
MicaConstants.RESULT_SUCCESS, MicaConstants.RESULT_NOSUCHMOB or MicaConstants.RESULT_ERROR

replaceMob

public java.lang.String replaceMob(java.lang.String agentName,
                                   Mob newMob)
Description copied from interface: BlackboardActions
replace a mob on the blackboard.

Parameters:
agentName - the name of the agent that wants the mob replaced
newMob - the new value for the mob
Returns:
MicaConstants.RESULT_SUCCESS, MicaConstants.RESULT_NOSUCHMOB or MicaConstants.RESULT_ERROR

mobSearch

public java.util.List mobSearch(java.lang.String agentName,
                                java.lang.String query)
Description copied from interface: BlackboardActions
Finds all frame meeting the criteria.

Returns:
A (possibly empty) list of mobs matching the criteria, or null if an error occurred