1 package org.getahead.dwrdemo.cli; 2 3 import javax.servlet.ServletConfig ; 4 import javax.servlet.ServletContext ; 5 6 import org.directwebremoting.WebContextFactory.WebContextBuilder; 7 import org.directwebremoting.impl.ContainerUtil; 8 import org.directwebremoting.impl.DefaultContainer; 9 import org.directwebremoting.impl.DwrXmlConfigurator; 10 import org.directwebremoting.impl.StartupUtil; 11 import org.directwebremoting.util.FakeServletConfig; 12 import org.directwebremoting.util.FakeServletContext; 13 14 18 public class SingletonContainer 19 { 20 24 public static void main(String [] args) throws Exception 25 { 26 WebContextBuilder webContextBuilder = null; 27 28 try 29 { 30 ServletContext servletContext = new FakeServletContext(); 31 ServletConfig servletConfig = new FakeServletConfig("dwr-test", servletContext); 32 33 DefaultContainer container = ContainerUtil.createDefaultContainer(servletConfig); 35 ContainerUtil.setupDefaultContainer(container, servletConfig); 36 37 webContextBuilder = StartupUtil.initWebContext(servletConfig, servletContext, container); 38 StartupUtil.initServerContext(servletConfig, servletContext, container); 39 ContainerUtil.prepareForWebContextFilter(servletContext, servletConfig, container, webContextBuilder, null); 40 41 ContainerUtil.configureFromSystemDwrXml(container); 42 43 DwrXmlConfigurator local = new DwrXmlConfigurator(); 44 local.setClassResourceName("/dwr.xml"); 45 local.configure(container); 46 47 ContainerUtil.configureFromInitParams(container, servletConfig); 48 49 ContainerUtil.publishContainer(container, servletConfig); 50 webContextBuilder.set(null, null, servletConfig, servletContext, container); 51 52 58 } 59 finally 60 { 61 if (webContextBuilder != null) 62 { 63 webContextBuilder.unset(); 64 } 65 } 66 } 67 } 68 | Popular Tags |