public class ObjDBLocal extends Object
Constructor and Description |
---|
ObjDBLocal(BootProperties props,
String propRoot,
Trace appTrace)
Create an object to access a local object store.
|
Modifier and Type | Method and Description |
---|---|
void |
addClass(String tag,
Class<?> type)
Inform the object database about a mapping from a JSON object type tag
string to a Java class.
|
protected Object |
decodeJSONObject(JSONObject jsonObj)
Convert a parsed JSON object description into the object it describes.
|
void |
getObject(String ref,
String collectionName,
ArgRunnable handler)
Fetch an object from the store.
|
void |
putObject(String ref,
Encodable obj,
String collectionName,
boolean requireNew,
ArgRunnable handler)
Store an object into the store.
|
void |
queryObjects(JSONObject template,
String collectionName,
int maxResults,
ArgRunnable handler)
Query the object store.
|
void |
removeObject(String ref,
String collectionName,
ArgRunnable handler)
Delete an object from the store.
|
Class<?> |
resolveType(Class<?> baseType,
String typeName)
Get the class associated with a given JSON type tag string.
|
void |
shutdown()
Shutdown the object database.
|
void |
updateObject(String ref,
int version,
Encodable obj,
String collectionName,
ArgRunnable handler)
Update an object in the store.
|
public ObjDBLocal(BootProperties props, String propRoot, Trace appTrace)
The property "propRoot.objstore" may specify the
fully qualified Java class name of the object store implementation to
use. If unspecified, the default, "org.elkoserver.objdb.store.filestore.FileObjectStore
", will be used.
The property "propRoot.classdesc" may specify a (comma-separated) list of references to class description objects to read from the store at startup time.
Other properties may be interpreted as appropriate for the particular object store implementation selected.
props
- Properties that the hosting server was configured withpropRoot
- Prefix string for selecting relevant configuration
properties.appTrace
- Trace object for event logging.public void getObject(String ref, String collectionName, ArgRunnable handler)
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.public void putObject(String ref, Encodable obj, String collectionName, boolean requireNew, ArgRunnable handler)
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 existhandler
- 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.public void updateObject(String ref, int version, Encodable obj, String collectionName, ArgRunnable handler)
ref
- Reference string naming the object to be stored.version
- Version number of the object to be updatedobj
- 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.public void queryObjects(JSONObject template, String collectionName, int maxResults, ArgRunnable handler)
template
- Query template indicating the object(s) 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.public void removeObject(String ref, String collectionName, ArgRunnable handler)
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.public void shutdown()
public void addClass(String tag, Class<?> type)
protected Object decodeJSONObject(JSONObject jsonObj)
jsonObj
- The object being decoded.public Class<?> resolveType(Class<?> baseType, String typeName)
resolveType
in interface TypeResolver
baseType
- Base class from which result class must be derived.typeName
- JSON type tag identifying the desired class.Copyright © 2017. All rights reserved.