8 |
import java.util.List; |
import java.util.List; |
9 |
import java.util.logging.Logger; |
import java.util.logging.Logger; |
10 |
|
|
11 |
import com.gargoylesoftware.htmlunit.ProxyConfig; |
|
12 |
import com.gargoylesoftware.htmlunit.WebClient; |
import com.gargoylesoftware.htmlunit.WebClient; |
13 |
import com.gargoylesoftware.htmlunit.html.DomNodeList; |
import com.gargoylesoftware.htmlunit.html.DomNodeList; |
14 |
import com.gargoylesoftware.htmlunit.html.HtmlElement; |
import com.gargoylesoftware.htmlunit.html.HtmlElement; |
19 |
public class DepartureFetcher { |
public class DepartureFetcher { |
20 |
|
|
21 |
Logger logger = Logger.getLogger(DepartureFetcher.class.getName()); |
Logger logger = Logger.getLogger(DepartureFetcher.class.getName()); |
22 |
|
|
23 |
|
TimeoutCache<Integer, List<DepartureBean>> cache = new TimeoutCache<Integer,List<DepartureBean>>(120 * 1000); |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
public List<DepartureBean> cachedLookupDepartures(int stationID) throws Exception { |
28 |
|
|
29 |
|
List<DepartureBean> list = cache.get(stationID); |
30 |
|
|
31 |
|
if (list == null) { |
32 |
|
logger.warning("Departure: Cache miss " + stationID); //remove before production |
33 |
|
list = lookupDepartures(stationID); |
34 |
|
cache.put(stationID, list); |
35 |
|
} else { |
36 |
|
logger.warning("Departure: Cache hit " + stationID); //remove before production |
37 |
|
} |
38 |
|
return list; |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
public List<DepartureBean> lookupDepartures(int stationID) throws Exception { |
public List<DepartureBean> lookupDepartures(int stationID) throws Exception { |