In the off chance it might help someone -
All records are cached as record objects (a custom class)
Lock mappings are stored in the Data attribute (all synchro is done on this oject for locking actions)
private static HashMap recordsLocked = new HashMap();
As above in the Data class I implement the Sun supplied,
public long lockRecord(long recNo)throws RecordNotFoundException
(if mapping already exists for this record wait until lock released, otherwise add new record/random lockcookie mapping to HashMap recordsLocked )
public void unlock(long recNo, long cookie)throws SecurityException
( check using Data method isValidRecordLock(recNo, cookie) if a record lock exists for this record/lockcookie combination, if so remove mapping from hashmap. )
These methods are wrapped in the Remote implementation, in the local implementation the methods throw new UnsupportedOperationException ("No local locking implemented");
Each clients controller class has a connetion object (local or remote Database access implementation ) and stores one lockcookie
The client only uses locking when a RMI client books a record, for a local
connetion -1 passed as lockcookie indicates ignore lcoking.
Hope it helps.
ps. I found the most confusing aspect of the project was exception handling, I just passed everything up to the GUI controller, which rewrapped the message and sent it to a GUI level error display method
to generate a dialog window with the original cause
string.
I could not see any case where I would handle an exception at a lower level.
Still not sure if this is right.
Regards
Hugh