Jetty Logo
Version: 9.2.2-SNAPSHOT
Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Jetty JMX Annotations

Annotation Introspection
@ManagedObject
@ManagedAttribute
@ManagedOperation
@Name
Example

When the jetty-jmx libraries are present on startup and the wiring is enabled for exposing jetty mbeans to jmx, there are three annotations that govern when and how mbeans are created and exposed.

Annotation Introspection

When jmx is configured and enabled in jetty any time an object is registered with the Server it is introspected as a potential mbean to be exposed. This introspection proceeds as follows assuming the class is named com.acme.Foo:

  1. All influences for com.acme.Foo determined. These include each class in the chain of super classes, and by convention each of these classes following a form of com.acme.jmx.FooMBean. All super classes and their corresponding MBean representations are then used in the next step.

  2. Each potential influencing class is checked for the @ManagedObject annotation, should this annotation exist at any point in the chain of influencers then a mbean is created with the description of the version @ManageObject discovered.

  3. Once an mbean has been created for an object then each potential influencing object is introspected for @ManagedAttribute and @ManagedOperation annotations and the corresponding type is exposed to the mbean.

The convention of looking for @ManageObject annotations on .jmx.ClassMBean allows for a normal POJO to be wrapped in an mbean without itself without requiring it being marked up with annotations. Since the pojo is passed to these wrapped derived Mbean instances and is an internal variable then the MBean can be used to better expose a set of attributes and operations that may not have been anticipated when the original object was created.

@ManagedObject

The @ManagedObject annotation is used on a class at the top level to indicate that it should be exposed as an mbean. It has only one attribute to it which is used as the description of the MBean. Should multiple @ManagedObject annotations be found in the chain of influence then the first description is used.

The list of attributes available are:

value

The description of the Managed Object.

@ManagedAttribute

The @ManagedAttribute annotation is used to indicate that a given method exposes a JMX attribute. This annotation is placed always on the reader method of a given attribute. Unless it is marked as read-only in the configuration of the annotation a corresponding setter is looked for following normal naming conventions. For example if this annotation is on a method called getFoo() then a method called setFoo() would be looked for and if found wired automatically into the jmx attribute.

The list of attributes available are:

value

The description of the Managed Attribute.

name

The name of the Managed Attribute.

proxied

Value is true if the corresponding mbean for this object contains the method of this JMX attribute in question.

readonly

By default this value is false which means that a corresponding setter will be looked for an wired into the attribute should one be found. Setting this to true make the jmx attribute read only.

setter

This attribute can be used when the corresponding setter for a JMX attribute follows a non-standard naming convention and it should still be exposed as the setter for the attribute.

@ManagedOperation

The @ManagedOperation annotation is used to indicate that a given method should be considered a JMX operation.

The list of attributes available are:

value

The description of the Managed Operation.

impact

The impact of an operation. By default this value is "UNKNOWN" and acceptable values are "ACTION", "INFO", "ACTION_INFO" and should be used according to their definitions with JMX.

proxied

Value is true if the corresponding mbean for this object contains the method of this JMX operation in question.

@Name

A fourth annotation is often used in conjuction with the JMX annotations mentioned above. This annotation is used to describe variables in method signatures so that when rendered into tools like JConsole it is clear what the parameters are. For example:

The list of attributes available are:

value

The name of the parameter.

description

The description of the parameter.

Example

The following is an example of each of the annotations mentioned above in practice.

See an error or something missing? Contribute to this documentation at Github!(Generated: 2014-07-24T01:01:41-07:00)