Skip Headers
Oracle® Coherence Developer's Guide
Release 3.5

Part Number E14509-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

27 Configuring Custom MBeans

This chater 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 K, "MBean Configuration Elements" for a complete descriptions of the elements used in this chapter.

Configuring Standard MBeans

The configuration in Example 27-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 (mbean-class), an MBean name (mbean-name), and whether it is registered (enabled) in the instance.

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

<mbeans>
  <mbean id="100">
    <mbean-class>com.oracle.customMBeans.Query</mbean-class>
    <mbean-name>type=Query</mbean-name>
    <enabled>true</enabled>
  </mbean>
</mbeans>

Configuring MXBeans

The configuration in Example 27-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 example specifies an MBean factory (mbean-factory), an accessor method name on the factory (mbean-accessor), an MBean name (mbean-name), and whether it is registered (enabled) in the instance.

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

<mbeans>
  <mbean id="2">
    <mbean-factory>java.lang.management.ManagementFactory</mbean-factory>
    <mbean-accessor>getMemoryMXBean</mbean-accessor>
    <mbean-name>type=java,SubSystem=Memory</mbean-name>
    <enabled>true</enabled>
  </mbean>
</mbeans>

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 27-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 example specifies a JMX MBean query(mbean-query), an MBean name (mbean-name), and whether it is registered(enabled) in the instance.

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

<mbeans>
  <mbean id="1">
    <mbean-query>java.lang:*</mbean-query>
    <mbean-name>type=Platform</mbean-name>
    <enabled>true</enabled>
  </mbean>
<mbeans>

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

Figure 27-1 MBean Query Displayed in the JConsole

Description of Figure 27-1 follows
Description of "Figure 27-1 MBean Query Displayed in the JConsole"

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 27-4 System Property to Load an MBean

-Dtangosol.coherence.mbeans=<filename>

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.