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 Why the remote client code must provide all the public methods of the Data class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Why the remote client code must provide all the public methods of the Data class?" Watch "Why the remote client code must provide all the public methods of the Data class?" New topic
Author

Why the remote client code must provide all the public methods of the Data class?

Tiger Meng
Ranch Hand

Joined: Nov 10, 2002
Posts: 32
Why "the remote client code must provide all the public methods of the Data class"?
My sense is that these methods are Remote-method of RMI, is that right?
"This implementation should include a class that implements the same public methods as the suncertify.db.Data class,"
Is the _stub.class auto-generated by JDK meet the requirement?
In this case the book method will put in client-side (in this method call lock-read-modify- unlock).
But can I put book method in server-side (also call lock-read-modify-unlock), and the client-side just call book method and criteriaFind method, then the public methods of Data are no use the client.


SCJP SCJD SCWCD SCMAD
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by mengxiaoxi:
Why "the remote client code must provide all the public methods of the Data class"?
Because if you look at the system in this way:
GUI <==> business code <==> database
Then there are two sensible candidates for your RMI interface: either the GUI <==> business code interface, or the business code <==> database interface.
The requirement forces you into the second choice.
Is the _stub.class auto-generated by JDK meet the requirement?
Yes, it does. Well spotted.
But can I put book method in server-side (also call lock-read-modify-unlock), and the client-side just call book method and criteriaFind method, then the public methods of Data are no use the client.
You answered your own question. If you would put the business code (esp the book function) on the server, then having a Data-like object at the client side makes no sense, worse, would be bad OO.
- Peter
[ November 27, 2002: Message edited by: Peter den Haan ]
Tiger Meng
Ranch Hand

Joined: Nov 10, 2002
Posts: 32
thank you. another further question: can i use data class directly in both client and server side? i notice that candidates often use respectively remoteDataclass and localDataclass which implement a dataInterface. I feel this way waste code! becasuse both local and remote class have a instance of data, method call is boring like:
xxx add(yyy){
data.add(yyy);
}
Why not modify the Data class: make the public methods could be RMI?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
You asked the same question in a new thread -- see my answer there.
Executive summary: yes, but...
- Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why the remote client code must provide all the public methods of the Data class?