1 6 7 package org.jfox.deployment.web; 8 9 import java.io.IOException ; 10 11 import org.jfox.jndi.enc.EnterpriseContextFactory; 12 import org.mortbay.http.HttpException; 13 import org.mortbay.http.HttpRequest; 14 import org.mortbay.http.HttpResponse; 15 import org.mortbay.j2ee.J2EEWebApplicationContext; 16 17 20 21 public class JettyWebApplicationContext extends J2EEWebApplicationContext { 22 private static WebEnterpriseContextContainer encFactory = WebEnterpriseContextContainer.getInstance(); 23 24 public JettyWebApplicationContext() { 25 } 26 27 public JettyWebApplicationContext(String s) { 28 super(s); 29 } 30 31 41 public void handle(String s, String s1, HttpRequest httpRequest, HttpResponse httpResponse) throws HttpException, IOException { 42 43 String contextPath = getContextPath(); 45 if(contextPath.startsWith("/")) { 46 contextPath = contextPath.substring(1); 47 } 48 49 EnterpriseContextFactory.EnterpriseType type = EnterpriseContextFactory.enterWeb(); 50 String old = encFactory.setCurrentEnterpriseContextName(contextPath); 51 try { 52 super.handle(s, s1, httpRequest, httpResponse); 53 } 54 finally { 55 encFactory.setCurrentEnterpriseContextName(old); 56 EnterpriseContextFactory.enter(type); 57 } 58 } 59 60 public static void main(String [] args) { 61 62 } 63 } 64 65 | Popular Tags |