Enthuware - Best Mock Exams and Questions for Oracle Java Certifications
Quality Guaranteed - Pass or Full Refund!
Rainer<br />SCJP, SCJD, SCWCD
Thanks,<BR>Ravikiran<BR>rkchoppalli@yahoo.com
Originally posted by Michael Scott II:
The way I understand it to work is like this.
On the server-side there would be a remoteDataFactoryImpl which had a reference to the Data object and was binded to the name server. The client would do a look up on the name server for this factory. Once the client had a reference to the factory it would call a method like create() which would instantiate a remoteDataImpl, passes it a reference to the Data object, and pass the reference back to the client. The remoteDataImpl is export but not binded to the Name server. Therefore it is a remoteObject but you can't do a look up in the name server to find it. Once you have a reference to remoteDataImpl you make all request on the Data object though it.
There would be one remoteDataImpl object for every client.
Now I just started on the developer yesterday but I think you need the lock and unlock methods for:
I go in as a client and look up a record for what ever reason. I might be using the information on that specific record to do something if I don't lock that record then someone else can go in and change the information in the record. therefore the information inwhich I was viewing is incorrect, as well as anything I did with that information.
The lock and unlock methods are to lock a specific record. Therefore you need the lock and unlock methods.
Look at it from this perspective I want to book a flight and I need I tell someone we have one more seat and I can get it for him. If I don't lock that record someone else can come alone who types faster and steal that person seat which I just promised him.
The synchronized is to provent someone the move the file pointer in the middle of some one reading or write to the file.
I hope that helps you guys.
Mike
Originally posted by Karl Fu:
[...] So if i understand it correctly, if there is 10 concurrent user, then there are 10 Impl object reside on the server side.
However, what I don't get is how to obtain a reference of client ID on the server without changing the signature of lock and unlock. Since every client (represented by impl object) has the same data object within it, and the lock method is within the data class.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Rick Fortier:
Peter -
I don't find this to be true. On the server I have the following classes: [...] The only objects which ever got above 1 [instance] were DataInfo and FieldInfo.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Karl Fu:
I think i got misdirected by the source code provided ...they put the lock and unlock method in the Data class and this makes me assume the entire locking mechanism could be done within the Data class alone.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Paul Anil:
No, lock and unlock operations are needed to support a "business rule" ie. if two clients try to modify the same record the result should be sensible. A call sequence of lock, read, modify, unlock will make sure that only one client modifies the locked record at a time. But it will allow other clients to modify other records. Locking a record (by calling lock() ) does not prevent multiple threads from modifying the file. (It prevents multiple clients from modifying the same record).
The individual methods (like modify(), write() etc. ) are doing an entirely different job. They are actully writing the data to the file and so they have to be synchronized because if multiple threads try to modify the file at the same time, the file will be screwed up!
HTH,
Paul.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Suppose only there is one instance of Data class.--No, lock and unlock operations are needed to support a "business rule" ie. if two clients try to modify the same record the result should be sensible. A call sequence of lock, read, modify, unlock will make sure that only one client modifies the locked record at a time. But it will allow other clients to modify other records. Locking a record (by calling lock() ) does not prevent multiple threads from modifying the file. (It prevents multiple clients from modifying the same record).
The individual methods (like modify(), write() etc. ) are doing an entirely different job. They are actually writing the data to the file and so they have to be synchronized because if multiple threads try to modify the file at the same time, the file will be screwed up!
Q2:--- Since multiple threads are virtually executed at the same time you have to ensure that only one thread can alter the position of the file pointer. This is done by synchronizing on the modify method (and others like getRecord, etc).
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
We now have a similar problem with multiple clients running this method (either because you have a multi threaded server or because you have your booking method on the client side). Client A starts validating record 5, Client B starts validating record 5, Client A then books record 5, Client B then books record 5
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Seriously? That's what you're going with? I prefer this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|