1 package ejava.examples.asyncmarket.web; 2 3 import javax.ejb.EJB; 4 import javax.ejb.ScheduleExpression; 5 6 import javax.servlet.ServletException; 7 import javax.servlet.http.HttpServlet; 8 9 import org.apache.commons.logging.Log; 10 import org.apache.commons.logging.LogFactory; 11 12 import ejava.examples.asyncmarket.AuctionMgmt; 13 import ejava.examples.asyncmarket.ejb.AuctionMgmtLocal; 14 15 @SuppressWarnings("serial") 16 public class InitServlet extends HttpServlet { 17 private static Log log = LogFactory.getLog(InitServlet.class); 18 @EJB(beanInterface=AuctionMgmtLocal.class) 19 private AuctionMgmt auctionMgmt; 20 21 public void init() throws ServletException { 22 log.debug("init() called, auctionMgmt=" + auctionMgmt); 23 try { 24 if (auctionMgmt == null) { 25 log.error("auctionMgmt is null, timers will not be initialized"); 26 } 27 else { 28 log.debug("calling initTimers"); 29 ScheduleExpression schedule = new ScheduleExpression(); 30 schedule.second("*/10"); 31 schedule.minute("*"); 32 schedule.hour("*"); 33 schedule.dayOfMonth("*"); 34 schedule.month("*"); 35 schedule.year("*"); 36 auctionMgmt.initTimers(schedule); 37 } 38 } 39 catch (Exception ex) { 40 log.fatal("error initializing", ex); 41 throw new ServletException("error initializing", ex); 42 } 43 } 44 }