Search in sources :

Example 6 with ContainerInitializer

use of org.eclipse.jetty.plus.annotation.ContainerInitializer 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)

Example 7 with ContainerInitializer

use of org.eclipse.jetty.plus.annotation.ContainerInitializer in project Openfire by igniterealtime.

the class HttpBindManager method createCrossDomainHandler.

private void createCrossDomainHandler(ContextHandlerCollection contexts, String crossPath) {
    ServletContextHandler context = new ServletContextHandler(contexts, crossPath, 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 FlashCrossDomainServlet()), "");
}
Also used : SimpleInstanceManager(org.apache.tomcat.SimpleInstanceManager) InstanceManager(org.apache.tomcat.InstanceManager) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) 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 ContainerInitializer

use of org.eclipse.jetty.plus.annotation.ContainerInitializer in project jetty.project by eclipse.

the class QuickStartDescriptorProcessor method visitContainerInitializer.

public void visitContainerInitializer(WebAppContext context, ContainerInitializer containerInitializer) {
    if (containerInitializer == null)
        return;
    //add the ContainerInitializer to the list of container initializers
    List<ContainerInitializer> containerInitializers = (List<ContainerInitializer>) context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
    if (containerInitializers == null) {
        containerInitializers = new ArrayList<ContainerInitializer>();
        context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, containerInitializers);
    }
    containerInitializers.add(containerInitializer);
    //Ensure a bean is set up on the context that will invoke the ContainerInitializers as the context starts
    ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter) context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER);
    if (starter == null) {
        starter = new ServletContainerInitializersStarter(context);
        context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter);
        context.addBean(starter, true);
    }
}
Also used : ServletContainerInitializersStarter(org.eclipse.jetty.annotations.ServletContainerInitializersStarter) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with ContainerInitializer

use of org.eclipse.jetty.plus.annotation.ContainerInitializer 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 10 with ContainerInitializer

use of org.eclipse.jetty.plus.annotation.ContainerInitializer in project mysql_perf_analyzer by yahoo.

the class App method jspInitializers.

private List<ContainerInitializer> jspInitializers() {
    JettyJasperInitializer sci = new JettyJasperInitializer();
    ContainerInitializer initializer = new ContainerInitializer((ServletContainerInitializer) sci, null);
    List<ContainerInitializer> initializers = new ArrayList<ContainerInitializer>();
    initializers.add(initializer);
    return initializers;
}
Also used : ArrayList(java.util.ArrayList) JettyJasperInitializer(org.eclipse.jetty.apache.jsp.JettyJasperInitializer) ServletContainerInitializer(javax.servlet.ServletContainerInitializer) ContainerInitializer(org.eclipse.jetty.plus.annotation.ContainerInitializer)

Aggregations

ContainerInitializer (org.eclipse.jetty.plus.annotation.ContainerInitializer)10 ArrayList (java.util.ArrayList)7 JasperInitializer (org.apache.jasper.servlet.JasperInitializer)4 InstanceManager (org.apache.tomcat.InstanceManager)4 SimpleInstanceManager (org.apache.tomcat.SimpleInstanceManager)4 List (java.util.List)3 ServletContainerInitializer (javax.servlet.ServletContainerInitializer)3 ServletContainerInitializersStarter (org.eclipse.jetty.annotations.ServletContainerInitializersStarter)2 JettyJasperInitializer (org.eclipse.jetty.apache.jsp.JettyJasperInitializer)2 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)2 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)2 ConcurrentHashSet (org.eclipse.jetty.util.ConcurrentHashSet)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 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1