Exercises

  • Exercise 21-1. Modify the remote banking example in this chapter so that bank customers are allowed to borrow money from the bank against some maximum line of credit, and so they can also apply money from their account to pay off their debt. Add borrow( ) and repay( ) methods to the RemoteBank interface, implement these methods with RemoteBankServer or PersistentBankServer, and modify the client so that it can call these methods when the user requests them.

  • Exercise 21-2. The rmiregistry program provides a simple name service for RMI programs; it allows servers to register names for the remote objects they serve, and it allows clients to look up those remote objects by name. Because it is a global registry, shared by any number of remote services, there is a possibility of name collisions. For this reason, if a service needs to define names for a number of remote objects, it should usually provide its own custom registry. That way, a client can use the global registry to look up the service’s custom naming registry, and then it can use this custom registry to look up particular named objects for that service.

    Use RMI to write a server that provides such a custom naming service. It should export remote methods that correspond to the bind( ), rebind( ), unbind( ), and lookup( ) methods of the Naming class. You will probably want to use a java.util.Map object to associate names with remote objects.

  • Exercise 21-3. The MUD example of this chapter uses remote objects to represent ...

Get Java Examples in a Nutshell, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.