Java Reference
In-Depth Information
<entry key="bean:name=documentReplicator,type=FileReplicatorJMXImpl">
<bean class="com.apress.springenterpriserecipes.replicator.
ReplicationNotificationListener" />
6-3. Accessing Remote JMX MBeans in Spring
You want to access JMX MBeans running on a remote MBean server exposed by a JMX connector. When
accessing remote MBeans directly with the JMX API, you have to write complex JMX-specific code.
Spring offers two approaches to simplify your remote MBean access. First, it provides a factory bean for
you to create an MBean server connection declaratively. With this server connection, you can query and
update an MBean's attributes, as well as invoke its operations. Second, Spring provides another factory
bean that allows you to create a proxy for a remote MBean. With this proxy, you can operate a remote
MBean as if it were a local bean.
How It Works
Accessing Remote MBeans Through an MBean Server Connection
A JMX client requires an MBean server connection to access MBeans running on a remote MBean server.
Spring provides for you to create
a connection to a remote JSR-160-enabled MBean server declaratively. You only have to provide the
service URL for it to locate the MBean server. Now let's declare this factory bean in your client bean
configuration file (e.g., beans-jmx-client.xml ).
<beans xmlns=""
<bean id="mbeanServerConnection"
<property name="serviceUrl" value=
"service:jmx: rmi://localhost/jndi/ rmi://localhost:1099/replicator" />
With the MBean server connection created by this factory bean, you can access and operate the
MBeans running on this server. For example, you can query and update an MBean's attributes through
the getAttribute() and setAttribute() methods, giving the MBean's object name and attribute name.
You can also invoke an MBean's operations by using the invoke() method.
Search WWH ::

Custom Search