• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

FBNS:How to extend Data.class

 
Martin Ouyang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just got the assignment. I'm thinking of the possibility of implement a 'multiton' DataServer(somebody created this word :just one instance for one db file)? If extending the Data.class as the 'multiton' DataServer,the lock(int record) ,unlock(int record) 's intefaces seem be unsuitable for this way.Because cannot tell the Data who want to lock/unlock the record.So I thinks about creating another DataServer.class and moving all file's operation into it.This DataServer's lock/unlock methods have one more parameter like 'Object obj' to show who want to lock/unlock the record. And the Data.class has only the DataServer instance . Is this fulfil the assignment?
 
hassan kalaldeh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Martin,

the lock(int record) ,unlock(int record) 's intefaces seem be unsuitable for this way.Because cannot tell the Data who want to lock/unlock the record


why do you want to know who lock/unlock the record !!
u need the lock only to ensure that only one person is updating the record at this moment , but no need to know who did the lock



Best Regards
[ December 26, 2005: Message edited by: hassan kalaldeh ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martin,

I presume you are trying to meet the following requirement:
From the instructions:

If an attempt is made to unlock a record that has not been locked by this connection, then no action is be taken.
In which case, you are quite correct: you do have to have some way of identifying who locked the record in the first place.

Hassan: It is worth noting that (as far as I know) all the assignments have a similar requirement - that is, only the client who locked the record can modify it or unlock it. You should probably recheck your instructions to see that you dont have either the requirement above, or for the URLyBird and Bodgit & Scarper assignments, something like "Locks a record so that it can only be updated or deleted by this client."

Martin - I suspect that your instructions state that "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)". In which case, your clients must be able to call these two methods in your extended class.

Assuming I am reading your post correctly, you are going to have DataServer implement those signatures, which will become the class that your clients will access. But DataServer will call Data's lock method, with another parameter to indicate who is doing the locking. Have I read your post correctly?

If so, then I think this will meet the requirements.

Regards, Andrew
 
Martin Ouyang
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,Andrew
I 'm ashamed of my pool English .I just mean the opposite like the following code.


I just mean to move all the real operation into DataServer from Data.
Is this correct?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic