简体   繁体   English

JBoss 7 MBean对另一个MBean的依赖

[英]JBoss 7 MBean dependency on another MBean

I am working on migrating project from JBoss 4.2.2 to JBoss 7.1.1. 我正在将项目从JBoss 4.2.2迁移到JBoss 7.1.1。 We had Configuration MBean and other beans on start were connecting to this Configuration MBean to get some parameters. 我们启动时有Configuration MBean,其他bean正在连接到此Configuration MBean以获取一些参数。 So jboss-service.xml configuration was like that: 所以jboss-service.xml的配置是这样的:

    <mbean code="example.ConfigManager" name="exam:name=ConfigManager">        
         <attribute name="DataSourceName">java:jboss/datasources/myDS</attribute>
    </mbean>
...
    <mbean code="example.AnotherMBean" name="exam:name=AnotherMBean">
         <depends>exam:name=ConfigManager</depends>
         <attribute name="Login">system</attribute>
    </mbean>

In jboss 7 I have implemented MBeans in the way it is required (implemented start() and stop() method), but when starting AnotherMBean and it is trying to get information from ConfigManager I get: 在jboss 7中,我已经按照所需的方式(实现了start()和stop()方法)实现了MBean,但是在启动AnotherMBean并尝试从ConfigManager获取信息时,我得到了:

javax.management.InstanceNotFoundException: exam:name=ConfigManager

There are no problems with ConfigManager, it simply loads after AnotherMbean. ConfigManager没问题,它只是在AnotherMbean之后加载。 Is it possible to define loading order for MBeans? 是否可以定义MBean的加载顺序?

PS Don't advise switching to @Startup and @Singleton, it is not possible for now, due to our system requirements. PS不建议切换到@Startup和@Singleton,由于我们的系统要求,目前无法切换。

Thank you! 谢谢!

So, no workaround was found, so reconfigured my application to use Singleton ejbs with @DependsOn annotations. 因此,未找到任何解决方法,因此将我的应用程序重新配置为使用具有@DependsOn批注的Singleton ejbs。 And in @PostConstruct method created something like 并在@PostConstruct方法中创建了类似

    @PostConstuct 
    private void registerToJMX() {
       private MBeanServer platformMBeanServer;
       private ObjectName objectName = null;
       try {
           objectName = new ObjectName("tms:name=BlankNotifications");
           platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
           platformMBeanServer.registerMBean(this, objectName);
       } catch (Exception e) {            
       }
    }

To register it in JMX console. 要在JMX控制台中注册。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM