Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Locking in local mode - URLyBird 1.1.2

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Al McGreavy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic