Martin de Klaus

Greenhorn
+ Follow
since Jun 16, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Martin de Klaus

Hi Roberto,

Thanks for the quick reply.

You mean, on line 32 of your code? I don't think that is necessary because you are already doing so on line 58. I'm not sure though, because I didn't run this code...



Hmmm, Actually in line 32 the RemoteServiceImpl itself is exported.
In line 58 the RemoteServiceFACTORY is exported.

If I remove line 32, I recieve a java.io.NotSerializableException: RemoteServiceImpl. So I guess I need to export both, the RemoteServiceFactory and the RemoteServiceImpl. As far as I understand, the RemoteServiceImpl needs to be exported as well to enable the client to access the server via the Proxy(Stubs) pattern. To make the RemoteServiceImpl serializable doesnt make sense to me because then RemoteServiceImpl gets transported to the client and executed on the client side only without communicating to the server.

Declaring a method in an interface with a throws clause means that the implementations can throw the listed exceptions, not that the implementations have to throw them. It's not strange



That's obviously true . I was just wondering, if the actual class method does not declare the RemoteException, even if the interface did so, how will a error during execution of a remote method call indicated? Or is this somehow handled by RMI itself?



Hi guys,

I already read a lot of posts regarding this topic:

https://coderanch.com/t/479761/java-developer-SCJD/certification/design-cloudier#2361306
https://coderanch.com/t/547905/java-developer-SCJD/certification/Business-Service#2497723
...

And actually I am in the middle of testing my implementation but still I have some doubts. Maybe some of you could help me with the following questions.

Facts:
I need a RMI factory to identify clients. Meaning each client will get its own RemoteService instance from the RMI factory impl. Each RemoteService instance has its own Data(Implementaion of given interface) instance used as lock-identifier-object in the Data.lock() method implementation.

Code:



Question 1: Is it ok to call "UnicastRemoteObject.exportObject(this);" in the RemoteServiceImpl constructor to avoid RemoteServiceImpl "extends UnicastRemoteObject"?
Question 2: Is it ok that RemoteServiceImpl does actually not redeclare the service methods incl. throwing RemoteException. Instead just the interface RemoteService declares the RemoteException??? That feels quite strange to me?
Question 3: Overall design approach? Any hints or recommendations?

Thanks and regards

Martin