O'Reilly logo

Java Examples in a Nutshell, 3rd Edition by David Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Remote MUD Interfaces

Example 21-4 is a Mud class that serves as a placeholder for inner classes and interfaces (and one constant) used by the rest of the MUD system. Most importantly, Mud defines three Remote interfaces: RemoteMudServer, RemoteMudPerson, and RemoteMudPlace. These define the remote methods that are implemented by the MudServer, MudPerson, and MudPlace objects, respectively.

Example 21-4. Mud.java

package je3.rmi; import java.rmi.*; import java.util.Vector; import java.io.IOException; /** * This class defines three nested Remote interfaces for use by our MUD game. * It also defines a bunch of exception subclasses, and a constant string * prefix used to create unique names when registering MUD servers **/ public class Mud { /** * This interface defines the exported methods of the MUD server object **/ public interface RemoteMudServer extends Remote { /** Return the name of this MUD */ public String getMudName( ) throws RemoteException; /** Return the main entrance place for this MUD */ public RemoteMudPlace getEntrance( ) throws RemoteException; /** Look up and return some other named place in this MUD */ public RemoteMudPlace getNamedPlace(String name) throws RemoteException, NoSuchPlace; /** * Dump the state of the server to a file so that it can be restored * later. All places, and their exits and things, are dumped, but the * "people" in them are not. **/ public void dump(String password, String filename) throws RemoteException, BadPassword, IOException; } ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required