File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Locking in local mode - URLyBird 1.1.2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Locking in local mode - URLyBird 1.1.2" Watch "Locking in local mode - URLyBird 1.1.2" New topic
Author

Locking in local mode - URLyBird 1.1.2

Al McGreavy
Greenhorn

Joined: May 23, 2003
Posts: 2
Hi

I had everything working fine in both local and networked mode and realised I have omitted something!! Argh!

I have a Data class implementing a DB interface. This interface includes lock and unlock methods and has other methods requiring lockCookies ie.

public void update(int recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;

My Data class is a facade to a LockHandler for all locking and a FileHandler for all database operations.

I have a DataService class as an adapter to the Data class. This implements another interface, Database and it is this that exposes methods to the client (all locking is on the server). It is also a singleton so that the Data class can be extended in the future.

My local mode is working through the DataService and thus my local mode uses locking as well as the networked mode at the moment.

I can't think of a way round this just now other than having another class, say, LocalDataService to implement the Database interface as well but which creates an instance of FileHandler and not the Data class so that no locking is employed. So, local mode would create a LocalDataService with no locking and networked mode would create a DataService (Rename this to RemoteDataService) with locking.

I'm not so sure about this approach. Would you please advise your thoughts on this.

Many thanks


Alison
[ August 17, 2007: Message edited by: Al McG ]
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi Al McG,

I don't see any problem with locking in local mode, do you?

If you are worried about performance, i think you can just ignore the very tiny difference.

Herman
rinke hoekstra
Ranch Hand

Joined: Apr 06, 2007
Posts: 152
Hi Al,

I think you're overcomplicating. Sure, locking and unlocking has its costs in terms of performance, so it might be an idea to bypass it when not needed, but there is no requirement on performance in the assignment. So I wouldn't bother; it can only costs you points but you will gain none. I've seen people pass with 400 points who didn't bother about this.


_ _ ________________________ _ _ <br /> <br />Just SCJP (but 93%)
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Hello "Al McG"-

Welcome to JavaRanch.

On your way in you may have missed that we have a JavaRanch Naming Policy for displayed (screen) names. Your displayed name must consist of a first name (or an initial), a space, and a family name (in that order) and not be obviously fictitious. Since yours "Al McG", does not conform with it, please take a moment to change it, which you can do right here.

Posters with nonconforming displayed names will be locked out of JavaRanch after a few posts using those names.

Thanks
-Barry

(NR) - search tag


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Al McGreavy
Greenhorn

Joined: May 23, 2003
Posts: 2
Ok Barry, point taken.

It's not "entirely" fictitious as most people call me 'Al' and 'McG' is shortish for my surname. However, point taken, I have changed my displayed name to my real name.

Thanks

Alison
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Locking in local mode - URLyBird 1.1.2
 
Similar Threads
Using Both Rich & Thin Client
Data.close() is it needed?
NX: (Contractors) Interfaces and design question
Could somebody suggest me about locking in standalone mode,please?
NX: Client side lock vs Server side lock