40 Configuring Custom MBeans

This chapter provides information on configuring standard, MX, and JMX MBeans.

Creating an MBean XML Configuration File

Custom MBeans are configured in an XML configuration file. The elements in the file describe the MBean type, MBean implementation, and the target MBean ObjectName. The current release of Coherence supports these types of custom MBeans.

See Appendix A, "Operational Configuration Elements" for a complete descriptions of the elements used in this chapter.

Configuring Standard MBeans

The configuration in Example 40-1 will create a Coherence:type=Query,nodeId=<nodeId> using the standard MBean com.oracle.customMBeans.Query class for the node. This example specifies an MBean class, an MBean name, and enables the MBean to be registered in the instance.

Example 40-1 Using an MBean to Create a Query Node

  <mbean id="100">

Configuring MXBeans

The configuration in Example 40-2 will execute the standard Java method getMemoryMXBean in the java.lang.management.ManagementFactory class and use the result to create a Coherence:type=java,SubSystem=Memory,nodeId=<nodeId> for the node. The following example specifies an MBean factory, an accessor method name on the factory, an MBean name, and enables the MBean to be registered in the instance.

Example 40-2 Getting an MBean for the Memory System of a Java Virtual Machine

  <mbean id="2">

Configuring JMX MBeans

JMX MBeans are MBeans that exist in a local MBean server that need to be added to the Coherence Management structure. This allows consolidation of MBeanServer information into a single source. The configuration in Example 40-3 executes the JMX query, java.lang:*, on the node's local MBean server and uses the results to create corresponding MBeans on the centralized Coherence MBean server. The following example specifies a JMX MBean query, an MBean name, and and enables the MBean to be registered in the instance.

Example 40-3 Executing a JMX Query and Creating an MBean on the MBean Server

  <mbean id="1">

Figure 40-1 illustrates the results on the query in JConsole.

Figure 40-1 MBean Query Displayed in the JConsole

This figure is described in the text

Enabling a Custom MBean Configuration File

You can enable the custom MBean configuration file by setting a system property or by including a specially named file in the class path.

Setting a System Property

Coherence provides the following system property to specify the name and location of a custom MBean configuration file. Setting this system property will cause the Coherence node to load the MBeans defined in the file represented by filename.

Example 40-4 System Property to Load an MBean


Adding a Custom MBean Configuration File to the Class Path

By convention, Coherence recognizes the configuration file named custom-mbeans.xml as containing a custom MBean configuration. If you name your custom MBean configuration file custom-mbeans.xml and include it in the class path, then the Coherence node will load the configured MBeans.