相同的JMX Mbean类用于同一服务器上的许多应用程序 [英] Same JMX Mbean class for many application at same server

查看:137
本文介绍了相同的JMX Mbean类用于同一服务器上的许多应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有超过5个春季网络应用程序,所有这些都使用另一个公共库。这个公共库有自己的MBean。由于强制唯一objectName约束,我的应用程序无法部署在同一服务器上。

I have more than 5 spring web application and all of them are utilizing another common library. This common library has its own MBeans. Because of mandatory unique objectName constraint, my applications could not be deployed on same server.

我使用MBeans的方式是这样的:

The way I am using MBeans are like this:

@ManagedResource(objectName = "com.org.city:name=City", description = "City related operations")

我想为所有应用程序使用具有不同objectNames的相同MBean类。在不重复我的MBean的情况下使用它的正确方法是什么。

I would like to use same MBean class with different objectNames for all applications. What is the correct way to utilize it without duplicating my MBeans.

谢谢

推荐答案

我已经为自定义行为实现了ObjectNamingStrategy。

I have implemented ObjectNamingStrategy for custom behaviour.

   @Override
  public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException {
     Class managedClass = AopUtils.getTargetClass(managedBean);
     Hashtable<String, String> properties = new Hashtable<String, String>();
     properties.put("type",ClassUtils.getPackageName(managedClass).concat(".").concat(ClassUtils.getShortName(managedClass)));
     properties.put("name", beanKey);
     return ObjectNameManager.getInstance(domain, properties);
  }

这篇关于相同的JMX Mbean类用于同一服务器上的许多应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆