|
Visit our blog
News & EventsOracle Article Blitz: Spring Soup with OC4J and MBeansSpring 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. |
Newsletter SubscriptionOur monthly newsletter is packed full of techniques, tutorials, tips and tricks to get you on your way to Spring nirvana. View Archive Upcoming Training04/15 - 04/18:
Bangalore Rich Web Applications with Spring Enterprise Integration with Spring 04/16 - 04/19:
Wien Plus: Hibernate with Spring, Core Spring.NET, Groovy & Grails |





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!