View Javadoc
1 package net.sf.flock.webapp; 2 3 import java.io.File; 4 5 import javax.servlet.ServletConfig; 6 import javax.servlet.ServletContext; 7 import javax.servlet.ServletException; 8 9 import net.sf.flock.FlockResourceException; 10 import net.sf.flock.SubscriptionManagerI; 11 import net.sf.flock.impl.PersistentSubscriptionManager; 12 import net.sf.flock.util.SchedulerThread; 13 import net.sf.tapestry.ApplicationServlet; 14 import org.apache.log4j.LogManager; 15 import org.apache.log4j.Logger; 16 17 public class FlockTapestryServlet extends ApplicationServlet { 18 19 private final static Logger LOGGER = LogManager.getLogger(FlockTapestryServlet.class); 20 21 protected String getApplicationSpecificationPath() { 22 return "/net/sf/flock/webapp/Flock.application"; 23 } 24 25 /*** 26 * @see javax.servlet.Servlet#init(javax.servlet.ServletConfig) 27 */ 28 public void init(ServletConfig config) throws ServletException { 29 super.init(config); 30 31 String home = System.getProperty("flock.home", System.getProperty("user.home")); 32 File storeDirectory = new File( home, ".flock" ); 33 34 final SubscriptionManagerI subscriptionManager; 35 LOGGER.info("Initializing Flock"); 36 try { 37 subscriptionManager = new PersistentSubscriptionManager(storeDirectory); 38 } catch (FlockResourceException e) { 39 throw new ServletException("Error creating subscription manager", e); 40 } 41 42 new SchedulerThread(15, new Runnable() { 43 public void run() { 44 subscriptionManager.refreshAll(); 45 } 46 }).start(); 47 48 ServletContext ctx = this.getServletContext(); 49 ctx.setAttribute("flock.subscriptionManager", subscriptionManager); 50 FlockContext.setSubscriptionManager( subscriptionManager ); 51 52 LOGGER.info("Flock initialized"); 53 } 54 55 } 56

This page was automatically generated by Maven