Instrumenting Resources as Model MBeans
In this chapter, we
have
seen how to create Descriptor objects and the
necessary metadata classes for a model MBean, and we have looked at
RequiredModelMBean and the interfaces that it must
implement. In this section, we will see how to tie all of this
information together to instrument resources as model MBeans.
The steps you must go through to instrument each of your resources as model MBeans are:
Create an instance of the resource to be managed.
Create an instance of
RequiredModelMBean.Create the necessary metadata classes and optional descriptors for the features of the management interface.
Create the metadata for the resource (i.e., the
ModelMBeanInfoobject).Set the metadata of
RequiredModelMBeanto the metadata for the resource (from Step 3) and the resource to be managed through theModelMBeaninterface.
As in the previous chapters, we will use the sample application for all of our examples. This will allow you to compare and contrast the other MBean types with model MBeans.
In the examples presented here we will look at the application class
Controller, which
acts as the JMX agent. For the example code in this chapter, the
Controller class is responsible for creating the
resources to be managed, instrumenting them as model MBeans, and
registering them with the MBean server.
The first two steps are to create an instance of the managed resource
(in this example, the Queue) and to create the
RequiredModelMBean instance:
// . . . ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access