This preview shows page 1-2-3-4 out of 13 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 13 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC 433, Michael Hicks, U. Maryland1CMSC433, Spring 2002Programming Language Technology and Paradigms Java RMIMichael HicksNovember 21, 2002CMCS 433, Fall 2002 -Michael Hicks2Different Approaches to Distributed Computation• High-performance, parallel scientific apps•Connecting via sockets–custom protocols for each application•RPC/DCOM/CORBA/RMI–make what looks like a normal function call–function is actually invoked on another machine–Arguments are marshalledfor transport–Value is unmarshalledon returnCMSC 433, Michael Hicks, U. Maryland2CMCS 433, Fall 2002 -Michael Hicks3Remote Method Invocation•Easy way to get distributed computation•Have stub for remote object–calls to stub get translated into network call•Arguments and return values can be passed over network CMCS 433, Fall 2002 -Michael Hicks4Remote Objects and Interfaces•Remote Objects are those that can be referenced remotely–extends java.rmi.UnicastRemoteObject–constructor throws java.rmi.RemoteException• Remote interfaces describe services that can be provided remotely–extends java.rmi.Remote interface–all methods throw java.rmi.RemoteExceptionCMSC 433, Michael Hicks, U. Maryland3CMCS 433, Fall 2002 -Michael Hicks5rmic- RMI Compiler•Generates stub code for a class–For 1.1, also generates skeleton class–skeleton not needed for 1.2+•Generates stubs for all methods declared in the class’s Remote interface–other methods don’t get a stubCMCS 433, Fall 2002 -Michael Hicks6Passing arguments•Can pass arbitrary values as arguments•Can return arbitrary values as results•To pass a value, it must either be–Serializable, or–Remote•Passing the same Serializable object in different calls–will materialize different objects at receiverCMSC 433, Michael Hicks, U. Maryland4CMCS 433, Fall 2002 -Michael Hicks7Downloading code•When you pass a reference to a remote class– receiver needs stub class•When you pass a reference to serializable class–receiver needs class•Annotate ref’s with RMI codebase– where code can be loaded fromCMCS 433, Fall 2002 -Michael Hicks8SecurityManager•Must install some Security Manager to allow download of classes from RMI codebase•Can use RMISecurityManagerSystem.setSecurityManager(new RMISecurityManager());•Modify policy file to grant permissionsCMSC 433, Michael Hicks, U. Maryland5CMCS 433, Fall 2002 -Michael Hicks9Naming.lookup•Naming.lookup is used to bootstrap RMI communication–Get your first reference to a remote object•Run an RMI Registry–a separate Java VM (command rmiregistry)–listens to a particular port (default 1099)•Can bind/unbind/rebind name on localhost•Can lookup name on any hostCMCS 433, Fall 2002 -Michael Hicks10RMI Chat server•Server –runs the chat room•Client–participant in chat room–receives messages from others in room•Connection–uniquely identifies a client–used to speak in chat roomCMSC 433, Michael Hicks, U. Maryland6CMCS 433, Fall 2002 -Michael Hicks11Serverinterface Server extends Remote {Connection logon(String name, Client c)throws RemoteException; }CMCS 433, Fall 2002 -Michael Hicks12Connectioninterface Connection extends Remote {/** Say to everyone */void say(Stringmsg)throwsRemoteException;/ ** Say to one person */void say(String who, String msg)throwsRemoteException;String [] who()throws RemoteException;void logoff()throwsRemoteException;}CMSC 433, Michael Hicks, U. Maryland7CMCS 433, Fall 2002 -Michael Hicks13Clientinterface Client extends Remote {void said(String who, String msg)throws RemoteException;void whoChanged(String [] who)throws RemoteException;}CMCS 433, Fall 2002 -Michael Hicks14Server’s Remote Object creationServerImplServer s = new ServerImpl();HostedRemote ObjectssServerObject added to table because it implements extension of RemoteinterfaceCMSC 433, Michael Hicks, U. Maryland8CMCS 433, Fall 2002 -Michael Hicks15Remote Object registryServerImplNaming.rebind(“ChatServer”, s);HostedRemote ObjectsChatServerServerImplStubsServerRMI RegistryCMCS 433, Fall 2002 -Michael Hicks16Client’s Remote Object creationClientImplClient c = new ClientImpl();HostedRemote ObjectscClientClient object also implements extension of RemoteinterfaceCMSC 433, Michael Hicks, U. Maryland9CMCS 433, Fall 2002 -Michael Hicks17Client looks up ServerServer s = (Server) Naming.lookup(“//host/ChatServer”);sServerImplStubHostedRemote ObjectsServerImplClientServerRMI RegistryChatServerServerImplStublookupreturnsstubCMCS 433, Fall 2002 -Michael Hicks18After lookup finishedClientImplHostedRemote ObjectscsServerImplStubHostedRemote ObjectsServerImplClientServerCMSC 433, Michael Hicks, U. Maryland10CMCS 433, Fall 2002 -Michael Hicks19Invokes remote Server methodConnectionconn= s.logon(“Bill”, c);sServerImplStubClientStub code for remote logon callString “Bill”Stub for cMethod: logon… to server processlogonClientImplcCMCS 433, Fall 2002 -Michael Hicks20Receives remote callServerSkeleton code for remote logon callString “Bill”Stub for cMethod: logon… from client processHostedRemote ObjectsServerImpl“Bill”ClientImplStub cunmarshalledargumentsCMSC 433, Michael Hicks, U. Maryland11CMCS 433, Fall 2002 -Michael Hicks21Executes the callServerHostedRemote ObjectsServerImpl“Bill”ClientImplStub ccall logon …ConnectionImpl… create new Connection objectCMCS 433, Fall 2002 -Michael Hicks22Returns the resultServerHostedRemote ObjectsServerImplConnectionImpl… return this as the resultSkeleton code for remote logon callStub for connReturn value:… to client processCMSC 433, Michael Hicks, U. Maryland12CMCS 433, Fall 2002 -Michael Hicks23Receives the resultsServerImplStubClientStub code for remote logon callStub for connReturn value:… from server processlogonConn Stubconnunmarshalledreturn valueThis document was created with Win2PDF available at http://www.daneprairie.com.The unregistered version of Win2PDF is for evaluation or non-commercial use


View Full Document

UMD CMSC 433 - Java RMI

Documents in this Course
Trace 1

Trace 1

62 pages

Reflection

Reflection

137 pages

Testing

Testing

25 pages

Paradigms

Paradigms

10 pages

Testing

Testing

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Java RMI

Java RMI

17 pages

Trace 1

Trace 1

46 pages

Jini

Jini

4 pages

Final

Final

15 pages

Testing

Testing

16 pages

Load more
Download Java RMI
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Java RMI and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Java RMI 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?