Search in sources :

Example 1 with SimpleInstanceManager

use of org.apache.tomcat.SimpleInstanceManager in project tomcat by apache.

the class JasperInitializer method onStartup.

@Override
public void onStartup(Set<Class<?>> types, ServletContext context) throws ServletException {
    if (log.isDebugEnabled()) {
        log.debug(Localizer.getMessage(MSG + ".onStartup", context.getServletContextName()));
    }
    // Setup a simple default Instance Manager
    if (context.getAttribute(InstanceManager.class.getName()) == null) {
        context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    }
    boolean validate = Boolean.parseBoolean(context.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM));
    String blockExternalString = context.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
    boolean blockExternal;
    if (blockExternalString == null) {
        blockExternal = true;
    } else {
        blockExternal = Boolean.parseBoolean(blockExternalString);
    }
    // scan the application for TLDs
    TldScanner scanner = newTldScanner(context, true, validate, blockExternal);
    try {
        scanner.scan();
    } catch (IOException | SAXException e) {
        throw new ServletException(e);
    }
    // add any listeners defined in TLDs
    for (String listener : scanner.getListeners()) {
        context.addListener(listener);
    }
    context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME, new TldCache(context, scanner.getUriTldResourcePathMap(), scanner.getTldResourcePathTaglibXmlMap()));
}
Also used : ServletException(javax.servlet.ServletException) TldCache(org.apache.jasper.compiler.TldCache) InstanceManager(org.apache.tomcat.InstanceManager) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) IOException(java.io.IOException) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) SAXException(org.xml.sax.SAXException)

Example 2 with SimpleInstanceManager

use of org.apache.tomcat.SimpleInstanceManager in project jetty.project by eclipse.

the class TestJettyJspServlet method setUp.

@Before
public void setUp() throws Exception {
    JspFactory.setDefaultFactory(new JspFactoryImpl());
    _dir = MavenTestingUtils.getTestResourceDir("base");
    _tester = new ServletTester("/context");
    _tester.getContext().setClassLoader(new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader()));
    ServletHolder jspHolder = _tester.getContext().addServlet(JettyJspServlet.class, "/*");
    jspHolder.setInitParameter("scratchdir", MavenTestingUtils.getTargetTestingDir().getAbsolutePath());
    _tester.getContext().setResourceBase(_dir.getAbsolutePath());
    _tester.getContext().setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    ServletHolder dfltHolder = new ServletHolder();
    dfltHolder.setName("default");
    dfltHolder.setHeldClass(DfltServlet.class);
    _tester.getContext().addServlet(dfltHolder, "/");
    _tester.start();
}
Also used : ServletTester(org.eclipse.jetty.servlet.ServletTester) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) InstanceManager(org.apache.tomcat.InstanceManager) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) JspFactoryImpl(org.apache.jasper.runtime.JspFactoryImpl) URLClassLoader(java.net.URLClassLoader) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) URL(java.net.URL) Before(org.junit.Before)

Example 3 with SimpleInstanceManager

use of org.apache.tomcat.SimpleInstanceManager in project Openfire by igniterealtime.

the class AdminConsolePlugin method createWebAppContext.

private void createWebAppContext() {
    WebAppContext context;
    // Add web-app. Check to see if we're in development mode. If so, we don't
    // add the normal web-app location, but the web-app in the project directory.
    boolean developmentMode = Boolean.getBoolean("developmentMode");
    if (developmentMode) {
        System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode"));
        context = new WebAppContext(contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + "src" + File.separator + "web", "/");
    } else {
        context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/");
    }
    // Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
    final List<ContainerInitializer> initializers = new ArrayList<>();
    initializers.add(new ContainerInitializer(new JasperInitializer(), null));
    context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    // The index.html includes a redirect to the index.jsp and doesn't bypass
    // the context security when in development mode
    context.setWelcomeFiles(new String[] { "index.html" });
    // Make sure the context initialization is done when in development mode
    if (developmentMode) {
        context.addBean(new ServletContainerInitializersStarter(context), true);
    }
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) ServletContainerInitializersStarter(org.eclipse.jetty.annotations.ServletContainerInitializersStarter) ArrayList(java.util.ArrayList) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) JasperInitializer(org.apache.jasper.servlet.JasperInitializer) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager)

Example 4 with SimpleInstanceManager

use of org.apache.tomcat.SimpleInstanceManager in project mysql_perf_analyzer by yahoo.

the class App method createDeployedApplicationInstance.

private WebAppContext createDeployedApplicationInstance(File workDirectory, String deployedApplicationPath) {
    WebAppContext deployedApplication = new WebAppContext();
    deployedApplication.setContextPath(this.getContextPath());
    deployedApplication.setWar(deployedApplicationPath);
    deployedApplication.setAttribute("javax.servlet.context.tempdir", workDirectory.getAbsolutePath());
    deployedApplication.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
    deployedApplication.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
    deployedApplication.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    deployedApplication.addBean(new ServletContainerInitializersStarter(deployedApplication), true);
    // webapp.setClassLoader(new URLClassLoader(new
    // URL[0],App.class.getClassLoader()));
    deployedApplication.addServlet(jspServletHolder(), "*.jsp");
    return deployedApplication;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) InstanceManager(org.apache.tomcat.InstanceManager) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) ServletContainerInitializersStarter(org.eclipse.jetty.annotations.ServletContainerInitializersStarter) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager)

Example 5 with SimpleInstanceManager

use of org.apache.tomcat.SimpleInstanceManager in project Openfire by igniterealtime.

the class HttpBindManager method createBoshHandler.

private void createBoshHandler(ContextHandlerCollection contexts, String boshPath) {
    ServletContextHandler context = new ServletContextHandler(contexts, boshPath, ServletContextHandler.SESSIONS);
    // Ensure the JSP engine is initialized correctly (in order to be able to cope with Tomcat/Jasper precompiled JSPs).
    final List<ContainerInitializer> initializers = new ArrayList<>();
    initializers.add(new ContainerInitializer(new JasperInitializer(), null));
    context.setAttribute("org.eclipse.jetty.containerInitializers", initializers);
    context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
    context.setAllowNullPathInfo(true);
    context.addServlet(new ServletHolder(new HttpBindServlet()), "/*");
    if (isHttpCompressionEnabled()) {
        Filter gzipFilter = new AsyncGzipFilter() {

            @Override
            public void init(FilterConfig config) throws ServletException {
                super.init(config);
                _methods.add(HttpMethod.POST.asString());
                Log.info("Installed response compression filter");
            }
        };
        FilterHolder filterHolder = new FilterHolder();
        filterHolder.setFilter(gzipFilter);
        context.addFilter(filterHolder, "/*", EnumSet.of(DispatcherType.REQUEST));
    }
}
Also used : FilterHolder(org.eclipse.jetty.servlet.FilterHolder) AsyncGzipFilter(org.eclipse.jetty.servlets.AsyncGzipFilter) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) Filter(javax.servlet.Filter) AsyncGzipFilter(org.eclipse.jetty.servlets.AsyncGzipFilter) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) FilterConfig(javax.servlet.FilterConfig) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) JasperInitializer(org.apache.jasper.servlet.JasperInitializer)

Aggregations

InstanceManager (org.apache.tomcat.InstanceManager)8 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)8 JasperInitializer (org.apache.jasper.servlet.JasperInitializer)4 ContainerInitializer (org.eclipse.jetty.plus.annotation.ContainerInitializer)4 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)4 ServletContainerInitializersStarter (org.eclipse.jetty.annotations.ServletContainerInitializersStarter)3 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)3 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 EmailScheduler (com.ifsoft.jmxweb.plugin.EmailScheduler)1 CoreThreadPool (com.javamonitor.openfire.mbeans.CoreThreadPool)1 DatabasePool (com.javamonitor.openfire.mbeans.DatabasePool)1 Openfire (com.javamonitor.openfire.mbeans.Openfire)1 PacketCounter (com.javamonitor.openfire.mbeans.PacketCounter)1 IOException (java.io.IOException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 ArrayList (java.util.ArrayList)1 Filter (javax.servlet.Filter)1 FilterConfig (javax.servlet.FilterConfig)1 ServletException (javax.servlet.ServletException)1