Does anyone know a good way to implement this. It's says in the assignment documentation that you should implement public void lock(int) and public void unlock(int). How I'm I then supposed to be able to track which client that is trying to lock and unlock the current record? Using the current threads name doesn't seem to be a adequate solution. Any suggestions?
I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages. The other way is that some people modify the signatures of the lock/unlock methods.
posted 19 years ago
Originally posted by Rick Fortier: I could never how to figure this out, but some people use custom socket factories to do this. I would search this NG for those messages. The other way is that some people modify the signatures of the lock/unlock methods.
Are you really allowed to change the signature of lock(int) and unlock(int)? It's says in the instructions "Record locking must be implemented using the methods public void lock(int) and public void unlock(int)".
posted 19 years ago
I think that it is best not to change the signatures. I did not. Others have and have passed. There are two conflicting requirements, identify the connection for unlock is the same as lock, and the method signatures. Unless you come up with a complex answer, you will probably have to violate one or the other of these rules.
Try this as a solution to this. It works and is not complex. Dont put any of the lock/unlock checking code in your Data class. Instead put this in whatever class you're using to do remote data access. Have a signature in that class that allows you to check who locks/unlocks appropriately and depending on that you can then call the non-checking lock/unlock methods in the Data class (ie at the server end). That way all remote lock/unlocks will be checked and local lock/unlocks don't really need checking. Akanimo.
I RELEASE YOU! (for now .... ) Feel free to peruse this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!