|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.sourceforge.jemm.client.DatabaseAdapter
public class DatabaseAdapter
An Adapter that maps the ObjectState fields onto actual objects, which are created and stores the objects it creates into a memory sensitive cache. When objects are garbage collected the reference is cleared. Otherwise requests for objects with an id already pulled will return the exact same object.
| Field Summary | |
|---|---|
protected ClientId |
clientId
|
protected Database |
database
|
protected JEMMObjectCreator |
objectCreator
|
protected JEMMObjectFactory |
objectFactory
|
| Constructor Summary | |
|---|---|
DatabaseAdapter(Database database)
|
|
DatabaseAdapter(Database database,
JEMMObjectCreator creator)
|
|
| Method Summary | |
|---|---|
void |
acquireLock(ClientThreadId threadId,
ID jemmId)
Asynchronous request to acquire a lock. |
int |
cacheSize()
|
ClassInfo |
getClassInfo(ClassId classId)
Returns the class information for the given class id. |
EnumInfo |
getEnumInfo(EnumId enumId)
Returns the classname for the given enum type id. |
JEMMObject |
getObject(ID jemmId)
Looks up the Object with ID jemmId and converts from the underlying Delegate database into the actual JEMMObject from the response data. |
JEMMObject |
getRefreshedObject(ID jemmId)
Retrieves an object's information from the database but always calls the underlying database, updating the cache. |
JEMMObject |
getRoot(java.lang.String rootName)
Returns the object stored in the persistent root called 'rootName' |
ID |
newObject(ClassId classId,
JEMMObject target)
Notification of a new user object creation by the client. |
TypeResponse<?> |
processTypeRequest(JEMMObject obj,
ClassId classId,
TypeRequest<?> request)
|
void |
refreshObject(JEMMObject obj)
Refreshes an objects state by: - Retrieving the object again from the database and setting all primitives to the new values - setting all uninitialised Object fields to the new values - For initialised fields that are objects either: *) Matches the ID return from step 1 and refresh the object recursively *) Does not match the ID, the new object is retrieved and set as the value. |
ClassId |
registerClass(ClassInfo classInfo)
Register a user class. |
EnumId |
registerEnum(EnumInfo enumInfo)
Register an enumerated type. |
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 |
setObjectCreator(JEMMObjectCreator creator)
|
void |
setRoot(java.lang.String rootName,
JEMMObject newValue)
Set the persistent root reference to the given object. |
JEMMObject |
setRootIfNull(java.lang.String rootName,
JEMMObject newValue)
Sets the persistent root reference to the given object, if the root is currently null. |
void |
shutdown()
|
void |
synchroniseObject(JEMMObject jo)
Takes all the data from the syncData object and creates an ObjectSyncData packet which is then passed to the delegated Database. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final ClientId clientId
protected final Database database
protected JEMMObjectFactory objectFactory
protected JEMMObjectCreator objectCreator
| Constructor Detail |
|---|
public DatabaseAdapter(Database database,
JEMMObjectCreator creator)
public DatabaseAdapter(Database database)
| Method Detail |
|---|
public void setObjectCreator(JEMMObjectCreator creator)
public JEMMObject getObject(ID jemmId)
getObject in interface ObjectDatabasegetObject in interface ObjectSourcejemmId - The id of the object to retrieve.
public JEMMObject getRefreshedObject(ID jemmId)
ObjectDatabase
getRefreshedObject in interface ObjectDatabasejemmId - The id of the object to retrieve.
public void refreshObject(JEMMObject obj)
refreshObject in interface ObjectDatabaseobj - The object to retrieve and updatepublic void synchroniseObject(JEMMObject jo)
synchroniseObject in interface ObjectDatabasesyncData - the JEMMObject data to use.
public void setRoot(java.lang.String rootName,
JEMMObject newValue)
ObjectDatabase
setRoot in interface ObjectDatabaserootName - The name of the persistent root.newValue - The new value of the root.
public JEMMObject setRootIfNull(java.lang.String rootName,
JEMMObject newValue)
ObjectDatabase
setRootIfNull in interface ObjectDatabaserootName - The name of the persistent root.newValue - The new value of the root.
public JEMMObject getRoot(java.lang.String rootName)
ObjectDatabase
getRoot in interface ObjectDatabaserootName - The name of the persistent root.
public int cacheSize()
public void acquireLock(ClientThreadId threadId,
ID jemmId)
ObjectDatabase
acquireLock in interface ObjectDatabasethreadId - The requesting thread.jemmId - The id of the object to lock.
public void setClientLockAcquiredListener(ClientId clientId,
LockAcquiredListener listener)
ObjectDatabase
setClientLockAcquiredListener in interface ObjectDatabaseclientId - The client who is interested in their lock event notifications.listener - The listener to register.public ClassInfo getClassInfo(ClassId classId)
ObjectDatabase
getClassInfo in interface ObjectDatabaseclassId - The id of the held class.
public EnumInfo getEnumInfo(EnumId enumId)
ObjectDatabase
getEnumInfo in interface ObjectDatabaseenumId - The enum type id.
public ID newObject(ClassId classId,
JEMMObject target)
ObjectDatabase
newObject in interface ObjectDatabaseclassId - The class id of the new object (must be previously registered).
public ClassId registerClass(ClassInfo classInfo)
throws StructureModifiedException
ObjectDatabase
registerClass in interface ObjectDatabaseclassInfo - The information about the loaded user class (name/fields).
StructureModifiedException - if the class has been modified
and the Database does not accept the change
public EnumId registerEnum(EnumInfo enumInfo)
throws StructureModifiedException
ObjectDatabase
registerEnum in interface ObjectDatabaseenumInfo - The enumeration type information
StructureModifiedException - If a modification to the enum is detected.
public void releaseLock(ClientThreadId threadId,
ID jemmId)
ObjectDatabase
releaseLock in interface ObjectDatabasethreadId - The thread currently holding the lock.jemmId - The id of the object to release.public void removeLockAcquiredListener(ClientId clientId)
ObjectDatabase
removeLockAcquiredListener in interface ObjectDatabaseclientId - The id the the client who is no longer interested in lock events.
public TypeResponse<?> processTypeRequest(JEMMObject obj,
ClassId classId,
TypeRequest<?> request)
processTypeRequest in interface TypeRequestHandlerpublic void shutdown()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||