|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
com.cometway.ak.Agent
com.cometway.ak.ServiceAgent
com.cometway.om.FileObjectManager
public class FileObjectManager
The FileObjectManager manages Props objects and persists them as files, using FilePropsContainers. A Props object must first be created by calling createObject with an ObjectType to get an ObjectID which matches that props Object. The only ObjectType supported in this Manager is the PropsType. Since only Props Objects are stored, using other types will fail. The actual Props object can be fetched by calling getObject with the ObjectID. The ObjectID associated with its props is: new ObjectID(props.getString("type"),props.getString("id")); Props objects can be listed by calling listObjects with an Object which listObjects will use as a queryObject. If this object is null, all ObjectID's will be listed. If this Object is an instanceof ObjectType, then all the ObjectID's of the props objects of this type will be returned. If this Object is an instanceof Pair, then the ObjectID whos props contains a property name that is the String stored in Pair.first() with a value that is equal to the String stored in Pair.second(). Props objects can be removed by calling removeObject with an ObjectID.
All the Props objects managed by this manager is cached in a hashtable called 'allprops' with ObjectID's as keys associated with the Props object. The id property stored in the props object matches its persistent filename as the number after \"prop#\", i.e. filename is \"prop\"+id. This manager is passed a String or File that is the root directory to store all props persistence files in. The props is written to the file as a serialized Hashtable. This hashtable is kept in the FilePropsContainer which keeps the file updated with its hashtable.
Props,
FilePropsContainer,
ObjectID,
TODO:| Field Summary | |
|---|---|
protected java.util.Hashtable |
allprops
|
protected java.lang.Object |
fsSync
|
protected long |
nextID
|
protected java.io.File |
rootdir
|
protected java.util.Hashtable |
types
|
| 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 | |
|---|---|
FileObjectManager()
|
|
| 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. |
protected void |
initialize()
This constructor creates all the directories that doesn't exist. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.util.Hashtable types
protected java.util.Hashtable allprops
protected long nextID
protected java.io.File rootdir
protected java.lang.Object fsSync
| Constructor Detail |
|---|
public FileObjectManager()
| Method Detail |
|---|
public void initProps()
initProps in interface AgentInterfaceinitProps in class Agentpublic void start()
start in interface AgentInterfacestart in class ServiceAgentpublic void stop()
stop in interface AgentInterfacestop in class ServiceAgent
protected void initialize()
throws java.io.IOException
rootdir - This is the File of the directory to store all persistence files
java.io.IOException - This exception is thrown if the root directory is invalid or could not be used.public ObjectID createObject(ObjectType type)
IObjectManagerNote: Currently, only the PropsType is supported.
createObject in interface IObjectManagertype - a reference to an ObjectType representing the type of object to create.
public java.lang.Object getObject(ObjectID id)
IObjectManager
getObject in interface IObjectManagerid - a reference to an ObjectID representing a valid object in the object manager.
public java.util.Vector listObjects(java.lang.Object objectQuery)
IObjectManager| 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. |
listObjects in interface IObjectManagerobjectQuery - any valid object from the list above.
public boolean removeObject(ObjectID id)
IObjectManager
removeObject in interface IObjectManagerid - a reference to an ObjectID representing a valid object in the object manager.
public boolean changeObjectID(ObjectID oldID,
ObjectID newID)
IObjectManager
changeObjectID in interface IObjectManager
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||