This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how do i use the cookies?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how do i use the cookies??" Watch "how do i use the cookies??" New topic
Author

how do i use the cookies??

Derick Potgieter
Greenhorn

Joined: Feb 19, 2004
Posts: 13
Urlybird 1.1.2
I`m generating a new cookie in my lock and then returning it to the caller.

but in my update or delete method it wants the cookie value specified.
now problem
[CODE]
public void update(int recNo, String[] data, long lockCookie) throws
RecordNotFoundException, SecurityException{


1. should i write an adapter class where i would say
data.lock(1);
data.update(1,data(array),cookie);
data.unlock(1,cookie

2. how do you compare the two cookies.
i created a map object in my data class, giving 1 the recNo and
2 the cookie value.

but you have to send it as a Long and long, so when i cant to
compare the two they differ? any suggestions??
Jon Entwistle
Ranch Hand

Joined: Feb 20, 2003
Posts: 118

1. should i write an adapter class


It is one solution - as long as you state your reasons and the options you should be fine.


2. how do you compare the two cookies.
i created a map object in my data class, giving 1 the recNo and
2 the cookie value.

but you have to send it as a Long and long, so when i cant to
compare the two they differ? any suggestions??


I am not sure I see what you are driving at . You would only ever compare keys to keys (Integer to Integer for recNo in your case) and values to values (Long to Long) - both of these classes overide the equals method in object to return true when two instances represent the same number.

To compare a long to a Long, just convert the long value into a Long object and compare.


Hope this helps....


Jon
[ May 27, 2004: Message edited by: Jon Entwistle ]

SCJD, SCEA
Serkan Yazici
Ranch Hand

Joined: Apr 24, 2004
Posts: 33
Hi Derickll,

Shouldn't your lock return the cookie it generated, which you can just
use with update/unlock:


-- SCJP 1.4 (98%), SCJD (98%), SCWCD (96%), OCA Dev (97% avg.), SCBCD (97%), SCJP 1.5 BETA (90%)<br />-- OCP Dev (maybe), MCDBA (probably) SCEA (eventually)<br />-- Haven't tried Firefox yet? Free, open, secure, fast, tabified, and slick!<br />-- <a href="http://www.mozilla.org/products/firefox/" target="_blank" rel="nofollow">http://www.mozilla.org/products/firefox/</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how do i use the cookies??
 
Similar Threads
Why I lost points in locking, pls comment on my code
NX: Thread safe and WeakHashMap vs. Unrefence Interface
Locking strategy URLyBird 1.1.1 with ReentrantLock
NX: Contractor locking
My locking approach...comments please