|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.sourceforge.jemm.client.DelegatingDatabase
org.sourceforge.jemm.client.TrackingDatabase
public class TrackingDatabase
This Database implementation tracks maps any ids from the delegated database into singleton tracked ids (i.e. for any given object, there will be one singleton instance of a tracked id. All down calls to the delegate will have the tracked ids mapped back to regular ids.
It is responsible for detecting live use of the ids within the client code, once a client has finished using a tracked id, it will be garbage collected and the database will inform the underlying database that the id is no longer referenced.
To avoid a race condition between marking an id as unused and it being passed back in another call, the database users locking
N.b. This is heavily based upon the original ReferenceCleaner implementation and effectively is moving that code down into the Database rather than ObjectDatabase layer.
Field Summary | |
---|---|
static long |
SLEEP_TIME
Sleep time between reference cleaning cycles (in ms) |
Constructor Summary | |
---|---|
TrackingDatabase(Database delegate,
TrackedIDFactory idFactory)
|
Method Summary | |
---|---|
void |
acquireLock(ClientThreadId threadId,
ID jemmId)
Asynchronous request to acquire a lock. |
GetObjectResp |
getObject(ClientId clientId,
ID jemmId)
Retrieves an object's information from the database. |
ID |
getRoot(ClientId clientId,
java.lang.String rootName)
Returns the object stored in the persistent root called 'rootName' |
void |
internalClearRererence(ID[] toClear)
|
ID |
newObject(ClientId clientId,
ClassId classId)
Notification of a new user object creation by the client. |
TypeResponse<?> |
processTypeRequest(ClientId clientId,
ClassId classId,
ID objId,
TypeRequest<?> request)
Process a request from a jemm type implementation. |
void |
referenceCleared(ClientId clientId,
ID... ids)
Asynchronous notification that the client has de-referenced the given id. |
void |
releaseLock(ClientThreadId threadId,
ID jemmId)
Release the given lock held by the thread. |
void |
removeLockAcquiredListener(ClientId clientId)
Remove a lock listener |
void |
setClientLockAcquiredListener(ClientId clientId,
LockAcquiredListener listener)
Register a lock listener |
void |
setRoot(ClientId clientId,
java.lang.String rootName,
ID newValue)
Set the persistent root reference to the given object. |
ID |
setRootIfNull(ClientId clientId,
java.lang.String rootName,
ID newValue)
Sets the persistent root reference to the given object, if the root is currently null. |
void |
shutdown()
TrackingDatabase uses a separate thread to pass ID information for cleaning, shutdown must be called to recover that native resource to avoid leaks. |
ObjectSyncResp |
synchroniseObject(ClientId clientId,
ID jemmId,
ObjectSyncData syncData)
Synchronise a client held object with the server. |
Methods inherited from class org.sourceforge.jemm.client.DelegatingDatabase |
---|
clientDisconnect, getClassInfo, getDebugInterface, getEnumInfo, registerClass, registerEnum |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long SLEEP_TIME
Constructor Detail |
---|
public TrackingDatabase(Database delegate, TrackedIDFactory idFactory)
Method Detail |
---|
public void acquireLock(ClientThreadId threadId, ID jemmId)
Database
acquireLock
in interface Database
acquireLock
in class DelegatingDatabase
threadId
- The requesting thread.jemmId
- The id of the object to lock.public GetObjectResp getObject(ClientId clientId, ID jemmId)
Database
getObject
in interface Database
getObject
in class DelegatingDatabase
clientId
- The id of the requesting client.jemmId
- The id of the object to retrieve.
public ID getRoot(ClientId clientId, java.lang.String rootName)
Database
getRoot
in interface Database
getRoot
in class DelegatingDatabase
clientId
- The id of the requesting client.rootName
- The name of the persistent root.
public ID newObject(ClientId clientId, ClassId classId)
Database
newObject
in interface Database
newObject
in class DelegatingDatabase
clientId
- The id of the requesting client.classId
- The class id of the new object (must be previously registered).
public void referenceCleared(ClientId clientId, ID... ids)
Database
referenceCleared
in interface Database
referenceCleared
in class DelegatingDatabase
clientId
- The client who is no longer referencing 'id'ids
- The ID that has been de-referenced.public void releaseLock(ClientThreadId threadId, ID jemmId)
Database
releaseLock
in interface Database
releaseLock
in class DelegatingDatabase
threadId
- The thread currently holding the lock.jemmId
- The id of the object to release.public void setRoot(ClientId clientId, java.lang.String rootName, ID newValue)
Database
setRoot
in interface Database
setRoot
in class DelegatingDatabase
clientId
- The id of the requesting client.rootName
- The name of the persistent root.newValue
- The new value of the root.public ID setRootIfNull(ClientId clientId, java.lang.String rootName, ID newValue)
Database
setRootIfNull
in interface Database
setRootIfNull
in class DelegatingDatabase
clientId
- The id of the requesting client.rootName
- The name of the persistent root.newValue
- The new value of the root.
public ObjectSyncResp synchroniseObject(ClientId clientId, ID jemmId, ObjectSyncData syncData)
Database
synchroniseObject
in interface Database
synchroniseObject
in class DelegatingDatabase
clientId
- The id of the requesting client.jemmId
- The id of the object.syncData
- The object synchronisation data (client version, updated fields)
public TypeResponse<?> processTypeRequest(ClientId clientId, ClassId classId, ID objId, TypeRequest<?> request)
Database
processTypeRequest
in interface Database
processTypeRequest
in class DelegatingDatabase
clientId
- The id of the requesting client.classId
- The id of the class making the request.objId
- The target object.request
- The request data.
public void removeLockAcquiredListener(ClientId clientId)
Database
removeLockAcquiredListener
in interface Database
removeLockAcquiredListener
in class DelegatingDatabase
clientId
- The lock listener to remove.public void setClientLockAcquiredListener(ClientId clientId, LockAcquiredListener listener)
Database
setClientLockAcquiredListener
in interface Database
setClientLockAcquiredListener
in class DelegatingDatabase
clientId
- The id of the client registering for lock notifications.listener
- The listener to register.public void internalClearRererence(ID[] toClear)
public void shutdown()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |