Java Reference
In-Depth Information
* @param forTeam the team whose players are being
* updated
* @param game the {@link BoxScore} object that
* contains the record of the game
*/
private void processScore(Team forTeam, BoxScore game) {
List<UUID> players = game.getPlayers(forTeam.getName());
for (UUID id : players) {
Player toUpdate = forTeam.getPlayer(id);
updatePlayer(toUpdate, game);
}
}
/**
* Update the statistics of a particular player, given
* the boxscore of the game. The actual implementation
* of this method is an exercise left to the reader...
* @param toUpdate
* @param game
*/
private void updatePlayer(Player toUpdate, BoxScore game) {
}
}
This is a pretty straightforward implementation in most respects. Our constructor takes a list
of the Team objects that we assume already exist, which can be used to populate a Hashtable
that we are using to store the association of teams by their names. This list of Team objects
will also let us get to all of the Player objects in which we might be interested. We have an
implementation of the getRoster method that returns a Set of Player objects that are on a
team, and an implementation of the methods needed to process the BoxScore reports of games
that are sent in.
The only really interesting method in this implementation is the private method exportRe-
corder() . It is this method that connects the implementation with the runtime for RMI, and
it is this connection that allows other programs running in other virtual machines (perhaps
on other physical machines) to call our implementation. This is a very short method, but it is
worth looking at in some detail.
The first two lines of the method simply make sure that there is a security manager running.
Java security managers are a dark art (and are not included in this topic, because of its title),
but they do protect the virtual machine on which they are running in a number of ways. Be-
cause RMI makes use of the ability of the JVM to dynamically load code, and because you
Search WWH ::




Custom Search