Search in sources :

Example 1 with FakeServletContext

use of org.directwebremoting.util.FakeServletContext in project ma-core-public by infiniteautomation.

the class StartupUtil method outOfContainerInit.

/**
 * A way to setup DWR outside of any Containers.
 * This method can also serve as a template for in container code wanting
 * to get DWR setup. Callers of this method should clean up after themselves
 * by calling {@link #outOfContainerDestroy(Container)}
 * @return A new initialized container.
 * @throws ServletException If the setup fails.
 */
public Container outOfContainerInit() throws ServletException {
    try {
        ServletConfig servletConfig = new FakeServletConfig("test", new FakeServletContext());
        ServletContext servletContext = servletConfig.getServletContext();
        StartupUtil.setupLogging(servletConfig, null);
        StartupUtil.logStartup(servletConfig);
        DefaultContainer container = ContainerUtil.createDefaultContainer(servletConfig);
        ContainerUtil.setupDefaultContainer(container, servletConfig);
        WebContextBuilder webContextBuilder = StartupUtil.initWebContext(servletConfig, servletContext, container);
        StartupUtil.initServerContext(servletConfig, servletContext, container);
        ContainerUtil.prepareForWebContextFilter(servletContext, servletConfig, container, webContextBuilder, null);
        ContainerUtil.configureContainerFully(container, servletConfig);
        ContainerUtil.publishContainer(container, servletConfig);
        return container;
    } catch (ServletException ex) {
        throw ex;
    } catch (Exception ex) {
        throw new ServletException(ex);
    }
}
Also used : ServletException(javax.servlet.ServletException) FakeServletContext(org.directwebremoting.util.FakeServletContext) ServletConfig(javax.servlet.ServletConfig) FakeServletConfig(org.directwebremoting.util.FakeServletConfig) FakeServletContext(org.directwebremoting.util.FakeServletContext) ServletContext(javax.servlet.ServletContext) WebContextBuilder(org.directwebremoting.WebContextFactory.WebContextBuilder) ServletException(javax.servlet.ServletException) FakeServletConfig(org.directwebremoting.util.FakeServletConfig)

Aggregations

ServletConfig (javax.servlet.ServletConfig)1 ServletContext (javax.servlet.ServletContext)1 ServletException (javax.servlet.ServletException)1 WebContextBuilder (org.directwebremoting.WebContextFactory.WebContextBuilder)1 FakeServletConfig (org.directwebremoting.util.FakeServletConfig)1 FakeServletContext (org.directwebremoting.util.FakeServletContext)1