|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.elkoserver.objdb.ObjDBRemote
public class ObjDBRemote
Asynchronous access to a remote instance of the object database. This is implemented as a connection to an external repository.
| Constructor Summary | |
|---|---|
ObjDBRemote(ServiceFinder serviceFinder,
NetworkManager networkManager,
String localName,
BootProperties props,
String propRoot,
Trace appTrace)
Create an object to access a remote object repository. |
|
| 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. |
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 repository. |
void |
putObject(String ref,
Encodable obj,
String collectionName,
boolean requireNew,
ArgRunnable handler)
Store an object into the repository. |
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 repository. |
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 repository. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ObjDBRemote(ServiceFinder serviceFinder,
NetworkManager networkManager,
String localName,
BootProperties props,
String propRoot,
Trace appTrace)
The repository to connect to is specified by configuration properties, but may be indicated in one of two different ways:
The property "propRoot.service", if given, indicates a repository name to ask the Broker for. Specifying this property as the special value 'any' indicates that any repsitory that the Broker knows about will be acceptable.
Alternatively, a repository host may be specified directly using the "propRoot.host" property.
However the repository is indicated, the following properties are also recognized:
The boolean property "propRoot.dontlog", if true, indicates that message traffic between this server and the remote repository should not be logged, even if this server is otherwise logging all message traffic. If unspecified, it defaults to false.
The property "propRoot.retry" may specify a retry interval (in seconds), at which successive attempts will be made to connect to the external repository if earlier attempts have failed. The value -1 (which is the default if this property is left unspecified) indicates that no retries should be attempted.
The property "propRoot.classdesc" may specify a (comma-separated) list of references to class description objects to read from the repository at startup time.
serviceFinder - Access to broker, to locate repository server.networkManger - Network manager, for making outbound connections.localName - Name of this server.props - Properties that the hosting server was configured withpropRoot - Prefix string for generating relevant configuration
property names.appTrace - Trace object for event logging.| Method Detail |
|---|
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.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 object '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.
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 upated.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.
public void queryObjects(JSONObject template,
String collectionName,
int maxResults,
ArgRunnable handler)
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.
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)
addClass in interface ObjDBtag - The JSON object type tag string.type - The class that 'tag' labels.protected Object decodeJSONObject(JSONObject jsonObj)
jsonObj - The object being decoded.
public Class<?> resolveType(Class<?> baseType,
String typeName)
resolveType in interface TypeResolverbaseType - Base class from which result class must be derived.typeName - JSON type tag identifying the desired class.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||