Version: 9.4.5.v20170502 |
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 for sponsored feature development
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.
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
:
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.@ManagedObject
annotation.
Should this annotation exist at any point in the chain of influencers then an MBran is created with the description of the version @ManagedObject
discovered.@ManagedAttribute
and @ManagedOperation
annotations and the corresponding type is exposed to the MBean.The convention of looking for @ManagedObject
annotations on .jmx.ClassMBean
allows for a normal POJOs 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.
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:
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:
The @ManagedOperation
annotation is used to indicate that a given method should be considered a JMX operation.
The list of attributes available are:
A fourth annotation is often used in conjunction 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:
The following is an example of each of the annotations mentioned above in practice.
package com.acme;
import org.eclipse.jetty.util.annotation.ManagedAttribute;
import org.eclipse.jetty.util.annotation.ManagedObject;
import org.eclipse.jetty.util.annotation.ManagedOperation;
import org.eclipse.jetty.util.annotation.Name;
@ManagedObject("Test MBean Annotations")
public class Derived extends Base implements Signature
{
String fname="Full Name";
@ManagedAttribute(value="The full name of something", name="fname")
public String getFullName()
{
return fname;
}
public void setFullName(String name)
{
fname=name;
}
@ManagedOperation("Doodle something")
public void doodle(@Name(value="doodle", description="A description of the argument") String doodle)
{
System.err.println("doodle "+doodle);
}
}