Difference between revisions of "Jetty/Feature/JMX"

From Eclipsepedia

< Jetty‎ | Feature
Jump to: navigation, search
Line 5: Line 5:
  
 
The creation of MBeans is coordinated by the MBeanContainer implementation of the Container.Listener interface. The Jetty Server and it's components use a [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/util/component/Container.html Container] to maintain a containment tree of components and to support notification of changes to that tree. The MBeanContainer class listens for Container events and creates and destroys MBeans as required to wrap all Jetty components.
 
The creation of MBeans is coordinated by the MBeanContainer implementation of the Container.Listener interface. The Jetty Server and it's components use a [http://download.eclipse.org/jetty/stable-7/apidocs/org/eclipse/jetty/util/component/Container.html Container] to maintain a containment tree of components and to support notification of changes to that tree. The MBeanContainer class listens for Container events and creates and destroys MBeans as required to wrap all Jetty components.
| body = (required)
+
| body =
| more = (optional) - links, additional references
+
 
| category = (optional) - categor(ies) to use for this page. If blank, will use the template name as a default category
+
 
Example: [[Category:Category 1]] [[Category:Category 2]]
+
== Using Jetty MBeans ==
 +
 
 +
The simplest way to use Jetty MBeans is to use the JVM supplied [http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html JConsole] utility. An internal HTTP agent can also be used (see jetty-jmx.xml config file comments).
 +
 
 +
See [Run Jetty with JConsole] for instructions on how to configure jmx for use with Sun's [http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html JConsole].
 +
 
 +
== Jetty Standalone ==
 +
 
 +
The MBeanContainer instance can be configured for a Jetty server by the jetty-jmx.xml configuration file. This can be run with the standard configuration file as follows:
 +
<source lang="text">
 +
java -jar start.jar etc/jetty-jmx.xml etc/jetty.xml
 +
</source>
 +
 
 +
Jetty 7 requires -DOPTIONS=jmx to be used when starting up Jetty. That is, instead of the above, use this:
 +
java '''-DOPTIONS=jmx''' -jar start.jar etc/jetty-jmx.xml etc/jetty.xml
 +
 
 +
== Jetty Maven Plugin ==
 +
 
 +
If you are using the [http://jetty.mortbay.org/maven-plugin/index.html Jetty Maven plugin] you should copy the etc/jetty-jmx.xml file into your webapp project somewhere, such as src/etc, then add a <jettyConfig> element to the plugin <configuration>:
 +
<source lang="xml">
 +
<plugin>
 +
        <groupId>org.mortbay.jetty</groupId>
 +
        <artifactId>maven-jetty-plugin</artifactId>
 +
        <version>${project.version}</version>
 +
        <configuration>
 +
          <scanIntervalSeconds>10</scanIntervalSeconds>
 +
          <jettyConfig>src/etc/jetty-jmx.xml</jettyConfig>
 +
          <userRealms>
 +
            <userRealm implementation="org.mortbay.jetty.security.HashUserRealm">
 +
              <name>Test Realm</name>
 +
              <config>../../etc/realm.properties</config>
 +
            </userRealm>
 +
          </userRealms>
 +
        </configuration>
 +
</plugin>
 +
</source>
 +
| more =
 +
See [Run Jetty with JConsole] for instructions on how to configure jmx for use with Sun's [http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html JConsole].
 +
| category = [[Category:Feature]]
 
}}
 
}}

Revision as of 20:48, 21 December 2009



Contents

Introduction

The Jetty JMX integration is based on the ObjectMBean implementation of DynamicMBean. This implementation allows an arbitrary POJO to be wrapped in an MBean and for meta data to be provided by properties files

The creation of MBeans is coordinated by the MBeanContainer implementation of the Container.Listener interface. The Jetty Server and it's components use a Container to maintain a containment tree of components and to support notification of changes to that tree. The MBeanContainer class listens for Container events and creates and destroys MBeans as required to wrap all Jetty components.

Feature

Using Jetty MBeans

The simplest way to use Jetty MBeans is to use the JVM supplied JConsole utility. An internal HTTP agent can also be used (see jetty-jmx.xml config file comments).

See [Run Jetty with JConsole] for instructions on how to configure jmx for use with Sun's JConsole.

Jetty Standalone

The MBeanContainer instance can be configured for a Jetty server by the jetty-jmx.xml configuration file. This can be run with the standard configuration file as follows:

java -jar start.jar etc/jetty-jmx.xml etc/jetty.xml

Jetty 7 requires -DOPTIONS=jmx to be used when starting up Jetty. That is, instead of the above, use this: java -DOPTIONS=jmx -jar start.jar etc/jetty-jmx.xml etc/jetty.xml

Jetty Maven Plugin

If you are using the Jetty Maven plugin you should copy the etc/jetty-jmx.xml file into your webapp project somewhere, such as src/etc, then add a <jettyConfig> element to the plugin <configuration>:

<plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>maven-jetty-plugin</artifactId>
        <version>${project.version}</version>
        <configuration>
          <scanIntervalSeconds>10</scanIntervalSeconds>
          <jettyConfig>src/etc/jetty-jmx.xml</jettyConfig>
          <userRealms>
            <userRealm implementation="org.mortbay.jetty.security.HashUserRealm">
              <name>Test Realm</name>
              <config>../../etc/realm.properties</config>
            </userRealm>
          </userRealms>
        </configuration>
</plugin>

Additional Resources

See [Run Jetty with JConsole] for instructions on how to configure jmx for use with Sun's JConsole.