*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Packaging questions 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 "Packaging questions" Watch "Packaging questions" New topic
Author

Packaging questions

Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
I'm sort in a jam here.
I'm trying to test the RMI on two machines.
I tried to fingure out what files are needed on the client side.
I basically have DataServer (the interafce that my Data class implement), DataClient, DataInfo, FieldInfo, DatabaseException, Data_stub files.
My question is, if I don't put the DataServer class on the client side, my subsequent DataClient won't compile because my DataClient implements the public methods of Data class by simply calling the method in Data class.
Any ideas?
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
I believe that the interface needs to be present on both the client and server sides - is that your question? I arranged my packages with a suncertify.common and then a client and server package as well, and deploy the common (containing the interface) on both.
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Thank you Paul!
That's what I think too, I just can't confirm it.
One of the problem I have is combining local and RMI DataClient in one class file.
My concern is that, no matter which mode user choice, I'll use the same interface (DataServer: my RMI remote interface) as the access point for my Data class.
When user selects RMI mode, one constructor in my DataClient will instantiate the DataServer ds from RMI server, (Naming.lookup).
When user elects local mode, the other constructor will take a string (db.db location), and instantiate the Data class (new Data()).
The one thing that concerns me is that the DataServer is a interface that extends Remote. Of course, when in local mode, it does do anything special, it's just an ordinary interface.
Is my design ok?
Paul Smiley
Ranch Hand

Joined: Jun 02, 2000
Posts: 244
Sounds about right to me...
joey phillip
Ranch Hand

Joined: Jan 22, 2001
Posts: 40
Andrian,
Are you saying that you are making suncertify.db.Data
class to implement the Remote interface(DataServer) directly?
that means
1) Are you making the Data Class to extend UnicastRemoteObject?
2)Are you modifying the signature of the Data class as throwing RemoteException.
???
with respect
joey
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Yes, in my constructors in Data class, I export the object.
I was going to extend Data class, then make it implement the remote interface, however, it doesn't make sense, since the two class will do essentially the same thing.
joey phillip
Ranch Hand

Joined: Jan 22, 2001
Posts: 40
Andrian,
I am planning to extend my Data class. but i am kind of confused how to extend both UnicastRemoteObject and my Data Class.
with respect
joey
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
Joey:
if you are extending the Data class.
You should use UnicastRemoteObject.exportObject(this); this is design for your type of problems.
IMHO, if you are extending the Data class, you can add the above code in your subclass's constructor.
However, can you please explain why you want to extend the Data class? I'm still confuse as to why people extedning the Data class.
joey phillip
Ranch Hand

Joined: Jan 22, 2001
Posts: 40
Andrian,
I am thinking if i don't extend Data class i have to change all the public method signature to throw RemoteException. Why should we deal with this RemoteException in local mode?
Adrian Yan
Ranch Hand

Joined: Oct 02, 2000
Posts: 688
That's what I thought in the first place. But it really doesn't matter, since your client code will be use in local and network mode, anyway (you are not writing two data client).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packaging questions