How to customize the Jetty management server programmatically

Viewed 150

I would like to implement a JettyServerCustomizer (or some other similar interface) to customize the management server (running on port 8081). The method customize(Server server) of the classes I implemented so far is called only for the main Jetty server (running on port 8080), when the application starts. How can I make it be called for the management server?

1 Answers

Enable JMX and/or JMX remote modules on standalone Jetty.

All of the various ThreadPools, along with many other components, will be available in JMX for you to access.

For embedded-jetty, do this ...

Server server = newServer();

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

ConnectorServer jmx = new ConnectorServer(
    new JMXServiceURL(
        "rmi",
        null,
        1999,
        "/jndi/rmi://localhost:1999/jmxrmi"),
    "org.eclipse.jetty.jmx:name=rmiconnectorserver");
server.addBean(jmx);
Related