Skip to content

Commit

Permalink
Merge pull request #14 from fbe/issue-13-add-jetty-jmx-beans
Browse files Browse the repository at this point in the history
Issue 13 - enable JMX beans
  • Loading branch information
Felix Becker authored Aug 12, 2016
2 parents ec897af + dd48220 commit b5a3147
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions jarlotte-jettyinitializer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<artifactId>apache-jsp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jmx</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>de.metacoder</groupId>
<artifactId>jarlotte-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@
package de.metacoder.jarlotte.jettyinitializer;

import de.metacoder.jarlotte.api.JarlotteInitializer;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppClassLoader;
import org.eclipse.jetty.webapp.WebAppContext;

import java.io.File;
import java.lang.management.ManagementFactory;

public class Initializer implements JarlotteInitializer {

Expand All @@ -42,6 +45,11 @@ public void initialize(File webAppDir) {

server = new Server(jettyPort);

MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
server.addEventListener(mbContainer);
server.addBean(mbContainer);
server.addBean(Log.getLog());

// required for working JSPs
final Configuration.ClassList classlist = Configuration.ClassList.setServerDefault( server );
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
Expand Down

0 comments on commit b5a3147

Please sign in to comment.