--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/02/08 19:12:15 588 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureFetcher.java 2010/05/05 20:11:03 711 @@ -6,6 +6,7 @@ import java.util.Map; import java.util.logging.Logger; +import com.gargoylesoftware.htmlunit.BrowserVersion; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.DomNodeList; import com.gargoylesoftware.htmlunit.html.HtmlElement; @@ -15,6 +16,7 @@ import dk.thoerup.circuitbreaker.CircuitBreakerManager; import dk.thoerup.traininfoservice.StationBean; import dk.thoerup.traininfoservice.StationDAO; +import dk.thoerup.traininfoservice.Statistics; public class DepartureFetcher { @@ -42,6 +44,7 @@ list = lookupDepartures(stationID); cache.put(stationID, list); } else { + Statistics.getInstance().incrementDepartureCacheHits(); logger.info("Departure: Cache hit " + stationID); //remove before production } return list; @@ -81,7 +84,7 @@ List departureList = new ArrayList(); - final WebClient webClient = new WebClient(); + final WebClient webClient = new WebClient( BrowserVersion.FIREFOX_3 ); webClient.setTimeout(2500); webClient.setJavaScriptEnabled(false); @@ -131,12 +134,15 @@ String note = extractNote( fields.get(7) ); departure.setNote(note); + departure.setType(type); + departureList.add(departure); } } } else { logger.warning("No departures found for station=" + stationcode + ", type=" + type); } + webClient.closeAllWindows(); return departureList; } @@ -145,7 +151,7 @@ List departureList = new ArrayList(); - final WebClient webClient = new WebClient(); + final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3); webClient.setTimeout(2500); webClient.setJavaScriptEnabled(false); @@ -201,6 +207,8 @@ } else { logger.warning("No departures found for station=" + stationcode + ", type=" + type); } + webClient.closeAllWindows(); + return departureList; } @@ -249,7 +257,6 @@ } - return number; }