org.elkoserver.objdb
Interface ObjDB

All Superinterfaces:
TypeResolver
All Known Implementing Classes:
ObjDBLocal, ObjDBRemote

public interface ObjDB
extends TypeResolver

Asynchronous interface to the object database.


Method Summary
 void addClass(String tag, Class<?> type)
          Inform the object database about a mapping from a JSON object type tag string to a Java class.
 void getObject(String ref, String collectionName, ArgRunnable handler)
          Fetch an object from the object database.
 void putObject(String ref, Encodable obj, String collectionName, boolean requireNew, ArgRunnable handler)
          Store an object into the object database.
 void queryObjects(JSONObject template, String collectionName, int maxResults, ArgRunnable handler)
          Query one or more objects from the object database.
 void removeObject(String ref, String collectionName, ArgRunnable handler)
          Delete an object from the object database.
 void shutdown()
          Shutdown the object database.
 void updateObject(String ref, int version, Encodable obj, String collectionName, ArgRunnable handler)
          Update an object in the object database.
 
Methods inherited from interface org.elkoserver.foundation.json.TypeResolver
resolveType
 

Method Detail

addClass

void addClass(String tag,
              Class<?> type)
Inform the object database about a mapping from a JSON object type tag string to a Java class.

Parameters:
tag - The JSON object type tag string.
type - The class that 'tag' labels.

getObject

void getObject(String ref,
               String collectionName,
               ArgRunnable handler)
Fetch an object from the object database.

Parameters:
ref - Reference string naming the object desired.
collectionName - Name of collection to get from, or null to take the configured default (or the db doesn't use this abstraction).
handler - Handler to be called with the result. The result will be the object requested, or null if the object could not be retrieved.

putObject

void putObject(String ref,
               Encodable obj,
               String collectionName,
               boolean requireNew,
               ArgRunnable handler)
Store an object into the object database.

Parameters:
ref - Reference string naming the object to be stored.
obj - The object to be stored.
collectionName - Name of collection to put into, or null to take the configured default (or the db doesn't use this abstraction).
requireNew - If true, require that the object with the given ref not already exist
handler - Handler to be called with the result. The result will be a status indicator: an error message string if there was an error, or null if the operation was successful.

queryObjects

void queryObjects(JSONObject template,
                  String collectionName,
                  int maxResults,
                  ArgRunnable handler)
Query one or more objects from the object database.

Parameters:
template - Template object for the objects desired.
collectionName - Name of collection to query, or null to take the configured default.
maxResults - Maximum number of result objects to return, or 0 to indicate no fixed limit.
handler - Handler to be called with the results. The results will be an array of the object(s) requested, or null if no objects could be retrieved.

removeObject

void removeObject(String ref,
                  String collectionName,
                  ArgRunnable handler)
Delete an object from the object database. It is not considered an error to attempt to remove an object that is not there; such an operation always succeeds.

Parameters:
ref - Reference string naming the object to remove.
collectionName - Name of collection to delete from, or null to take the configured default (or the db doesn't use this abstraction).
handler - Handler to be called with the result. The result will be a status indicator: an error message string if there was an error, or null if the operation was successful.

shutdown

void shutdown()
Shutdown the object database.


updateObject

void updateObject(String ref,
                  int version,
                  Encodable obj,
                  String collectionName,
                  ArgRunnable handler)
Update an object in the object database.

Parameters:
ref - Reference string naming the object to be stored.
version - Version number of the object to be updated.
obj - The object to be stored.
collectionName - Name of collection to put into, or null to take the configured default (or the db doesn't use this abstraction).
handler - Handler to be called with the result. The result will be a status indicator: an error message string if there was an error, or null if the operation was successful.