Java Reference
In-Depth Information
throws RemoteException;
* Return a list of the players on a team, where the
* team is identified by name.
* @param forTeam a {@link String} that is the name
* of the team whose roster is desired
* @return a {@link Set} of {@link Player} objects
* that are the players on this team
* @throws RemoteException if there is a problem
* with the underlying network or the RMI system
Set<Player> getRoster(String forTeam)
throws RemoteException;
There are two things to notice about this interface. The first is that the interface extends
java.rmi.Remote . This is a marker interface, indicating that the interface that extends it will
be used to define methods that will be made available to calls from other address spaces. We
will look at how this happens when we look at the implementation of our interface. As a mark-
er interface, it doesn't add any methods to the interface extending it.
The second thing to notice is that the two methods in the interface, recordGame() and
getRoster() , are declared as throwing java.rmi.RemoteException . Any remotely access-
ible method in RMI needs to declare itself as throwing this exception (or a super-type of this
exception, such as ). This is not an exception that will be thrown by
the implementation of the server code, but rather an exception that will be thrown by the RMI
runtime to indicate a problem with the network or with the internal workings of RMI. This
exception reminds the programmer that the call being made is not a local call, but may in fact
be subject to all of the failure modes of a networking call, including partial failure and long
latency. It is up to the application to figure out how it wants to deal with such failures, but the
fact that the exception is a user-level exception means that some thought has to be given to
handling such failure. Any call to this method will need to be in a try…catch block, with an
exception handler supplied for the RemoteException .
The first method defined in this interface takes a single argument of type BoxScore . This ar-
gument is meant to be a shorthand way of encapsulating all of the relevant statistics for a game
in a single object. Our definition of this interface is:
Search WWH ::

Custom Search