org.sourceforge.jemm.client
Interface ObjectDatabase

All Superinterfaces:
ObjectSource, TypeRequestHandler
All Known Implementing Classes:
AlwaysRefreshObjectDatabase, DatabaseAdapter, DelegatingObjectDatabase, SynchronousLockDecorator

public interface ObjectDatabase
extends ObjectSource, TypeRequestHandler

An ObjectDatabase is similar to a Database but instead of working with Field values it works on the constructed Objects. This is only used Internally by the client for a number of pieces of functionality that benefit from pre-created objects such as reference tracking for GC purposes and caching.

Author:
Paul Keeble

Method Summary
 void acquireLock(ClientThreadId threadId, ID jemmId)
          Asynchronous request to acquire a lock.
 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)
          Retrieves an object's information from the database or a local cache if the object has already been retrieved and still in memory.
 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 obj)
          Notification of a new user object creation by the client.
 void refreshObject(JEMMObject obj)
          Retrieves the fields of the object again from the store and updates the passed object with all the values.
 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 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 synchroniseObject(JEMMObject syncObject)
          Synchronise a client held object with the server.
 
Methods inherited from interface org.sourceforge.jemm.client.TypeRequestHandler
processTypeRequest
 

Method Detail

getObject

JEMMObject getObject(ID jemmId)
Retrieves an object's information from the database or a local cache if the object has already been retrieved and still in memory.

Specified by:
getObject in interface ObjectSource
Parameters:
jemmId - The id of the object to retrieve.
Returns:
The object information (class type, field values etc.).

getRefreshedObject

JEMMObject getRefreshedObject(ID jemmId)
Retrieves an object's information from the database but always calls the underlying database, updating the cache.

Parameters:
jemmId - The id of the object to retrieve.
Returns:
The object information (class type, field values etc.).

refreshObject

void refreshObject(JEMMObject obj)
Retrieves the fields of the object again from the store and updates the passed object with all the values. This call may never be cached as its intention is to make sure everything is up to date in a locked scenario.

Parameters:
obj - The object to retrieve and update

synchroniseObject

void synchroniseObject(JEMMObject syncObject)
Synchronise a client held object with the server. Passing in the current client version and any updated fields this method returns the new version number of the object and any fields updated remotely (by another client).

Parameters:
syncObject - The object being synchronized.

setRoot

void setRoot(java.lang.String rootName,
             JEMMObject newValue)
Set the persistent root reference to the given object.

Parameters:
rootName - The name of the persistent root.
newValue - The new value of the root.

setRootIfNull

JEMMObject setRootIfNull(java.lang.String rootName,
                         JEMMObject newValue)
Sets the persistent root reference to the given object, if the root is currently null. This is an atomic operation.

Parameters:
rootName - The name of the persistent root.
newValue - The new value of the root.
Returns:
The old value if it was not null, or the recently set value.

getRoot

JEMMObject getRoot(java.lang.String rootName)
Returns the object stored in the persistent root called 'rootName'

Parameters:
rootName - The name of the persistent root.
Returns:
The ID of the object stored in the persistent root, or null if none.

registerClass

ClassId registerClass(ClassInfo classInfo)
                      throws StructureModifiedException
Register a user class.

Parameters:
classInfo - The information about the loaded user class (name/fields).
Returns:
The class id of the registered class.
Throws:
StructureModifiedException - if the class has been modified and the Database does not accept the change

registerEnum

EnumId registerEnum(EnumInfo enumInfo)
                    throws StructureModifiedException
Register an enumerated type.

Parameters:
enumInfo - The enumeration type information
Returns:
Returns the id of the registered enum type.
Throws:
StructureModifiedException - If a modification to the enum is detected.

acquireLock

void acquireLock(ClientThreadId threadId,
                 ID jemmId)
Asynchronous request to acquire a lock. This method will return immediately, but the caller should wait until notified by the LockAcquiredListener callback.

Parameters:
threadId - The requesting thread.
jemmId - The id of the object to lock.

setClientLockAcquiredListener

void setClientLockAcquiredListener(ClientId clientId,
                                   LockAcquiredListener listener)
Register a lock listener

Parameters:
clientId - The client who is interested in their lock event notifications.
listener - The listener to register.

removeLockAcquiredListener

void removeLockAcquiredListener(ClientId clientId)
Remove a lock listener

Parameters:
clientId - The id the the client who is no longer interested in lock events.

releaseLock

void releaseLock(ClientThreadId threadId,
                 ID jemmId)
Release the given lock held by the thread.

Parameters:
threadId - The thread currently holding the lock.
jemmId - The id of the object to release.

newObject

ID newObject(ClassId classId,
             JEMMObject obj)
Notification of a new user object creation by the client.

Parameters:
classId - The class id of the new object (must be previously registered).
Returns:
The ID assigned to the new object.

getClassInfo

ClassInfo getClassInfo(ClassId classId)
Returns the class information for the given class id.

Parameters:
classId - The id of the held class.
Returns:
The class information for the held class.

getEnumInfo

EnumInfo getEnumInfo(EnumId enumId)
Returns the classname for the given enum type id.

Parameters:
enumId - The enum type id.
Returns:
The classname of the registered enum type.


Copyright © 2009. All Rights Reserved.