RMI Client Application


The RMI client really benefits from all the work that is being done for it. All it has to do is look up the remote interface in the RMI registry and use that interface. The parameter to Naming.lookup() is a URL in the format noted previously. The return value is a Remote object that must be downcast to the remote interface that you are expecting to match the given name . The remote methods are called exactly the same as any other object method. The only condition that must be dealt with is handling exceptions. The exceptions thrown by Naming.lookup() were listed in the "RMI Registry Naming Service" section. Remember, all remote methods in a J2SE implementation throw RemoteException and therefore must be called from a try block that catches RemoteException . The only other point to note is that you may need to import the remote interface if it is in a different package from the client. The HitCounterClient , in Listing 12.5, shows an example of an RMI client application.



BEA WebLogic Platform 7
BEA WebLogic Platform 7
ISBN: 0789727129
EAN: 2147483647
Year: 2003
Pages: 360

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net