简体   繁体   English

JMX导出框架类似于Spring JMX导出器

[英]JMX exporting framework similar to Spring JMX exporter

Is there anything similar to the Spring JMX exporter out there WITHOUT using the Spring framework? 有什么类似于Spring JMX导出器没有使用Spring框架吗?

SimpleJMX seems to be reasonable but seems also to be a very young framework pushed only by a single person. SimpleJMX似乎是合理的,但似乎也是一个非常年轻的框架,只有一个人推动。

I'm in need of exposing a whole bunch of attributes, methods and classes as JMX but don't want to fiddle with the JMX API and writing tons of JMX interfaces. 我需要将一大堆属性,方法和类公开为JMX,但不想摆弄JMX API并编写大量的JMX接口。

And there is no way to introduce Spring in the project (just in case you ask). 并且没有办法在项目中引入Spring(以防你问)。 Any hints or ideas are greatly appreciated :-) 非常感谢任何提示或想法:-)

I cam accross org.weakref.jmxutils library in commons-dbcp-jmx . 我在commons-dbcp-jmx中 org.weakref.jmxutils库。 Check out ManagedBasicDataSource.java for an example: 查看ManagedBasicDataSource.java的示例:

@Managed(description = "The current number of active connections that have been allocated from this data source.")
public synchronized int getNumActive() {
    return super.getNumActive();
}

I've never used that library myself, but seems to work. 我自己从未使用过该库,但似乎有用。

Ok, I have quickly evaluated SimpleJMX and JMXUtils . 好的,我已经快速评估了SimpleJMXJMXUtils Both work as expected and are very similar to the Spring JMX exporter. 两者都按预期工作,与Spring JMX导出器非常相似。 However, I find JMXUtils to be more usable in my case. 但是,我发现JMXUtils在我的案例中更有用。

With JMXUtils it is very easy to register/unregister MBeans to an already started platform mbean server. 使用JMXUtils,可以非常轻松地将MBean注册/注销到已启动的平台mbean服务器。 In my case I was using GlassFish V3 as application server and I didn't want to start another MBean Server just for my own mbeans. 在我的情况下,我使用GlassFish V3作为应用程序服务器,我不想为我自己的mbeans启动另一个MBean Server。

As far as I can see the API of SimpleJMX does not allow this and you are either forced to start another MBeanServer using the SimpleJMX API and register the created mbeans (very easy with the API) or you start fiddling around with trying to register the mbeans into the platform mbean server. 据我所知,SimpleJMX的API不允许这样做,你要么被迫使用SimpleJMX API启动另一个MBeanServer并注册创建的mbeans(使用API​​非常容易),或者你开始尝试注册mbeans进入平台mbean服务器。 The later is a little bit more complicated and therefore I decided to use JMXUtils. 后者有点复杂,因此我决定使用JMXUtils。

The downside of JMXUtils is the manipulation of the bean name. JMXUtils的缺点是操纵bean名称。 SimpleJMX uses attributes in annotations (domainName, beanName) which is very useful but with JMXUtils you have to know the syntax for naming mbeans when using mbean domains. SimpleJMX使用注释中的属性(domainName,beanName),这非常有用但是使用JMXUtils时,您必须知道在使用mbean域时命名mbeans的语法。 All in all not a big deal but for my taste SimpleJMX has the better solution for this. 总而言之,这并不是什么大问题,但就我而言,SimpleJMX有更好的解决方案。

The bottom line is, that both libraries are great and do their job. 最重要的是,两个图书馆都很棒并且能够完成它们的工作。 I decided to use JMXUtils. 我决定使用JMXUtils。

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

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