Methods Summary |
---|
protected void | handleRequest()
String request = requestReader.readLine();
Movie movie = cache.getMovieByTitle(request);
System.out.println("Movie: " + movie.getTitle());
|
protected void | handleUpdate()
String update = updateReader.readLine();
StringTokenizer tokenizer = new StringTokenizer(update, ";");
String movieName = tokenizer.nextToken();
String webSite = tokenizer.nextToken();
cache.updateWebSite (movieName, webSite);
|
protected java.io.BufferedReader | openReader(java.lang.String urlName)
try {
URL url = new URL(urlName);
InputStream is = url.openStream();
Reader r = new InputStreamReader(is);
return new BufferedReader(r);
} catch (Exception ex) {
return null;
}
|
protected void | serviceReaders()
boolean done = false;
boolean lastTime = false;
try {
while (!done) {
if (updateReader.ready()) {
handleUpdate();
done = false;
lastTime = false;
} else if (requestReader.ready()) {
handleRequest();
done = false;
lastTime = false;
} else {
try {
Thread.sleep (timeoutMillis);
if (lastTime) done = true;
lastTime = true;
} catch (InterruptedException ex) {
done = true;
}
}
}
} catch (Exception ex) {
return;
}
|