--- android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/07/10 10:53:44 978 +++ android/TrainInfoService/src/dk/thoerup/traininfoservice/banedk/DepartureServlet.java 2010/09/02 18:37:49 1026 @@ -22,7 +22,6 @@ import org.w3c.dom.Element; import dk.thoerup.circuitbreaker.CircuitBreakerException; -import dk.thoerup.traininfoservice.StationDAO; import dk.thoerup.traininfoservice.Statistics; /** @@ -45,8 +44,9 @@ boolean useTempSite = Boolean.parseBoolean( getServletContext().getInitParameter("usetempsite") ); int cacheTimeout = Integer.parseInt( getServletContext().getInitParameter("cache_timeout") ); + int replyTimeout = Integer.parseInt( getServletContext().getInitParameter("reply_timeout") ); logger.info( "DepartureServlet, use temp site=" + useTempSite + ", cache=" + cacheTimeout); - fetcher = new DepartureFetcher(useTempSite, cacheTimeout); + fetcher = new DepartureFetcher(useTempSite, cacheTimeout, replyTimeout); } @Override @@ -66,9 +66,7 @@ int station = Integer.parseInt( req.getParameter("station") ); String format = req.getParameter("format"); - DepartureBean beans; - - String stationName = StationDAO.getStationName(station); + DepartureBean beans; try { beans = fetcher.cachedLookupDepartures(station, arrival); @@ -94,14 +92,13 @@ if (format.equalsIgnoreCase("xml")) { resp.setContentType("text/xml"); - resp.getWriter().print( formatXml(beans, stationName, arrival) ); + resp.getWriter().print( formatXml(beans, arrival) ); } else if (format.equalsIgnoreCase("html")) { String advStr = req.getParameter("advanced"); boolean advanced = advStr != null ? Boolean.parseBoolean(advStr) : false; req.setAttribute("advanced", advanced); - req.setAttribute("stationname", stationName ); req.setAttribute("departurebeans", beans); req.setAttribute("stationID", station ); getServletContext().getRequestDispatcher("/ViewDepartures.jsp").forward(req,resp); @@ -111,7 +108,7 @@ } - protected String formatXml(DepartureBean beans, String stationName, boolean arrival) throws ServletException{ + protected String formatXml(DepartureBean beans, boolean arrival) throws ServletException{ String xml = ""; try { DocumentBuilder builder = docBuilderFactory.newDocumentBuilder(); @@ -120,7 +117,7 @@ Document doc = impl.createDocument(null,null,null); Element root = doc.createElement("departureinfo"); - root.setAttribute("station", stationName); + root.setAttribute("station", beans.getStationName()); root.setAttribute("arrival", Boolean.toString(arrival) ); for (String notif : beans.notifications) {