Originally posted by Roman Rytov:
in my design there is no way to get such remote objects from the registry. Clients find one remote bound to the registry object and call its method getRemoteConnection() that call private constructor in wich I assigh long ID = timemils() + hashCode(). It's unique 100% all the time over the server.
Mark didn't your connection object have a reference to the Data object?
How could you make the Data object know about the locks unless it was independant of your Connection object?
Originally posted by Mark Spritzler:
Well the connection object kept track of the locks that the one client had, once it was placed in the connection objects Hashset, it called the data classes lock method with the record number. So the Data class also had a Hashset of all locks by all clients.
In the connection object's unlock method, it first checked the connection objects' Hashset to make sure that client had it locked, before it would send it to the data class's unlock method.
In the connection object I also implemented the Unreference interface, and had code that would call the unlock method of the data class for each locked record the connection object had in it's Hashset.
). This results in a LockManager that doesn't care who owns the lock, right ?! Isn't this poor reusability ? If I wanted to use this LockManager in another application I'd still have to duplicate the RemoteDataImpl's code that arranges the ownership of locks...
Think of ways splitting responsabilities apart so that each class does one thing and only one thing
Originally posted by Andrew Collins:
2.Move the responsability of checking who owns a lock to the LockManager
[ April 19, 2002: Message edited by: Andrew Collins ]
I am a big proponent of threads doing the locking. Except, evidently, you should not rely on a thread id while identifying the client. Instead you should rely on user's own server object reference -- that is always unique.
didn't have a LockManager. My locking code was in two places. first in the RemoteData class I have a hashset that tracks the locks that that one client has. I pass my actual calls to my Data class, which has it's own HashSet of all the locks, and it doesn't know what client has what.
In the RemoteData class, when you call unlock, it first checks it's own HashSet, if the record is in there, then it passes the unlock call to the Data class.
Using a LockManager, I would just pass the calls to it, rather than the Data class. That's all