It does get confusing trying to understand everyones ideas, but here is my design and a few reasons why: -
* Nothing is static in the server side (At least nothing in Data, or LockManager, or Service)
* Nothing is Singleton.
Lots of reasons behind this, but mainly because if you make anything static appart from stuff which really really needs to be shared across all databases, then its not a true flexible multi table design.
Same goes for Singleton.
Christy in your design you say that you have a static RandomAccessFile object. Now how do you expect to be able to handle multiple table/databases when the variable is static. You would need one static variable/table/file
in order to handle multiple databases. This is only if you are intending to mention the multi-table capability? I assume you are not intending to do a flexible multi-table design?
My design is like this: -
Service(Data(LockManager(Hashmap)))
Each user has a unique service stub which uses a unique Data object.
The Data object uses a lockManager object that is 1 per table/per database file (See not static or singleton)
Program Flow
------------
1) Server binds databaseFactory to RMI registry
2) Client Looks up databaseFactory and gets stub
3) Client uses databaseFactory.getDB(
String dbFilename) to get Service Stub
4) Server looks up a hashmap to see if the table is already open if yes then return the existing lockManager
else create a new lockManager for this table and insert into the hashmap with dbFilename as key. return it.
Server then calls return new Service(new Data(dbFilename, lockMgr));
I'm not critising anyones design but thought you might get something out of this hopefully. Critise mine if you
like, that shall help me improve it.
I think I've got my design finalized.
thanks,
Chris