/[projects]/android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java
ViewVC logotype

Diff of /android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/TimetableFetcher.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1060 by torben, Thu Sep 16 13:32:10 2010 UTC revision 1331 by torben, Wed Apr 20 05:25:48 2011 UTC
# Line 12  import org.jsoup.nodes.Document; Line 12  import org.jsoup.nodes.Document;
12  import org.jsoup.nodes.Element;  import org.jsoup.nodes.Element;
13  import org.jsoup.select.Elements;  import org.jsoup.select.Elements;
14    
15    import dk.thoerup.android.traininfo.common.TimetableBean;
16    import dk.thoerup.android.traininfo.common.TimetableEntry;
17  import dk.thoerup.circuitbreaker.CircuitBreaker;  import dk.thoerup.circuitbreaker.CircuitBreaker;
18  import dk.thoerup.circuitbreaker.CircuitBreakerManager;  import dk.thoerup.circuitbreaker.CircuitBreakerManager;
 import dk.thoerup.traininfoservice.StationDAO;  
19  import dk.thoerup.traininfoservice.Statistics;  import dk.thoerup.traininfoservice.Statistics;
20    import dk.thoerup.traininfoservice.TraininfoSettings;
21    import dk.thoerup.traininfoservice.db.StationDAO;
22    
23  public class TimetableFetcher {  public class TimetableFetcher {
24    
# Line 27  public class TimetableFetcher { Line 30  public class TimetableFetcher {
30                    
31                    
32          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());
33    
34            TraininfoSettings settings;    
35                    
36          private boolean useAzureSite;          public TimetableFetcher(TraininfoSettings settings) {
37          private int replyTimeout;                  this.settings = settings;
           
         public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) {  
                 useAzureSite = azureSite;  
                 this.replyTimeout = replyTimeout;  
38                                    
39                  cache = new TimeoutMap<String,TimetableBean>(cacheTimeout);                  cache = new TimeoutMap<String,TimetableBean>( settings.getCacheTimeout() );
40                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );
41          }          }
42                    
# Line 55  public class TimetableFetcher { Line 56  public class TimetableFetcher {
56          }          }
57                    
58          TimetableBean lookupTimetable(String trainID, String type) throws Exception {          TimetableBean lookupTimetable(String trainID, String type) throws Exception {
59                  if (useAzureSite == true ){                  if (settings.getUseAzureSite() == true ){
60                          return lookupTimetableAzureSite(trainID, type);                          return lookupTimetableAzureSite(trainID, type);
61                                                    
62                  } else {                  } else {
63                          return lookupTimetableWwwSite(trainID, type);                          return lookupTimetableMobileSite(trainID, type);
64                  }                  }
65          }          }
66                    
# Line 86  public class TimetableFetcher { Line 87  public class TimetableFetcher {
87                  String url = "http://trafikinfo.bane.dk/TrafikInformation/Ruteplan/" + trainID;                                  String url = "http://trafikinfo.bane.dk/TrafikInformation/Ruteplan/" + trainID;                
88                  logger.fine("URL:" + url);                  logger.fine("URL:" + url);
89                            
90              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() );
91              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
92                            
93              Document doc = (Document) breaker.invoke(wrapper);              Document doc = (Document) breaker.invoke(wrapper);
# Line 169  public class TimetableFetcher { Line 170  public class TimetableFetcher {
170                  return timetableBean;                  return timetableBean;
171          }          }
172    
173            TimetableBean lookupTimetableMobileSite(String trainID, String type) throws Exception {
174                    return new TimetableBean(); //dummy skeleton method
175            }
176            
177            @Deprecated
178          TimetableBean lookupTimetableWwwSite(String trainID, String type) throws Exception {                      TimetableBean lookupTimetableWwwSite(String trainID, String type) throws Exception {            
179                  TimetableBean timetableBean = new TimetableBean();                  TimetableBean timetableBean = new TimetableBean();
180                                    
# Line 176  public class TimetableFetcher { Line 182  public class TimetableFetcher {
182                  logger.fine("URL:" + url);                  logger.fine("URL:" + url);
183    
184                            
185              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() );
186              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
187                            
188              Document doc = (Document) breaker.invoke(wrapper);              Document doc = (Document) breaker.invoke(wrapper);

Legend:
Removed from v.1060  
changed lines
  Added in v.1331

  ViewVC Help
Powered by ViewVC 1.1.20