Visit our blog

News & Events

Oracle Article Blitz: Spring Soup with OC4J and MBeans

Spring Soup with OC4J and MBeans, by Steve Button, is a wll illustrated article which steps throught the process of exposing a Spring service as a JMX managed MBean, in an OC4J environment, by using Spring transparent JMX support. It then shows how the MBean can be viewd and managed in the Application Server Control management console supplied with OC4J.

The Oct. 2006 Oracle monthly newsletter for Java developers is dedicated to Spring framework, and this is just one article linked to from this issue of the newsletter.

Comments

The article has some weird part

The article mentions specifying a custom domain name but doesn't tell where to get it which can lead to a lot of problems. To fix this I have developped a custom Oc4jNamingStrategy. Here's the code (in french, nomDomaine = domainName) :

package ca.qc.gouv.msp.oca.gdu.jmx;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;

import org.springframework.jmx.export.naming.ObjectNamingStrategy;
import org.springframework.jmx.support.ObjectNameManager;

public class Oc4jNamingStrategy implements ObjectNamingStrategy {

private String nomDomaine;

public String getNomDomaine() {
return nomDomaine;
}

public void setNomDomaine(String nomDomaine) {
this.nomDomaine = nomDomaine;
}

/* (non-Javadoc)
* @see org.springframework.jmx.export.naming.ObjectNamingStrategy#getObjectName(java.lang.Object, java.lang.String)
*/
public ObjectName getObjectName(Object object, String nom)
throws MalformedObjectNameException {
StringBuffer objectName = new StringBuffer();
objectName.append(nomDomaine);
objectName.append(":name=");
objectName.append(nom);

return ObjectNameManager.getInstance(objectName.toString( ));
}

}

And the wiring :


bean id="mBeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean"
/bean

bean id="oc4jNamingStrategy" class="ca.qc.gouv.msp.oca.gdu.jmx.Oc4jNamingStrategy"
property name="nomDomaine"
util:property-path path="mBeanServer.defaultDomain"/
/property
/bean

Sorry I had to take out the brackets.

Hope it helps!

 

Newsletter Subscription

Our monthly newsletter is packed full of techniques, tutorials, tips and tricks to get you on your way to Spring nirvana. View Archive

Upcoming Training