• 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

intentions of variable cookie on methods.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers !!
Somebody could explain me which the intention of the variable cookie in the methods update, delete and unlock in the DBAcess interface of the B&S?



Thanks
�verton
SCJP, SCJD(UD)
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by �verton Amorim:
Hello Ranchers !!
Somebody could explain me which the intention of the variable cookie in the methods update, delete and unlock in the DBAcess interface of the B&S?



Thanks
�verton
SCJP, SCJD(UD)



It is used to confirm that the record is locked with the cookie. That way only the user that locked the record can update it or unlock it.
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is how I interpreted the cookie... Please feel free to correct me if needed.

When a client locks a record, a unique long is generated by the server and associated with the record number (I plan on doing this with a lockedRecord collection - this will also ensure that duplicate cookies are not used at the same time). The long is returned to the client as the cookie.

When the client tries to update, delete, or unlock the record, it must provide the same cookie value that was provided when it locked the record. If it doesn't have the correct cookie value, then a SecurityException is thrown (at least in my version - B&S 2.2.3)
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now we now what the cookie does, the question remains why would you (or actually: why would the specification) use cookies.

I think it is to reduce the amount of synchronization needed to make your application thread-safe, and thus faster.

Besides, I actually think a cookie should be stored at the client.
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I think it is to reduce the amount of synchronization needed to make your application thread-safe, and thus faster.


Yes, that is exactly what it is for. If cookies were not specified in the assignment, you have to rely on a contract with the clients that no client will attempt to unlock a record that it did not lock in the first place. The cookie just enforces this contract.
[ September 09, 2004: Message edited by: Paul Bourdeaux ]
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic