--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2011/04/04 10:56:44 1255 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java 2011/04/20 05:25:48 1331 @@ -17,6 +17,7 @@ import dk.thoerup.circuitbreaker.CircuitBreaker; import dk.thoerup.circuitbreaker.CircuitBreakerManager; import dk.thoerup.traininfoservice.Statistics; +import dk.thoerup.traininfoservice.TraininfoSettings; import dk.thoerup.traininfoservice.db.StationDAO; public class TimetableFetcher { @@ -29,15 +30,13 @@ Logger logger = Logger.getLogger(TimetableFetcher.class.getName()); + + TraininfoSettings settings; - private boolean useAzureSite; - private int replyTimeout; - - public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) { - useAzureSite = azureSite; - this.replyTimeout = replyTimeout; + public TimetableFetcher(TraininfoSettings settings) { + this.settings = settings; - cache = new TimeoutMap(cacheTimeout); + cache = new TimeoutMap( settings.getCacheTimeout() ); stationCache = new TimeoutMap( 3*60*60*1000 ); } @@ -57,11 +56,11 @@ } TimetableBean lookupTimetable(String trainID, String type) throws Exception { - if (useAzureSite == true ){ + if (settings.getUseAzureSite() == true ){ return lookupTimetableAzureSite(trainID, type); } else { - return lookupTimetableWwwSite(trainID, type); + return lookupTimetableMobileSite(trainID, type); } } @@ -88,7 +87,7 @@ String url = "http://trafikinfo.bane.dk/TrafikInformation/Ruteplan/" + trainID; logger.fine("URL:" + url); - JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout); + JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() ); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); Document doc = (Document) breaker.invoke(wrapper); @@ -171,6 +170,11 @@ return timetableBean; } + TimetableBean lookupTimetableMobileSite(String trainID, String type) throws Exception { + return new TimetableBean(); //dummy skeleton method + } + + @Deprecated TimetableBean lookupTimetableWwwSite(String trainID, String type) throws Exception { TimetableBean timetableBean = new TimetableBean(); @@ -178,7 +182,7 @@ logger.fine("URL:" + url); - JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout); + JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() ); CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk"); Document doc = (Document) breaker.invoke(wrapper);