aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes What does Data Server do&Data Client do? 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 "What does Data Server do&Data Client do?" Watch "What does Data Server do&Data Client do?" New topic
Author

What does Data Server do&Data Client do?

Daniel Chen
Greenhorn

Joined: Oct 07, 2002
Posts: 24
I am doing scjd assignment "Flight by night" and I have some questions.The given instructions.html shows I need write Data Server and Data Client and I don't understand it well.
In my implementation, I wrote a interface incluing all Data public method and let Data extends UnicastRemoteObject implement this interface.I did a simple main method in Data Server to bind a string to Data.But in instructions.html it says "Because multiple concurrent connections may exist, you must make both your server and the suncertify.db classes threadsafe. You may implement your threaded server in more than one class if you choose", what special function do I need to implement?BTW, I use RMI and I have written code in lock, unlock method.
As for Data Client, I let it implement the interface, put lookup stub code into constructor and use it as a class variable.Most public methods just hand up this variable to implement.Am I right?
Paul Sun
Greenhorn

Joined: Aug 26, 2002
Posts: 19
I think you should create thread for each client
on DB Server.
Daniel Chen
Greenhorn

Joined: Oct 07, 2002
Posts: 24
Why create thread for each client connection?I use RMI instead of Socket.Each client call Data stub directly.If I use socket, I think I should create thread to accept client connection.
Padmaja Prasad
Ranch Hand

Joined: Nov 14, 2001
Posts: 76
Hi Daniel,
If you make Data to extend UnicastRemoteObject(Data instanceOf UnicastRemoteObject), then what you are doing for local mode (in which case no sockets should be opened)?
I think the better way is not to let Data be an instanceOf UnicastRemoteObject. You can create another class for remote mode which extend UnicastRemoteObject. Once again, this is only my opinion.
Padmaja
Daniel Chen
Greenhorn

Joined: Oct 07, 2002
Posts: 24
Hi Padmaja,
Thank you for your suggestion.Now I change my architectural.I did a new class RemoteData to extends UnicastRemoteObject.Client use either stub of RemoteData class or Data.But in instructions.html, it says " 'Writing Data Client'
To connect with your server, you should create a client program. This implementation should include a class that implements the same public methods as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration.
".What is the "client program"?Is it same as my RemoteData?But I think RemoteData should be in Server and client only use the stub.Shall I write a new special client class implements the same public methods as Data class to call RemoteData stub or Data?
Padmaja Prasad
Ranch Hand

Joined: Nov 14, 2001
Posts: 76
Originally posted by Daniel Chen:

To connect with your server, you should create a client program. This implementation should include a class that implements the same public methods as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration.
".What is the "client program"?Is it same as my RemoteData?But I think RemoteData should be in Server and client only use the stub.Shall I write a new special client class implements the same public methods as Data class to call RemoteData stub or Data?

Hi Daniel,
I understand it like this: I should have a DataClient class at client side, that has a reference to an object of type DataInterface which may be a RemoteData or Data. I should access the Data methods and db file via this reference. I defined the business logic such as bookFlight(), criteriaSearch() in this file which in turn call the methods in Data/RemoteData thru the Data instance.
I am still not sure whether my implementation is OK. I leave this to others to comment if anything is wrong.
Padmaja
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What does Data Server do&Data Client do?