com.cometway.om
Class ObjectManager

java.lang.Object
  extended by com.cometway.props.Props
      extended by com.cometway.ak.Agent
          extended by com.cometway.ak.ServiceAgent
              extended by com.cometway.om.ObjectManager
All Implemented Interfaces:
AgentInterface, IObjectManager, HasStateMachineModel

public class ObjectManager
extends ServiceAgent
implements IObjectManager

Reference implementation of a non-persistent IObjectManager as an agent. Normal operations are reported through debug for educational purposes. You should want to add the hide_debug=true property during normal use.


Field Summary
protected  java.util.Hashtable types
           
protected  int uniqueID
           
 
Fields inherited from class com.cometway.ak.Agent
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter
 
Fields inherited from interface com.cometway.om.IObjectManager
LIST_SUPPORTED_TYPES, LIST_TYPES
 
Constructor Summary
ObjectManager()
           
 
Method Summary
 boolean changeObjectID(ObjectID oldID, ObjectID newID)
          This method changes an object's ObjectID.
 ObjectID createObject(ObjectType type)
          Creates a new object in the object manager of the specified object type.
 java.lang.Object getObject(ObjectID id)
          Retrieves the object corresponding to an object ID.
static IObjectManager getObjectManager()
          Returns a reference to the IObjectManager registered as object_manager.
static IObjectManager getObjectManager(java.lang.String serviceName)
          Returns a reference to the IObjectManager registered as the specified service name.
 void initProps()
          Sets the service_name property to object_manager if a value was not provided.
 java.util.Vector listObjects(java.lang.Object objectQuery)
          Returns a Vector of objects designated by the objectQuery parameter.
 boolean removeObject(ObjectID id)
          Deletes the object corresponding to an object ID from the object manager.
 void start()
          Starts and registers the object cache.
 void stop()
          Stops and unregisters the object cache.
 
Methods inherited from class com.cometway.ak.Agent
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning
 
Methods inherited from class com.cometway.props.Props
addListener, append, copy, copyFrom, copyTo, decrementInteger, dump, enableListeners, enumerateKeys, format, getBoolean, getByteArray, getCharacter, getDate, getDate, getDateString, getDouble, getFloat, getHexString, getInteger, getKeys, getLong, getNextKey, getProperty, getProperty, getPropsContainer, getSize, getString, getString, getTokens, getTokens, getTrimmedString, getVector, hasProperty, incrementInteger, insertProps, loadProps, notifyPropsChanged, notifyPropsChangedIgnore, notifyPropsChangedIgnore, parse, propertyMatchesRegEx, readFromFile, regExPropertyMatches, removeAll, removeListener, removeProperty, resumeNotify, saveProps, set, setBoolean, setCharacter, setDefault, setDouble, setFloat, setInteger, setLong, setProperty, setProperty, setProperty, setPropsContainer, suspendNotify, writeToFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

types

protected java.util.Hashtable types

uniqueID

protected int uniqueID
Constructor Detail

ObjectManager

public ObjectManager()
Method Detail

initProps

public void initProps()
Sets the service_name property to object_manager if a value was not provided.

Specified by:
initProps in interface AgentInterface
Overrides:
initProps in class Agent

start

public void start()
Starts and registers the object cache.

Specified by:
start in interface AgentInterface
Overrides:
start in class ServiceAgent

stop

public void stop()
Stops and unregisters the object cache.

Specified by:
stop in interface AgentInterface
Overrides:
stop in class ServiceAgent

changeObjectID

public boolean changeObjectID(ObjectID oldID,
                              ObjectID newID)
This method changes an object's ObjectID.

Specified by:
changeObjectID in interface IObjectManager

createObject

public ObjectID createObject(ObjectType type)
Creates a new object in the object manager of the specified object type.

Note: Currently, only the PropsType is supported.

Specified by:
createObject in interface IObjectManager
Parameters:
type - a reference to an ObjectType representing the type of object to create.
Returns:
a reference to a valid ObjectID if successful; null otherwise.

getObject

public java.lang.Object getObject(ObjectID id)
Retrieves the object corresponding to an object ID.

Specified by:
getObject in interface IObjectManager
Parameters:
id - a reference to an ObjectID representing a valid object in the object manager.
Returns:
a reference to an Object if one was found; null otherwise.

listObjects

public java.util.Vector listObjects(java.lang.Object objectQuery)
Returns a Vector of objects designated by the objectQuery parameter. Valid objects for this parameter are:
IObjectManager.LIST_TYPES Lists object types that already exist.
IObjectManager.LIST_SUPPORTED_TYPES Lists objects which can be passed to createObject.
ObjectType Lists all existing objects of the same ObjectType.
PropsQuery Lists Props based on data from the PropsQuery object.
Note: Some object managers may support additional values for access to non-standard features.

Specified by:
listObjects in interface IObjectManager
Parameters:
objectQuery - any valid object from the list above.
Returns:
a Vector containing Objects based on the query; null if the query wasn't recognized.

removeObject

public boolean removeObject(ObjectID id)
Deletes the object corresponding to an object ID from the object manager.

Specified by:
removeObject in interface IObjectManager
Parameters:
id - a reference to an ObjectID representing a valid object in the object manager.
Returns:
true if the object was successfully deleted; false otherwise.

getObjectManager

public static IObjectManager getObjectManager()
Returns a reference to the IObjectManager registered as object_manager.


getObjectManager

public static IObjectManager getObjectManager(java.lang.String serviceName)
Returns a reference to the IObjectManager registered as the specified service name.