• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

LockManager class

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

I have quick question, my Data class implements the Sun interface specification DBMain.java however in the lock() and unlock() methods i do not provide any details within these methods. I use a LockManager class to encapsulate the reserving/releasing of records.This class is then used by a facade class which call methods within the LockManager class to do the locking/unlocking of records. Is this okay to do once it is documented or will it be an automatic fail if i do this.

Also in the interface specification, unlock() and unlock() methods throw a RecordNotFoundException,is it okay to call further exceptions from these methods within my LockManager class or should i adhere to the method declaration with the interface specification.

Your comments would be most appreciated.

David
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I had a similar situation and doubt but I did not get any satisfactory answer, so I decided to copy & paste the javadocs just in case... I didn't want to get an automatic failure because of this.

Cheers,

Iv�n
 
David Winters Junior
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ivan,

Not sure what you mena by copying and pasting the javadocs here?

Can someone comment on this, we should be able to follow this design as long as we comment on this in our design document?

Surely someone on the forum can comment on this issue?

David
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by David Winters Junior:
in the lock() and unlock() methods i do not provide any details within these methods.



Do you mean you didn't write any javadoc for these 2 methods in your Data.java ? What do you mean by "provide any details within these methods" ?


I use a LockManager class to encapsulate the reserving/releasing of records.This class is then used by a facade class which call methods within the LockManager class to do the locking/unlocking of records. Is this okay to do once it is documented or will it be an automatic fail if i do this.



So your lock and unlock methods are using a LockManager. This is fine, your Data object is allowed to use java objects to perform its tasks..
The constraint is to respect the interface provided by SUN, how it is implemented is up to you.


Also in the interface specification, unlock() and unlock() methods throw a RecordNotFoundException,is it okay to call further exceptions from these methods within my LockManager class or should i adhere to the method declaration with the interface specification.


Inside lock and unlock (the other methods also) you can handle any exception you want/need to.. However, since you comply with the interface provided by SUN, lock/unlock.. cannot throw other exception than the one specified.

Here's a dummy example nothing close to what's need to be done, simply to demonstrate the use of Exception..
You can handle exception in your method, but you can only throw RecordNotFoundException.


On top of that, you can always throw RuntimeException or subclasses of RecordNotFoundException.

Hope this helps
Alex
 
David Winters Junior
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex,

OK thanks for the clarification that makes sense.

I have the lock/unlock methods defined in my facade class used to call methods in Data.java(implements DBMain interface provided by Sun) as is defined in the interface provided by Sun. I then call LockManager's methods from wtihin these methods to perform the actual details of these methods. Just reconfirming this is okay?

David
 
reply
    Bookmark Topic Watch Topic
  • New Topic