@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<ThreadInfo> threadInfoList = threadService.listAll(); TemplateView view = new TemplateView("/topnb/ftl/", "thread"); view.addObject("threadInfoList", threadInfoList); view.render(request, response); }
public static void main(String[] args) { if (3 != args.length) { log.error( "you must provide three arguments: server.port, analytics.bindingName, billing.bindingName"); return; } boolean systemsOK = false; String analyticsBindingName = args[1]; String billingBindingName = args[2]; TCPServer tcpServer = null; UDPServer udpServer = null; try { int port = Integer.parseInt(args[0]); tcpServer = new TCPServer(port); ThreadService.execute(tcpServer); log.info("TCPServer started at port " + port); udpServer = new UDPServer(port); ThreadService.execute(udpServer); log.info("UDPServer started at port " + port); systemsOK = true; } catch (NumberFormatException e) { log.error("you must provide an integer value for the port number"); } catch (RejectedExecutionException e) { log.error("could not start TCP or UDP server."); } if (analyticsServer == null || billingServer == null) { systemsOK = false; String registryHost = "localhost"; int registryPort = 0; java.io.InputStream is = ClassLoader.getSystemResourceAsStream("registry.properties"); if (is != null) { java.util.Properties props = new java.util.Properties(); try { props.load(is); registryHost = props.getProperty("registry.host"); registryPort = Integer.parseInt(props.getProperty("registry.port")); Registry registry = LocateRegistry.getRegistry(registryHost, registryPort); analyticsServer = (AnalyticsServer) registry.lookup(analyticsBindingName); log.debug("connected to the analytics server at " + registryHost + ":" + registryPort); billingServer = (BillingServer) registry.lookup(billingBindingName); log.debug("connected to the billing server at " + registryHost + ":" + registryPort); systemsOK = true; } catch (NumberFormatException e) { log.error("registry.port could not be parsed as integer"); } catch (ConnectException e) { log.error("could not connect to the analytics|billing server, is it running?"); } catch (IOException e) { log.error("could not load registry.properties, exception: ", e); } catch (NotBoundException e) { log.error("could not lookup AnalyticsServer|BillingServer"); } finally { try { is.close(); } catch (IOException e) { log.warn("could not close file input stream."); } } } else { log.error("could not load registry.properties."); } } Timer timer = new Timer(); if (systemsOK) { timer = new Timer(); timer.schedule(new AuctionTimer(), 0, 1000); log.info("AuctionTimer started, checking auction every " + 1 + " second(s)"); log.info("All systems running. Type !exit to shutdown."); try { BufferedReader userIn = new BufferedReader(new InputStreamReader(System.in)); String input; while ((input = userIn.readLine()) != null) { if ("!exit".equals(input)) { userIn.close(); break; } } } catch (IOException e) { } } else { log.warn("some systems could not be started, check the log. Now going to shutdown ..."); } ThreadService.shutdown(); timer.cancel(); tcpServer.shutdown(); udpServer.shutdown(); // analyticsServer.shutdown(); log.info("Everything shut down."); System.exit(0); }