/[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 1255 by torben, Mon Apr 4 10:56:44 2011 UTC revision 1355 by torben, Wed Apr 20 19:01:33 2011 UTC
# Line 16  import dk.thoerup.android.traininfo.comm Line 16  import dk.thoerup.android.traininfo.comm
16  import dk.thoerup.android.traininfo.common.TimetableEntry;  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;
19    import dk.thoerup.genericjavautils.TimeoutMap;
20  import dk.thoerup.traininfoservice.Statistics;  import dk.thoerup.traininfoservice.Statistics;
21    import dk.thoerup.traininfoservice.TraininfoSettings;
22  import dk.thoerup.traininfoservice.db.StationDAO;  import dk.thoerup.traininfoservice.db.StationDAO;
23    
24  public class TimetableFetcher {  public class TimetableFetcher {
# Line 29  public class TimetableFetcher { Line 31  public class TimetableFetcher {
31                    
32                    
33          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());          Logger logger = Logger.getLogger(TimetableFetcher.class.getName());
34    
35            TraininfoSettings settings;    
36                    
37          private boolean useAzureSite;          public TimetableFetcher(TraininfoSettings settings) {
38          private int replyTimeout;                  this.settings = settings;
           
         public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) {  
                 useAzureSite = azureSite;  
                 this.replyTimeout = replyTimeout;  
39                                    
40                  cache = new TimeoutMap<String,TimetableBean>(cacheTimeout);                  cache = new TimeoutMap<String,TimetableBean>( settings.getCacheTimeout() );
41                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );
42          }          }
43                    
# Line 57  public class TimetableFetcher { Line 57  public class TimetableFetcher {
57          }          }
58                    
59          TimetableBean lookupTimetable(String trainID, String type) throws Exception {          TimetableBean lookupTimetable(String trainID, String type) throws Exception {
60                  if (useAzureSite == true ){                  if (settings.getUseAzureSite() == true ){
61                          return lookupTimetableAzureSite(trainID, type);                          return lookupTimetableAzureSite(trainID, type);
62                                                    
63                  } else {                  } else {
64                          return lookupTimetableWwwSite(trainID, type);                          return lookupTimetableMobileSite(trainID, type);
65                  }                  }
66          }          }
67                    
# Line 88  public class TimetableFetcher { Line 88  public class TimetableFetcher {
88                  String url = "http://trafikinfo.bane.dk/TrafikInformation/Ruteplan/" + trainID;                                  String url = "http://trafikinfo.bane.dk/TrafikInformation/Ruteplan/" + trainID;                
89                  logger.fine("URL:" + url);                  logger.fine("URL:" + url);
90                            
91              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() );
92              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
93                            
94              Document doc = (Document) breaker.invoke(wrapper);              Document doc = (Document) breaker.invoke(wrapper);
# Line 171  public class TimetableFetcher { Line 171  public class TimetableFetcher {
171                  return timetableBean;                  return timetableBean;
172          }          }
173    
174            TimetableBean lookupTimetableMobileSite(String trainID, String type) throws Exception {
175                    return new TimetableBean(); //dummy skeleton method
176            }
177            
178            @Deprecated
179          TimetableBean lookupTimetableWwwSite(String trainID, String type) throws Exception {                      TimetableBean lookupTimetableWwwSite(String trainID, String type) throws Exception {            
180                  TimetableBean timetableBean = new TimetableBean();                  TimetableBean timetableBean = new TimetableBean();
181                                    
# Line 178  public class TimetableFetcher { Line 183  public class TimetableFetcher {
183                  logger.fine("URL:" + url);                  logger.fine("URL:" + url);
184    
185                            
186              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , replyTimeout);              JsoupInvocation wrapper = new JsoupInvocation( new URL(url) , settings.getReplyTimeout() );
187              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("banedk");
188                            
189              Document doc = (Document) breaker.invoke(wrapper);              Document doc = (Document) breaker.invoke(wrapper);

Legend:
Removed from v.1255  
changed lines
  Added in v.1355

  ViewVC Help
Powered by ViewVC 1.1.20