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

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

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

revision 1092 by torben, Mon Sep 20 20:11:55 2010 UTC revision 1093 by torben, Tue Sep 21 20:10:46 2010 UTC
# Line 4  package dk.thoerup.traininfoservice.bane Line 4  package dk.thoerup.traininfoservice.bane
4    
5  import java.net.URL;  import java.net.URL;
6  import java.sql.SQLException;  import java.sql.SQLException;
7    import java.util.HashMap;
8  import java.util.Map;  import java.util.Map;
9  import java.util.logging.Level;  import java.util.logging.Level;
10  import java.util.logging.Logger;  import java.util.logging.Logger;
11    
12    import net.sf.jsr107cache.Cache;
13    import net.sf.jsr107cache.CacheException;
14    import net.sf.jsr107cache.CacheManager;
15    
16  import org.jsoup.nodes.Document;  import org.jsoup.nodes.Document;
17  import org.jsoup.nodes.Element;  import org.jsoup.nodes.Element;
18  import org.jsoup.select.Elements;  import org.jsoup.select.Elements;
19    
20    import com.google.appengine.api.memcache.jsr107cache.GCacheFactory;
21    
22  import dk.thoerup.android.traininfo.common.TimetableBean;  import dk.thoerup.android.traininfo.common.TimetableBean;
23  import dk.thoerup.android.traininfo.common.TimetableEntry;  import dk.thoerup.android.traininfo.common.TimetableEntry;
24  import dk.thoerup.circuitbreaker.CircuitBreaker;  import dk.thoerup.circuitbreaker.CircuitBreaker;
# Line 22  import dk.thoerup.traininfoservice.Stati Line 29  import dk.thoerup.traininfoservice.Stati
29  public class TimetableFetcher {  public class TimetableFetcher {
30    
31                                    
32          Map<String, TimetableBean> cache;          Cache cache;
33          Map<String, Integer> stationCache;          Cache stationCache;
34    
35          StationDAO stationDao = new StationDAO();          StationDAO stationDao = new StationDAO();
36                    
# Line 33  public class TimetableFetcher { Line 40  public class TimetableFetcher {
40          private boolean useAzureSite;          private boolean useAzureSite;
41          private int replyTimeout;          private int replyTimeout;
42                    
43            @SuppressWarnings("unchecked")
44          public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) {          public TimetableFetcher(boolean azureSite, int cacheTimeout, int replyTimeout) {
45                  useAzureSite = azureSite;                  useAzureSite = azureSite;
46                  this.replyTimeout = replyTimeout;                  this.replyTimeout = replyTimeout;              
47                    
48            Map props = new HashMap();
49            props.put(GCacheFactory.EXPIRATION_DELTA_MILLIS, cacheTimeout);        
50                    
51                    try {
52                cache = CacheManager.getInstance().getCacheFactory().createCache(props);            
53            } catch (CacheException e) {
54                    logger.log(Level.WARNING, "error creating cache", e);
55            }
56            
57            props = new HashMap();
58            props.put(GCacheFactory.EXPIRATION_DELTA_MILLIS, 3*60*60*1000);        
59                                    
60                  cache = new TimeoutMap<String,TimetableBean>(cacheTimeout);                  try {
61                  stationCache = new TimeoutMap<String,Integer>( 3*60*60*1000 );                          stationCache = CacheManager.getInstance().getCacheFactory().createCache(props);            
62            } catch (CacheException e) {
63                    logger.log(Level.WARNING, "error creating cache", e);
64            }              
65          }          }
66                    
67                    

Legend:
Removed from v.1092  
changed lines
  Added in v.1093

  ViewVC Help
Powered by ViewVC 1.1.20