Meaningless Drivel is fun!
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes need help with locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "need help with locking" Watch "need help with locking" New topic

need help with locking

joel smither
Ranch Hand

Joined: Jan 01, 2005
Posts: 31
I'm really having trouble with record locking on the urlybird project. I'm using RMI. I have a local interface called UrlyBirdDBAccess and a remote interface called RemoteUrlyBirdDBAccess. I have a factory that returns either a local connection (object that implements UrlyBirdDBAccess) or a remote one through RMI (object that implements RemoteUrlyBirdDBAccess), however I use an adapter to transform the object that implements the RemoteUrlyBirdDBAccess interface to an object that implements the UrlyBirdDBAccess interface so the client doesn't need to know the difference between the actual connections.

When I run in a standalone mode (i.e. local connection), the lock and unlock methods implemented in the UrlyBirdDBAccess do nothing...record locking is not an issue in standalone mode.

I'm having trouble implementing the lock and unlock methods for the RemoteUrlyBirdDBAccess interface. On the remote side, do I need to call the methods lock and unlock defined in the UrlyBirdDBAccess interface or is
it ok to just ignore them in terms of implementing the lock and unlock methods declared in RemoteUrlyBirdDBAccess.
peter wooster
Ranch Hand

Joined: Jun 13, 2004
Posts: 1033
You are better off implementing the locking code for both standalone and networked access. This simplifies the code and makes testing your record locking a lot easier since you can test it with a program that uses it locally.

The cost of doing the synchronization and lockin when there is only one thread is probably about the same as the cost of determining if the database is being accessed locally or remotely.
I agree. Here's the link:
subject: need help with locking
It's not a secret anymore!