wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes forced to implement local locking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "forced to implement local locking " Watch "forced to implement local locking " New topic
Author

forced to implement local locking

Kevin Mc Cusker
Greenhorn

Joined: Aug 06, 2003
Posts: 21
Hi all,
When in local mode i must not use any networking. I want to go beyond this andremove the unnecessay locking\unlocking for local mode too.

my data access class, data.java, implements a DBAccess which for example has the following method:

public void deleteRecord(long recNo, long lockCookie)...

Am I stuck now with having to implement the locking in local mode too? If not how can i get around it?

Thanks!
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
You're thinking wrong if you're implementing the entire database logic twice.

You only need it once, nicely decoupled from the user interface, and have either one of 2 access layers (networked or local) in between the user interface and database which route the traffic.


42
Kevin Mc Cusker
Greenhorn

Joined: Aug 06, 2003
Posts: 21
Im not intending on implementing it twice, I just cant see how I can delete a record in local mode without having to also perform a lock, as the delete record method requires a lockCookie as a parameter.
Jon Kean
Greenhorn

Joined: Jul 30, 2006
Posts: 5
you wont be deleting anything in local mode
Kevin Mc Cusker
Greenhorn

Joined: Aug 06, 2003
Posts: 21
But what about booking a record? updateRecord also requires a lockCookie.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Hello,
What i am doing is in local mode dont validate the cookie, moreover, locking methods provide dummy implementations like:



SCJP, OCMJD, OCMJEA
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
YUGH.
The calculation and validation of the cookie is a clear responsibility of the database layer, which should know nothing at all about whether it's being run in standalone or networked mode.

You ARE in fact implementing your entire database layer twice if you do it like this.
Kevin Mc Cusker
Greenhorn

Joined: Aug 06, 2003
Posts: 21
So i'm resigned to locking in local mode, right?
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

My Data instance is mainly composited of lockManager instance and a DAO that performs CRUD operations.
It's simple. If the specified lockManager instance is null, locking is bypassed.
And obviously locking is not needed in local mode since
your locking system only needs to be concerned with multiple concurrent clients of your server

[ September 09, 2006: Message edited by: Oricio Ocle ]
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

You ARE in fact implementing your entire database layer twice if you do it like this.

Entire?
Thirumurugan Mylrajan
Ranch Hand

Joined: Jan 26, 2006
Posts: 64
Originally posted by Oricio Ocle:

Entire?


More or less.

The spec says that the DB should be capable of handling multiple clients.

The database should not be concerned whether its running in standalone or networked mode. Thats the concern of the client/server.


SCJP , SCJD. (IBM 142 in progress).
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Database is a very abstract word.
Logical locking is completely out of "database" issues.
And, literaly:
; therefore your locking system only needs to be concerned with multiple concurrent clients of your server
Bhavik Patel
Ranch Hand

Joined: Jul 12, 2004
Posts: 155
we do require locking in local mode i guess.. theres only a single client in this mode but for testing they can generate multiple threads and try to access the database or may be the database will be accessed by other applications running on the machine (which may work as client).. so i guess locking should be provided in Local mode also ..Can anyone verify this ...


SCJP 1.4<br />SCWCD 1.4(91%)<br />Working on SCJD -Bodgitt & Scrapper Constructions...<br /> <br />"It takes 43 muscles to frown & 17 to smile but it doen't take any to just sit there with a dumb look on your face .. Keep Smiling "
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: forced to implement local locking