1 13 package info.magnolia.cms.servlets; 14 15 import info.magnolia.context.MgnlContext; 16 17 import java.io.IOException ; 18 19 import javax.servlet.ServletException ; 20 import javax.servlet.http.HttpServlet ; 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 24 import org.slf4j.Logger; 25 import org.slf4j.LoggerFactory; 26 27 28 33 public abstract class ContextSensitiveServlet extends HttpServlet { 34 35 38 Logger log = LoggerFactory.getLogger(ContextSensitiveServlet.class); 39 40 44 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException , IOException { 45 initializeContext(req); 46 } 47 48 52 protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException , IOException { 53 initializeContext(req); 54 } 55 56 61 protected void initializeContext(HttpServletRequest request) { 62 if (!MgnlContext.hasInstance()) { 63 MgnlContext.initAsWebContext(request); 64 } 65 else { 66 if (log.isDebugEnabled()) { 68 log.debug("context of thread was already set"); 69 } 70 } 71 } 72 73 } 74 | Popular Tags |