Search in sources :

Example 6 with JasperInitializer

use of org.apache.jasper.servlet.JasperInitializer in project Openfire by igniterealtime.

the class JmxWebPlugin method initializePlugin.

public void initializePlugin(PluginManager manager, File pluginDirectory) {
    Log.info("[" + NAME + "] initialize " + NAME + " plugin resources");
    try {
        openfire = new Openfire();
        openfire.start();
        JmxHelper.register(openfire, OBJECTNAME_OPENFIRE);
        Log.info("[" + NAME + "] .. started openfire server detector.");
    } catch (Exception e) {
        Log.debug("cannot start openfire server detector: " + e.getMessage(), e);
    }
    try {
        packetCounter = new PacketCounter();
        packetCounter.start();
        JmxHelper.register(packetCounter, OBJECTNAME_PACKET_COUNTER);
        Log.info("[" + NAME + "] .. started stanza counter.");
    } catch (Exception e) {
        Log.debug("cannot start stanza counter: " + e.getMessage(), e);
    }
    try {
        client = new CoreThreadPool(((ConnectionManagerImpl) XMPPServer.getInstance().getConnectionManager()).getSocketAcceptor());
        client.start();
        JmxHelper.register(client, OBJECTNAME_CORE_CLIENT_THREADPOOL);
        Log.info("[" + NAME + "] .. started client thread pool monitor.");
    } catch (Exception e) {
        Log.debug("cannot start client thread pool monitor: " + e.getMessage(), e);
    }
    try {
        database = new DatabasePool();
        database.start();
        JmxHelper.register(database, OBJECTNAME_DATABASEPOOL);
        Log.info("[" + NAME + "] .. started database pool monitor.");
    } catch (Exception e) {
        Log.debug("cannot start database pool monitor: " + e.getMessage(), e);
    }
    try {
        ContextHandlerCollection contexts = HttpBindManager.getInstance().getContexts();
        try {
            Log.info("[" + NAME + "] starting jolokia");
            WebAppContext context = new WebAppContext(contexts, pluginDirectory.getPath(), "/jolokia");
            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.setWelcomeFiles(new String[] { "index.html" });
            Log.info("[" + NAME + "] starting hawtio");
            WebAppContext context2 = new WebAppContext(contexts, pluginDirectory.getPath() + "/hawtio", "/hawtio");
            final List<ContainerInitializer> initializers2 = new ArrayList<>();
            initializers2.add(new ContainerInitializer(new JasperInitializer(), null));
            context2.setAttribute("org.eclipse.jetty.containerInitializers", initializers2);
            context2.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
            context2.setWelcomeFiles(new String[] { "index.html" });
            if (JiveGlobals.getBooleanProperty("xmpp.jmx.secure", true)) {
                SecurityHandler securityHandler = basicAuth("jmxweb");
                if (securityHandler != null)
                    context.setSecurityHandler(securityHandler);
                SecurityHandler securityHandler2 = basicAuth("jmxweb");
                if (securityHandler2 != null)
                    context2.setSecurityHandler(securityHandler2);
            }
        } catch (Exception e) {
            Log.error("An error has occurred", e);
        }
    } catch (Exception e) {
        Log.error("Error initializing JmxWeb Plugin", e);
    }
    if (JiveGlobals.getBooleanProperty("jmxweb.email.monitoring", true)) {
        Log.info("[" + NAME + "] starting email monitoring");
        emailScheduler = new EmailScheduler();
        emailScheduler.startMonitoring();
        Log.info("[" + NAME + "] started monitoring");
    }
}
Also used : ConnectionManagerImpl(org.jivesoftware.openfire.spi.ConnectionManagerImpl) CoreThreadPool(com.javamonitor.openfire.mbeans.CoreThreadPool) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) PacketCounter(com.javamonitor.openfire.mbeans.PacketCounter) ContextHandlerCollection(org.eclipse.jetty.server.handler.ContextHandlerCollection) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) Openfire(com.javamonitor.openfire.mbeans.Openfire) WebAppContext(org.eclipse.jetty.webapp.WebAppContext) DatabasePool(com.javamonitor.openfire.mbeans.DatabasePool) EmailScheduler(com.ifsoft.jmxweb.plugin.EmailScheduler) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) JasperInitializer(org.apache.jasper.servlet.JasperInitializer)

Example 7 with JasperInitializer

use of org.apache.jasper.servlet.JasperInitializer in project Openfire by igniterealtime.

the class HttpBindManager method createBoshHandler.

/**
 * Creates a Jetty context handler that can be used to expose BOSH (HTTP-Bind) functionality.
 *
 * Note that an invocation of this method will not register the handler (and thus make the related functionality
 * available to the end user). Instead, the created handler is returned by this method, and will need to be
 * registered with the embedded Jetty webserver by the caller.
 *
 * @return A Jetty context handler (never null).
 */
protected Handler createBoshHandler() {
    final int options;
    if (isHttpCompressionEnabled()) {
        options = ServletContextHandler.SESSIONS | ServletContextHandler.GZIP;
    } else {
        options = ServletContextHandler.SESSIONS;
    }
    final ServletContextHandler context = new ServletContextHandler(null, "/http-bind", options);
    // 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());
    // Generic configuration of the context.
    context.setAllowNullPathInfo(true);
    // Add the functionality-providers.
    context.addServlet(new ServletHolder(new HttpBindServlet()), "/*");
    // Add compression filter when needed.
    if (isHttpCompressionEnabled()) {
        final GzipHandler gzipHandler = context.getGzipHandler();
        gzipHandler.addIncludedPaths("/*");
        gzipHandler.addIncludedMethods(HttpMethod.POST.asString());
    }
    return context;
}
Also used : SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) GzipHandler(org.eclipse.jetty.server.handler.gzip.GzipHandler) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler) JasperInitializer(org.apache.jasper.servlet.JasperInitializer) SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager)

Example 8 with JasperInitializer

use of org.apache.jasper.servlet.JasperInitializer in project tomcat by apache.

the class TestStandardContext method testTldListener.

@Test
public void testTldListener() throws Exception {
    // Set up a container
    Tomcat tomcat = getTomcatInstance();
    File docBase = new File("test/webapp-3.0");
    Context ctx = tomcat.addContext("", docBase.getAbsolutePath());
    ctx.addServletContainerInitializer(new JasperInitializer(), null);
    // Start the context
    tomcat.start();
    // Stop the context
    ctx.stop();
    String log = TesterTldListener.getLog();
    Assert.assertTrue(log, log.contains("PASS-01"));
    Assert.assertTrue(log, log.contains("PASS-02"));
    Assert.assertFalse(log, log.contains("FAIL"));
}
Also used : ServletContext(jakarta.servlet.ServletContext) Context(org.apache.catalina.Context) Tomcat(org.apache.catalina.startup.Tomcat) File(java.io.File) JasperInitializer(org.apache.jasper.servlet.JasperInitializer) TomcatBaseTest(org.apache.catalina.startup.TomcatBaseTest) Test(org.junit.Test)

Example 9 with JasperInitializer

use of org.apache.jasper.servlet.JasperInitializer in project tomcat by apache.

the class TestELInJsp method doTestELMisc.

private void doTestELMisc(boolean quoteAttributeEL) throws Exception {
    Tomcat tomcat = getTomcatInstance();
    // Create the context (don't use addWebapp as we want to modify the
    // JSP Servlet settings).
    File appDir = new File("test/webapp");
    StandardContext ctxt = (StandardContext) tomcat.addContext(null, "/test", appDir.getAbsolutePath());
    ctxt.addServletContainerInitializer(new JasperInitializer(), null);
    // Configure the defaults and then tweak the JSP servlet settings
    // Note: Min value for maxLoadedJsps is 2
    Tomcat.initWebappDefaults(ctxt);
    Wrapper w = (Wrapper) ctxt.findChild("jsp");
    String jspName;
    if (quoteAttributeEL) {
        jspName = "/test/el-misc-with-quote-attribute-el.jsp";
        w.addInitParameter("quoteAttributeEL", "true");
    } else {
        jspName = "/test/el-misc-no-quote-attribute-el.jsp";
        w.addInitParameter("quoteAttributeEL", "false");
    }
    tomcat.start();
    ByteChunk res = getUrl("http://localhost:" + getPort() + jspName);
    String result = res.toString();
    assertEcho(result, "00-\\\\\\\"${'hello world'}");
    assertEcho(result, "01-\\\\\\\"\\${'hello world'}");
    assertEcho(result, "02-\\\"${'hello world'}");
    assertEcho(result, "03-\\\"\\hello world");
    assertEcho(result, "2az-04");
    assertEcho(result, "05-a2z");
    assertEcho(result, "06-az2");
    assertEcho(result, "2az-07");
    assertEcho(result, "08-a2z");
    assertEcho(result, "09-az2");
    assertEcho(result, "10-${'foo'}bar");
    assertEcho(result, "11-\\\"}");
    assertEcho(result, "12-foo\\bar\\baz");
    assertEcho(result, "13-foo\\bar\\baz");
    assertEcho(result, "14-foo\\bar\\baz");
    assertEcho(result, "15-foo\\bar\\baz");
    assertEcho(result, "16-foo\\bar\\baz");
    assertEcho(result, "17-foo\\&apos;bar&apos;\\&quot;baz&quot;");
    assertEcho(result, "18-3");
    assertEcho(result, "19-4");
    assertEcho(result, "20-4");
    assertEcho(result, "21-[{value=11}, {value=12}, {value=13}, {value=14}]");
    assertEcho(result, "22-[{value=11}, {value=12}, {value=13}, {value=14}]");
}
Also used : Wrapper(org.apache.catalina.Wrapper) Tomcat(org.apache.catalina.startup.Tomcat) ByteChunk(org.apache.tomcat.util.buf.ByteChunk) StandardContext(org.apache.catalina.core.StandardContext) File(java.io.File) JasperInitializer(org.apache.jasper.servlet.JasperInitializer)

Aggregations

JasperInitializer (org.apache.jasper.servlet.JasperInitializer)9 InstanceManager (org.apache.tomcat.InstanceManager)5 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)5 ContainerInitializer (org.eclipse.jetty.plus.annotation.ContainerInitializer)5 File (java.io.File)4 Tomcat (org.apache.catalina.startup.Tomcat)4 Wrapper (org.apache.catalina.Wrapper)3 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)3 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)3 Context (org.apache.catalina.Context)2 ByteChunk (org.apache.tomcat.util.buf.ByteChunk)2 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)2 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)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 ServletContext (jakarta.servlet.ServletContext)1 PageContext (jakarta.servlet.jsp.PageContext)1