1 15 16 package com.jdon.container.finder; 17 18 import javax.servlet.http.HttpServletRequest ; 19 import javax.servlet.ServletContext ; 20 21 import com.jdon.container.ContainerWrapper; 22 import com.jdon.container.startup.ContainerSetupScript; 23 import com.jdon.container.builder.ContainerBuilder; 24 import com.jdon.util.Debug; 25 26 32 public class ServletContainerFinder { 33 private final static String module = ServletContainerFinder.class.getName(); 34 35 private ContainerSetupScript ContainerSetupScript = new ContainerSetupScript(); 36 37 public ContainerWrapper findContainer(HttpServletRequest request) { 38 ServletContext sc = request.getSession().getServletContext(); 39 ContainerWrapper containerWrapper = findContainer(sc); 40 41 return containerWrapper; 42 } 43 44 52 public ContainerWrapper findContainer(ServletContext sc) { 53 ContainerBuilder cb = (ContainerBuilder) sc.getAttribute(ContainerBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME); 54 ContainerWrapper containerWrapper = null; 55 try{ 56 if (!cb.isStartup()) 57 ContainerSetupScript.startup(sc); 58 containerWrapper = cb.getContainerWrapper(); 59 }catch(Exception ex){ 60 Debug.logError("[JdonFramework] not find jdonFramework configuration file" , module); 61 } 62 return containerWrapper; 63 } 64 65 } 66 | Popular Tags |