org.sourceforge.jemm.database.debug
Class DebugDatabase

java.lang.Object
  extended by org.sourceforge.jemm.database.debug.DebugDatabase
All Implemented Interfaces:
Database

public class DebugDatabase
extends java.lang.Object
implements Database

The DebugDatabase is a pass-through logger to an underlying database. All calls are logged and then passed through to the underlying implementation.

Author:
Rory Graves

Constructor Summary
DebugDatabase(Database underlyingDatabase)
           
 
Method Summary
 void acquireLock(ClientThreadId threadId, ID jemmId)
          Asynchronous request to acquire a lock.
 void clientDisconnect(ClientId clientId)
          Notification that the given client has disconnected, this call is only used on multi-client servers, allowing the server to free up resources associated with the client.
 ClassInfo getClassInfo(ClientId clientId, ClassId classId)
          Returns the class information for the given class id.
 DatabaseDebugIF getDebugInterface()
          Returns a debug interface for this database, or null if not available.
 EnumInfo getEnumInfo(ClientId clientId, EnumId enumId)
          Returns the information about the given enumeration.
 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'
 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.
 ClassId registerClass(ClientId clientId, ClassInfo classInfo)
          Register a user class.
 EnumId registerEnum(ClientId clientId, 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(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.
 ObjectSyncResp synchroniseObject(ClientId clientId, ID jemmId, ObjectSyncData syncData)
          Synchronise a client held object with the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugDatabase

public DebugDatabase(Database underlyingDatabase)
Method Detail

acquireLock

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

Specified by:
acquireLock in interface Database
Parameters:
threadId - The requesting thread.
jemmId - The id of the object to lock.

getClassInfo

public ClassInfo getClassInfo(ClientId clientId,
                              ClassId classId)
Description copied from interface: Database
Returns the class information for the given class id.

Specified by:
getClassInfo in interface Database
Parameters:
clientId - The id of the requesting client.
classId - The id of the held class.
Returns:
The class information for the held class.

getDebugInterface

public DatabaseDebugIF getDebugInterface()
Description copied from interface: Database
Returns a debug interface for this database, or null if not available.

Specified by:
getDebugInterface in interface Database
Returns:
The debug interface for this database, or null if not available.

getEnumInfo

public EnumInfo getEnumInfo(ClientId clientId,
                            EnumId enumId)
Description copied from interface: Database
Returns the information about the given enumeration.

Specified by:
getEnumInfo in interface Database
Parameters:
clientId - The id of the requesting client.
enumId - The id of the enumerated type.
Returns:
The classname of the registered enum type.

getObject

public GetObjectResp getObject(ClientId clientId,
                               ID jemmId)
Description copied from interface: Database
Retrieves an object's information from the database.

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

getRoot

public ID getRoot(ClientId clientId,
                  java.lang.String rootName)
Description copied from interface: Database
Returns the object stored in the persistent root called 'rootName'

Specified by:
getRoot in interface Database
Parameters:
clientId - The id of the requesting client.
rootName - The name of the persistent root.
Returns:
The ID of the object stored in the persistent root, or null if none.

newObject

public ID newObject(ClientId clientId,
                    ClassId classId)
Description copied from interface: Database
Notification of a new user object creation by the client.

Specified by:
newObject in interface Database
Parameters:
clientId - The id of the requesting client.
classId - The class id of the new object (must be previously registered).
Returns:
The ID assigned to the new object.

referenceCleared

public void referenceCleared(ClientId clientId,
                             ID... ids)
Description copied from interface: Database
Asynchronous notification that the client has de-referenced the given id.

Specified by:
referenceCleared in interface Database
Parameters:
clientId - The client who is no longer referencing 'id'
ids - The ID that has been de-referenced.

registerClass

public ClassId registerClass(ClientId clientId,
                             ClassInfo classInfo)
                      throws StructureModifiedException
Description copied from interface: Database
Register a user class.

Specified by:
registerClass in interface Database
Parameters:
clientId - The registering client.
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

public EnumId registerEnum(ClientId clientId,
                           EnumInfo enumInfo)
                    throws StructureModifiedException
Description copied from interface: Database
Register an enumerated type.

Specified by:
registerEnum in interface Database
Parameters:
clientId - The identity of the registering client.
enumInfo - The EnumInfo describing the enumerated type.
Returns:
Returns the id of the registered enum type.
Throws:
StructureModifiedException - If a modification to the enum is detected.

releaseLock

public void releaseLock(ClientThreadId threadId,
                        ID jemmId)
Description copied from interface: Database
Release the given lock held by the thread.

Specified by:
releaseLock in interface Database
Parameters:
threadId - The thread currently holding the lock.
jemmId - The id of the object to release.

removeLockAcquiredListener

public void removeLockAcquiredListener(ClientId clientId)
Description copied from interface: Database
Remove a lock listener

Specified by:
removeLockAcquiredListener in interface Database
Parameters:
clientId - The lock listener to remove.

setClientLockAcquiredListener

public void setClientLockAcquiredListener(ClientId clientId,
                                          LockAcquiredListener listener)
Description copied from interface: Database
Register a lock listener

Specified by:
setClientLockAcquiredListener in interface Database
Parameters:
clientId - The id of the client registering for lock notifications.
listener - The listener to register.

setRoot

public void setRoot(ClientId clientId,
                    java.lang.String rootName,
                    ID newValue)
Description copied from interface: Database
Set the persistent root reference to the given object.

Specified by:
setRoot in interface Database
Parameters:
clientId - The id of the requesting client.
rootName - The name of the persistent root.
newValue - The new value of the root.

setRootIfNull

public ID setRootIfNull(ClientId clientId,
                        java.lang.String rootName,
                        ID newValue)
Description copied from interface: Database
Sets the persistent root reference to the given object, if the root is currently null. This is an atomic operation.

Specified by:
setRootIfNull in interface Database
Parameters:
clientId - The id of the requesting client.
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.

synchroniseObject

public ObjectSyncResp synchroniseObject(ClientId clientId,
                                        ID jemmId,
                                        ObjectSyncData syncData)
Description copied from interface: Database
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).

Specified by:
synchroniseObject in interface Database
Parameters:
clientId - The id of the requesting client.
jemmId - The id of the object.
syncData - The object synchronisation data (client version, updated fields)
Returns:
Returned synchronisation information, (new version number and updated fields).

clientDisconnect

public void clientDisconnect(ClientId clientId)
Description copied from interface: Database
Notification that the given client has disconnected, this call is only used on multi-client servers, allowing the server to free up resources associated with the client.

Specified by:
clientDisconnect in interface Database
Parameters:
clientId - The id of the client that has disconnected.

processTypeRequest

public TypeResponse<?> processTypeRequest(ClientId clientId,
                                          ClassId classId,
                                          ID objId,
                                          TypeRequest<?> request)
Description copied from interface: Database
Process a request from a jemm type implementation. This is a generic call where a package of data is passed to database the type handler and a response is returned.

Specified by:
processTypeRequest in interface Database
Parameters:
clientId - The id of the requesting client.
classId - The id of the class making the request.
objId - The target object.
request - The request data.
Returns:
The response data supplied by the type handler.


Copyright © 2009. All Rights Reserved.