View Javadoc

1   /**
2    * 
3    */
4   package org.sourceforge.jemm.database.components.interfaces;
5   
6   import org.sourceforge.jemm.database.ClassId;
7   import org.sourceforge.jemm.database.ClientId;
8   import org.sourceforge.jemm.database.ObjectAccessor;
9   import org.sourceforge.jemm.database.ObjectSyncData;
10  import org.sourceforge.jemm.database.ObjectSyncResp;
11  import org.sourceforge.jemm.database.components.ObjectStatusListener;
12  import org.sourceforge.jemm.database.components.TypeHandler;
13  import org.sourceforge.jemm.database.components.types.StoredListObject;
14  import org.sourceforge.jemm.database.components.types.StoredMapObject;
15  import org.sourceforge.jemm.database.components.types.StoredObject;
16  import org.sourceforge.jemm.database.components.types.StoredSetObject;
17  import org.sourceforge.jemm.database.components.types.StoredUserObject;
18  import org.sourceforge.jemm.types.ID;
19  
20  /**
21   * Internal object handler for the MemoryDatabase
22   * @author Rory Graves
23   */
24  public interface DBObjectHandler extends ObjectAccessor {
25  
26      /** Sets the object status listener.
27       * @param objectStatusListener The new object status listener to use.
28       */
29      void setObjectStatusListener(ObjectStatusListener objectStatusListener);
30      
31      StoredObject getObject(ID objectId);
32      
33      /** Update the given stored object, persisting its state.
34       * @param object The object to update
35       */
36      void update(StoredObject object);
37  
38  	/**
39       * Returns the stored user object referred to by 'id'
40       * @param objectId The id of the object to retrieve.
41       * @throws IllegalArgumentException If 'id' is null.
42       * @throws IllegalStateException If the object is not in the database (an internal error), or the type
43       *         of the retrieved object is not a user object.
44       */
45      StoredUserObject getUserObject(ID objectId);
46  
47      @Override
48      StoredListObject getListObject(ID objectId);
49  
50      @Override
51      StoredSetObject getSetObject(ID objectId);
52  
53      @Override
54      StoredMapObject getMapObject(ID objectId);
55  
56      /**
57       * Creates a new object with the given class type. <P>
58       * <B>N.b.</B> Once initialisation is complete - caller should call objectAccessor.initialisationFinished on the 
59       * returned id.
60       * @param classId The classId of the new object.
61       * @return The id of the newly created object.
62       */
63      ID createObject(ClientId clientId,ClassId classId);
64  
65      /**
66       * @param objectId The id of the object being synchronized
67       * @param syncData The synchronisation data, containing updated fields and current client version. 
68       * @return The synchronized object response data.
69       */
70      ObjectSyncResp synchroniseObject(ID objectId, ObjectSyncData syncData);
71  
72      /** Remote the object with the given id.
73       * @param id The id of the object to remove.
74       */
75      void removeObject(ID id);
76  
77      /**
78       * @return The number of objects held in this database.
79       */
80      int getObjectCount();
81  
82  	@Override
83  	boolean checkExists(ID objectId);
84  
85  	@Override
86  	void release(StoredObject object);
87  
88  	/** Debug method to return the number of locks currently held
89  	 * @return The number of lock currently held
90  	 */
91  	int getNoLocksHeld();
92  
93  	/** 
94  	 * Register a type handler for the given type class.
95  	 * @param typeClassId The class id of the type class being handled.
96  	 * @param handler The registered handler.
97  	 */
98  	void registerType(ClassId typeClassId, TypeHandler handler);
99  }