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 since cookie exist, does that mean RMI connection factory is not needed? 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 "since cookie exist, does that mean RMI connection factory is not needed?" Watch "since cookie exist, does that mean RMI connection factory is not needed?" New topic
Author

since cookie exist, does that mean RMI connection factory is not needed?

Li zhai
Greenhorn

Joined: Jul 19, 2006
Posts: 7
Hi everyone,

Thanks a lot for great and kind help.

I am keeping working on the assignment of "Bodgitt and Scarper". I just designed the middle-layer by using RMI. I used the RMI connection factory model. That model will guarantee to create new remote object for each client. The model works fine.

But since cookie is used in the project, may the factory connection model not be needed? Even if the server just use the same thread for different clients and one remote object are shared by several clients, the cookie will identify the client and make the synchronization work. I tested by using NONE-factory model. The clients could lock and update and unlock in synchronized way.

Does that mean cookie make factory-model unnecessary?

Could anyone help me to verify this problem?

I appreciate if anyone could help ASAP.

Thanks a lot and have a great day.
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Hello, Li.
Does your lock method have the following comment:


In this case you are required to use the cookie in unlocking.
So the use of Connection Factory in order to identify the client is inappropriate.

-The use of the connection factory in order manage unreferenced clients is different.
You can always base your arguments in that.

But, IMO, the cookie imposition forces us not to identify the client any other way, and therefore timeouts are the only way to ensure locking stability

Regards


SCJP, OCMJD, OCMJEA
Li zhai
Greenhorn

Joined: Jul 19, 2006
Posts: 7
Hi Oricio,

"But, IMO, the cookie imposition forces us not to identify the client any other way, and therefore timeouts are the only way to ensure locking stability"

How do you do with the timeout?

I just use the following code to get the lock of the map of lockedRecords.

synchronized(lockedRecords){
while (lockedRecords.containsKey(rec)) {
try{
lockedRecords.wait(100);
}
catch (InterruptedException e) {
throw new IllegalStateException("Another thread interrupts the current thread",e);
}
}
cookie = getNextCookie();
lockedRecords.put(recNo, cookie);
}

But if the user don't unlock the record, the program will loop forever?

How do you handle this kind of issue?
Oricio Ocle
Ranch Hand

Joined: Nov 30, 2004
Posts: 284

Hello Li zhai take a look here:
locking timeout thread
Regards
 
 
subject: since cookie exist, does that mean RMI connection factory is not needed?