开发者

JMX server locator replacement in JBoss AS 7 for class MBeanServerLocator

I am currently using JBoss 4.3 for a web application. I would like to move to the JBoss AS 7. I have been able to fix must of the differences of the application in both versions but one. The application has some JMX beans that are created thru the spring framework. Unfortunately the AS 7 release removed the class: org.jboss.mx.util.MBeanServerLocator which was used in spring to locate the JBoss JMX server and create some beans. I am not to familiar with JMX but so far the only thing I have found so far is: "http://lists.jboss.org/pipermail/jboss-as7-dev/2011-February/000569.html". I was wondering if somebody knows how to replace the class above from JBOSS with the new JMX 1.6 classes. Here is my spring configuration snipet fo开发者_Go百科r the piece I need to fix:

<bean class="org.springframework.jmx.export.MBeanExporter">
    <property name="server">
        <bean class="org.jboss.mx.util.MBeanServerLocator" factory-method="locateJBoss"/>
    </property>
      <property name="beans">
        <map>
          <entry key="MywebMbeans:name=profileListenerContainer" value-ref="profileListenerContainer"/>
          <entry key="MywebMbeans:name=jmsSenderService" value-ref="jmsSenderService"/>
          <entry key="MywebMbeans:name=mailSender" value-ref="mailSender"/>
        </map>
      </property>
      <property name="assembler" ref="mbeanAssembler"/>
</bean>

Thanks,


The MBeanServer used by JBoss 7 (by default) is the platform MBeanServer. The class name is com.sun.jmx.mbeanserver.JmxMBeanServer and the default domain is DefaultDomain. Accordingly, you can simply use:

java.lang.management.ManagementFactory.getPlatformMBeanServer()

Alternatively:

    for(MBeanServer server: javax.management.MBeanServerFactory.findMBeanServer(null)) {
        if("DefaultDomain".equals(server.getDefaultDomain())) return server;
    }
    throw new Exception("Failed to locate MBeanServer");


Actually I just look in the JMX page for spring http://static.springsource.org/spring/docs/1.2.x/reference/jmx.html

The following will work in both JBoss instaces 4 and 7.

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean">
      <property name="locateExistingServerIfPossible" value="true" />
</bean>

<bean class="org.springframework.jmx.export.MBeanExporter">

   <property name="server" ref="mbeanServer"/>
   </property>
      <property name="beans">
        <map>
          <entry key="MywebMbeans:name=profileListenerContainer" value-ref="profileListenerContainer"/>
          <entry key="MywebMbeans:name=jmsSenderService" value-ref="jmsSenderService"/>
          <entry key="MywebMbeans:name=mailSender" value-ref="mailSender"/>
        </map>
      </property>
      <property name="assembler" ref="mbeanAssembler"/>
</bean>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜