This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes How to extends Data class at RMI? 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 "How to extends Data class at RMI?" Watch "How to extends Data class at RMI?" New topic
Author

How to extends Data class at RMI?

Michael Deng
Greenhorn

Joined: Dec 05, 2000
Posts: 12
In RMI, I need to create:
1) a interface which extends java.rmi.Remote
2) a class which implement this interface and extends
UnicastRemoteObject
But, where can I extends Data class at FBN project? or I need to copy and paste the codes from Data.java to the implemention class?
Thanks
Michael
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Michael,
Create a separate server class extending UnicastRemoteObject (which implements Remote). This is the remote server that clients somehow attach to. This class can then access Data on behalf of the client. You probably don't want to make Data (or a subclass of it) remoteable. After all, Data will have to be used locally at the client as well, to meet the local-mode requirement.
Jerry
Rajesh Chandrasekaran
Greenhorn

Joined: Jan 08, 2001
Posts: 6
Jerry,
Separating the Data class from the Remote implementation
is a good option to iprovide modular design and to avoid code redundancy.
But the requirement for "Data Client" says:
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.
Does it means we have to directly implement all the
public methods of Data in the client, without any wrap arounds ?
Please comment.,
-Rajesh.
Jerry Pulley
Ranch Hand

Joined: Sep 19, 2000
Posts: 221
Rajesh,
I certainly wouldn't reimplement the Data methods in the client class. The way I did local/remote transparency was with an adapter class. In local mode, the adapter holds a reference to a local instance of Data (actually, a subclass of Data). In remote mode, the adapter holds a remote reference to the server. In either case, the client just calls the adapter.
Jerry
Rajesh Chandrasekaran
Greenhorn

Joined: Jan 08, 2001
Posts: 6
Jerry,
Thanks !
Thats exactly what I had in my mind.
To have a Client and server implementations holding local and
remote references to the "Data" implementations on either side.
The actual Data (or its subclass) is hidden.
-Rajesh.
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
Originally posted by Jerry Pulley:
Michael,
Create a separate server class extending UnicastRemoteObject (which implements Remote). This is the remote server that clients somehow attach to. This class can then access Data on behalf of the client. You probably don't want to make Data (or a subclass of it) remoteable. After all, Data will have to be used locally at the client as well, to meet the local-mode requirement.
Jerry

hi,
i have a Remote interface and my Data class implements Remote Interface.I have a server class ,which implements Remote Interface and extends UnicastRemoteObject.In this server class , i need a reference to Data class ,so i can write implementation of methods that i am implementing with Remote Interface, but i do not like to make this Data object as remotable.How can i do this.
thanks in advance
kanwal
 
GeeCON Prague 2014
 
subject: How to extends Data class at RMI?