1

I am working in a java project which implements MBeans and my need is to intercept MBean and change/add their properties before registry. Example :

domainName:name=myMBean --> domainName:name=myMBean1,type=myType

I found this link which presents how to apply an interceptor other then default interceptor but I have no idea to how do that in code.

Thanks in advance.

Mohammed
  • 115
  • 1
  • 13
  • I've added a simple answer. If you can edit your question with the framework you are using to register your mbeans, I can answer better. – Gray Apr 05 '12 at 17:01

1 Answers1

0

Once you register the bean obviously it is too late. The easiest thing to do is to change how the registration is done. If you show us what framework you are using to register the bean then I'll be able to help more.

Typically whatever is doing the actual registration is doing something like:

private MBeanServer mbeanServer;
...
mbeanServer.registerMBean(mbean, objectName);

You can therefore provide a different ObjectName:

ObjectName objectName = new ObjectName("domainName:name=myMBean1,type=myType");

But I assume you are not doing the registration yourself.


As an aside, I'm not sure you can switch to use a different JMX framework but I've put the finishing touches on my Simple JMX system recently. It allows objects to name themselves programmatically when they are published.

Gray
  • 115,027
  • 24
  • 293
  • 354
  • The project concerned is JOnAS in fact. For mbeans registry, JOnAS use apache API named BaseModelMBean with an mbean-descriptor. I don't know if that answers your question, I have not yet many references in this field. Change objectnames as you describe is too low level. I need to change some mbeans (depending on the presence, or not, of an information in the application to deploy). So : 1. Somewhere, we want to register a mbean 2. "Something" check the presence of the information, and change (if needed) objectname. 3. Register mbean Remains to find this "something" :-). Thanks in advance. – Mohammed Apr 06 '12 at 07:48
  • Sorry, I don't know about that framework. I'm not sure you can switch but I actually put the finishing touches on my Simple JMX system recently. It allows objects to name themselves programmatically: http://256.com/sources/simplejmx/ – Gray Apr 06 '12 at 13:11
  • Another side of my need could be saw as a "proxy" of the default MBeanServer. In this proxy, we could treat requests. The proxy will implement the same interface in addition of code which allows to treat mbeans before registry and also to access to mbeans (an application can only access to mbeans which have type=myType for example). – Mohammed Apr 06 '12 at 15:35