wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question about providing data class methods to client 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 "Question about providing data class methods to client" Watch "Question about providing data class methods to client" New topic
Author

Question about providing data class methods to client

dave wav
Greenhorn

Joined: Apr 04, 2002
Posts: 9
Hi, all: I have a question about how to provide methods in data class to client – GUI.
I have an Interface Idata – all public methods from data class plus extra, a class called DataAdapterServer
public class DataAdapterServer extends
UnicastRemoteObject implements Idata {
private Data adaptee;
public DataAdapterServer(Data adaptee)
throws RemoteException {
this.adaptee = adaptee;
}
public DataInfo[] criteriaFind(String
criteria) throws RemoteException{
return adaptee.criteriaFind(criteria);
}
………………..
}
DataAdapterServer wrapped the data class.
at client side, I need call remote methods from the class DataAdapterServer. Because the constructor of DataAdapterServer passed in Data class, my client class needs
import suncertify.db.*; and declare a data object in order to create DataAdapterServer object,
is this the right way to do
(import suncertify.db.* package on client side) or there is a better way to do?
Thank you in advance,
dave
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

First off. Welcome to Javaranch Dave. You will find this place an indespensible resource for the SCJD, and for other Certs.
Now based on your question, I'd say you are basically just starting out on the assignment. You have read Sun's tutorial on RMI, or some similar resource.
Well, you will have an import statement on your client side that is from your db package. This should by in your main class and your controller. This is fine. Some could even argue that by decoupling more, by making more classes you can make it such that the "Facade" that is used by the client is in the client package. But that is symantics. No wait, isn't that the company that makes the virus checker. Ok I digress.
import suncertify.db.*; and declare a data object in order to create DataAdapterServer object,
is this the right way to do

Not really, that server object you have will be bound into the RMI registry with the Data class already instantiated. By the server classes. Meaning your client does not create RMI registry and binding. The client only does a lookup. But you will still have an import of the DataAdapterServer class. In these cases it shows how imports with the .* at the end, are not the best way to go, when all you need is that one class imported.
You will find that your design will grow, and more options will be available to you that you will want to implement, that will change the way you look at this issue right now. But don't rush into it, you are on a good track.
Oh, and read previous posts, and do searches on this forum, it is a great resource with lots of answers.
Mark
[ April 05, 2002: Message edited by: Mark Spritzler ]

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
dave wav
Greenhorn

Joined: Apr 04, 2002
Posts: 9
Mark,
Thank you for your detailed response. I got it,
it returns the interface.
Thanks,
dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about providing data class methods to client