/** * This method starts the Crontab and lets the system Continue without wasting more resources. * This method can receive the config File as a variable in web.xml */ public void process() { String propz = "jcrontab.properties"; // String path = getServletConfig().getServletContext() // .getRealPath("."); // System.out.println("Real Path: " + path); String props = getServletConfig().getInitParameter("PROPERTIES_FILE"); if (props == null) { props = propz; } System.out.println(" ................ STARTING JCRONTAB .........................."); System.out.println("................ loading properties from :" + props); System.out.println("................ path :" + (new File(props)).getAbsolutePath()); // Load the servlet config parameters // and override the properties Properties propObj = new Properties(); try { InputStream input = createPropertiesStream(props); propObj.load(input); } catch (IOException ioe) { ioe.printStackTrace(); } ServletConfig c = getServletConfig(); Enumeration keys = c.getInitParameterNames(); while (keys.hasMoreElements()) { String key = (String) keys.nextElement(); propObj.setProperty(key, c.getInitParameter(key)); } crontab = Crontab.getInstance(); try { ShutdownHook(); crontab.init(propObj); } catch (Exception e) { Log.error(e.toString(), e); } }
public void doStop() { Log.info("Shutting down..."); // stops the system in 100 miliseconds :-) crontab.uninit(100); Log.info("Stoped"); }