


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of java remote method invocation (rmi) in the context of computer network programming. The authors, dave hollinger and wenyuan xu, from the university of south carolina's department of computer science and engineering, explain the differences between rmi and sockets programming, call semantics, finding remote objects, and rmi programming. They also discuss java interfaces, implementing an interface, and server and client details.
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!



reference: Dave Hollinger Wenyuan Xu
Department of Computer Science and Engineering University of South Carolina
Netprog: Java RMI^2
Not concerned with the details of the actual communication between processes – everything is just method calls.
Netprog: Java RMI^3
Method Call Semantics – what does it mean to make a call to a method?
How many times is the method run?
How do we know the method ran at all?
RMI does a great job of providing natural call semantics for remote objects/methods.
Simply a few additional Exceptions that you need to
Netprog: Java RMI^4
It would be awkward if we needed to include a hostname, port and protocol with every remote method invocation. RMI provides a Naming Service through the RMI Registry that simplifies how programs specify the location of remote objects.
This naming service is a JDK utility called
Server App. Skeleton Remote Reference Transport
Client App. Stubs Remote Reference Transport
The client acquires a reference to a remote object.
This part is different from creating a local object.
The client calls methods on the remote object
No (syntactic) difference!
Just need to worry about a few new exceptions.
Netprog: Java RMI^7
Netprog: Java RMI^8
Netprog: Java RMI^9
end result is very similar to multiple inheritence.
Netprog: Java RMI^10
public interface Shape { public getArea(); public draw(); public fill(Color c); }
Create an interface the extends the java.rmi.Remote interface.
This new interface includes all the public methods
import java.rmi.*; public interface MyRemote extends Remote { public int foo(int x) throws RemoteException; public String blah(int y) throws RemoteException;
... }
Netprog: Java RMI^19
Naming.lookup() method takes a string parameter that holds a URL indicating the remote object to lookup. rmi://hostname/objectname
Naming.lookup() returns an Object!
Naming.lookup() can throw
RemoteException
MalformedURLException
Netprog: Java RMI^20
try { Object o = Naming.lookup(“rmi://localhost/ReMath”);
MyRemote r = (MyRemote) o; //... Use r like any other Java object! } catch (RemoteException re) {
... } catch (MalformedURLException up) { throw up; }
RemoteMathImpl: remote integer arithmetic