Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 hi need help on network programming, JAVA RMI question

views
     
TSdawho
post Jun 21 2018, 10:24 AM, updated 6y ago

Enthusiast
*****
Senior Member
752 posts

Joined: Oct 2009



so guys im not trying to be a spoonfeeder but this semester my subject got no class and only online class plus the online tutor not responding at all so need our help guys regarding JAVA RMI

already search google and youtube but still dont understand.

here the question, need some help on getting some idead what i need to do for this JAVA RMI

Modify the class FullMark below to ensure that objects of this class in serial order. Make method getFullMark available via an RMI interface. This method should return an ArrayList containing initialized FullMark objects that are set up by a server program (You have to write it) and available via an implementation object in the RMI registry by the server. The server should store two marks objects in the ArrayList (name dan score) contained within the implementation object. Access this implementation object via a client program and use the methods of the FullMark class to display the surname and examination mark for each of the two FullMark objects.

any help would be appreciated. Thankss
bumpo
post Jun 25 2018, 05:14 PM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


seems like this question is based off some existing materials.
how far have you gone and where are you stuck at exactly?
TSdawho
post Jun 27 2018, 12:15 PM

Enthusiast
*****
Senior Member
752 posts

Joined: Oct 2009



QUOTE(bumpo @ Jun 25 2018, 05:14 PM)
seems like this question is based off some existing materials.
how far have you gone and where are you stuck at exactly?
*
thank you for replying sir...ive search the question on the internet but cant find a thing on it...plus research about the RMI and cant get a clue on trying to do the coding...need help kind sir cry.gif
bumpo
post Jun 27 2018, 12:31 PM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


hmm... i see
lets start from a more basic starting point first. before getting into coding, what do you understand about java rmi?
try to elaborate in as much granular details as you currently know/understand
TSdawho
post Jun 28 2018, 08:16 AM

Enthusiast
*****
Senior Member
752 posts

Joined: Oct 2009



QUOTE(bumpo @ Jun 27 2018, 12:31 PM)
hmm... i see
lets start from a more basic starting point first. before getting into coding, what do you understand about java rmi?
try to elaborate in as much granular details as you currently know/understand
*
from what i can see in java rmi is that it requires a server and client. the server will be on to provide any information that the program has been made to do so. after the client is already on, the client can connect to the server either to get information that is in the server and display it or to key in data and store the data into the server.

this is what i know a little bit of java rmi...if u asking about my foundation of java i really little about it sir
bumpo
post Jun 29 2018, 08:56 AM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


ok, quite correct on your understanding. just missing the rmi registry part.
how the client gets the stuff from the server is via the rmi registry


lets say you want to start a new venture delving into the gossip business
you want to own the gossip but need to allow for your clients to get the gossip as well as share updated gossip
this is why you will setup an interface that extends Remote. it is absolutely critical your methods are able to throw RemoteException coz you'll never know that happens when your gossip is in transit between you and your client.

public interface Gossip extends Remote {
public void printGossip() throws RemoteException;
public String getGossip() throws RemoteException;
public void shareGossip(String gossip) throws RemoteException;
}


next you need to kepoh around to get your gossip materials

public class Kepoh implements Gossip {
private static String gossip;
public void printGossip() throws RemoteException {System.out.println("Gossip of the day is " + getGossip());}
public String getGossip() throws RemoteException {
if (Kepoh.gossip == null)
return "no gossip today";
else
return Kepoh.gossip;
}
public void shareGossip(String gossip) throws RemoteException {Kepoh.gossip = gossip;}
}


now that you have your gossip material after kepohing around, you need to setup a kopitiam to serve it to your clients.
not only that, you also need to advertise your gossip in the yellow pages so that potential clients can find your gossip
lets say your kopitiam address is localhost:9998 and the yellow pages (rmi registry) is localhost:9999 (btw rmi registry default port is 1099)

public class Kopitiam {
public static void main (String[] args) {
try {
Kepoh kepohchi = new Kepoh(); //--- go kepoh to get material for gossip
Gossip gossip = (Gossip) UnicastRemoteObject.exportObject(kepohchi, 9998); //--- open shop for gossip
Registry menu = LocateRegistry.getRegistry(9999); //--- find yellow pages
menu.bind("Gossip", gossip); //--- advertise gossip in yellow pages
System.out.println("Kopitiam ready for business");
} catch (Exception e) {System.err.println("Failed to berkepoh gossip with error " + e);}}}


when kakikepoh (your clients) wants to get gossip, they will check in yellow pages for gossip and get/share/etc

Registry menu = LocateRegistry.getRegistry(9999); //--- find yellow pages
Gossip gossip = (Gossip) menu.lookup("Gossip"); //--- find your gossip
System.out.println("Current gossip is " + gossip.getGossip()); //--- get your gossip
gossip.shareGossip("menu item is 35% off"); //--- share a new gossip
System.out.println("Next gossip is " + gossip.getGossip()); //--- get gossip again to see that new gossip is shared



one external component that you aren't directly building is the yellow pages (rmiregistry).
for it to work correctly, you need to start rmiregistry with the right port "rmiregistry xxxx" where xxxx is the desired port.
do take note as with all things java, you need to ensure path and classpath are setup correctly

1) start rmiregistry
2) start kopitiam
3) start as many variances of kakikepoh as you want

as you can see, all the "processing" of gossip which is implemented via kepoh is done on server side (kopitiam being the server)

TSdawho
post Jul 3 2018, 07:07 AM

Enthusiast
*****
Senior Member
752 posts

Joined: Oct 2009



i will try tro understand...if i dont i will ask back...ty sir

 

Change to:
| Lo-Fi Version
0.0133sec    0.68    5 queries    GZIP Disabled
Time is now: 28th March 2024 - 07:31 PM