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

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

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

revision 1042 by torben, Mon Sep 13 17:57:31 2010 UTC revision 1048 by torben, Tue Sep 14 06:10:30 2010 UTC
# Line 39  public class MetroFetcher { Line 39  public class MetroFetcher {
39          Logger logger = Logger.getLogger(MetroFetcher.class.getName());          Logger logger = Logger.getLogger(MetroFetcher.class.getName());
40          StationDAO stationDAO = new StationDAO();          StationDAO stationDAO = new StationDAO();
41                    
42          Map<String, MetroBean> cache = new TimeoutMap<String,MetroBean>(1000);          Map<String, MetroBean> cache = new TimeoutMap<String,MetroBean>(60000); //TODO: make metro cache timeout configurable
43                    
44          public MetroBean cachedLookupMetroDepartures(int stationID) throws Exception {          public MetroBean cachedLookupMetroDepartures(int stationID) throws Exception {
45                  final String key = "metro:" + stationID;                  final String key = "metro:" + stationID;
# Line 62  public class MetroFetcher { Line 62  public class MetroFetcher {
62                                                    
63                                    
64                  URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true");                  URL url = new URL("http://www.m.dk/layouts/Metro/Widgets/MetroWidget.ashx?StationId=" + station.getMetro() + "&Congestion=true&Application=MyMetro&Expiration=true");
65                    logger.fine("URL:" + url);
66                                    
67              JsoupInvocation wrapper = new JsoupInvocation( url, 3000);              JsoupInvocation wrapper = new JsoupInvocation( url, 3000);
68              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("metro");              CircuitBreaker breaker = CircuitBreakerManager.getManager().getCircuitBreaker("metro");
# Line 100  public class MetroFetcher { Line 101  public class MetroFetcher {
101                          bean.entries.add(entry);                                                  bean.entries.add(entry);                        
102                  }                  }
103                                                                    
104                  bean.operationInfo = contentElems.get(3).text();                                  bean.operationInfo = contentElems.get(3).text();
105                  bean.plan = contentElems.get(5).text();                  
106                    int planIndex;
107                    if (contentElems.get(4).text().trim().equalsIgnoreCase("stationsinformation")) {
108                            planIndex = 7;
109                    } else {
110                            planIndex = 5;
111                    }
112                            
113                    bean.plan = contentElems.get(planIndex).text();
114                                    
115                  return bean;                  return bean;
116          }          }

Legend:
Removed from v.1042  
changed lines
  Added in v.1048

  ViewVC Help
Powered by ViewVC 1.1.20