Java Reference
In-Depth Information
teams.put(t.getName(), t);
}
try {
exportRecorder();
} catch (RemoteException e) {
System.out.println("unable to export stat recorder");
System.exit(1);
}
}
@Override
public void recordGame(BoxScore stats) throws RemoteException {
for (String teamName : stats.getTeams()) {
Team toUpdate = teams.get(teamName);
processScore(toUpdate, stats);
}
}
@Override
public Set<Player> getRoster(String forTeam) throws RemoteException {
return (teams.get(forTeam)).getRoster();
}
/**
* Export a stub object so that calls can be made from
* another address space thorugh that object. This is done
* by putting the stub in a {@link Registry}, which itself
* is a remote object that others can use to find the stub
* that in turn is used to call the remote objects of this
* implementation.
* @throws RemoteException
*/
private void exportRecorder() throws RemoteException {
if (System.getSecurityManager() == null){
System.setSecurityManager(new SecurityManager());
}
registry = LocateRegistry.getRegistry();
myStub = (StatRecorder) UnicastRemoteObject.exportObject(this, 5550);
registry.rebind("Recorder", myStub);
}
/**
* Process the box score for a particular team. This
* implementation will go through the players (by their
* id), and call {@link upDatePlayer} for each player
* that was in the game.
Search WWH ::




Custom Search