开发者

JMX - MBean automated registration on application deployment

开发者 https://www.devze.com 2022-12-29 23:58 出处:网络
I need some direction with JMX and Java EE. I am aware (after few weeks of research) that the JMX specification is missing as far as deployment is concerned. There are few vendor specific implementat

I need some direction with JMX and Java EE.

I am aware (after few weeks of research) that the JMX specification is missing as far as deployment is concerned. There are few vendor specific implementations for what I am looking for but none are cross vendor. I would like to automate the deployment of MBeans and registration with the Server. I need the server to load and register my MBeand when the application is deployed and remove when the application is un-deployed.

I develop with: NetBean 6.7.1, GlassFish 2.1, Java EE 5, EJB 3

More specific, I need a way to manage timer service runs. My application need to run different archiving agents and batch reporting. I was hoping the JMX will give me remote access to create and manage the timer services and enable the user to create his own schedule. If the JMX is auto registered on application deployment the user can immediately connect and manage the schedule. On the other hand, how can an EJB connect/access an MBean?

Many thanks in adv开发者_如何学编程ance. Gadi.


I investigated JMX and EJB in Glassfish few years ago, so I don't remember all the details. But this might still help.

  1. Glassfish-specific JMX. Glassfish has AMX and custom MBean can be deployed. AFAIK, such beans are meant to monitor the server itself, not to interact closely with a specific application. Such bean can be made persistent, and Glassfish will store their value somewhere across restart. Maybe have a look.

  2. Registration and lookup. You can register MBean anytime from within an application using the MBeanPlatform, or MBeanServer. See this link, I don't remember exactly. You can also lookup other JMX bean and invoke operations on them. The names for the lookup are a bit crazy though. You can register the MBean when the app. starts from within a ServletContextListener.

  3. Classloaders and deployment. The MBeans and the EJB instances are in distinct Classloader. I think you will need to place the .jar with the MBean implementation in the Glassfish deployment directory structure or add it the list of .jar in the classpath via the admin console. You can relatively easily manage to register a bean from within an EJB module, but a bean can not access a EJB easily, at least from my experience.

I managed to use plain JMX to expose statistics from my EJB application, and that worked relatively well. But I don't know if it's adequate to have something more interactive, as in your case where you want to have the EJB change their behavior depending the timer configured with JMX. I fear you will have troubles with this approach.

Hope it helps, despite the vagueness of what I remember.

0

精彩评论

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

关注公众号