resin Using MBeanRegistration tutorial MBeans can implement the MBeanRegistration interface to find the ObjectName and MBeanServer they're registered with. index.jsp
Configures the JMX-managed bean The resource bean implementation. The management interface for the bean. Using the managed bean.

Frequently, a managed bean will either need its ObjectName or its MBeanServer. When the bean implements the MBeanRegistration interface, the JMX server tells the bean its ObjectName on registration.

The bean can verify the ObjectName or even returning a different name, although returning a different ObjectName is generally a bad idea in most cases since it makes the to configure.

package example; import; import; import; public class Test implements TestMBean, MBeanRegistration { private ObjectName _name; public ObjectName getObjectName() { return _name; } public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception { _name = name; return name; } public void postRegister(Boolean registrationDone) { } public void preDeregister() throws Exception { } public void postDeregister() { } }

The client JSP asks for the object's ObjectName to see the ObjectName passed in the preRegistration call.

<%@ page import='com.caucho.jmx.Jmx, example.BasicMBean' %> <% BasicMBean basic = (BasicMBean) Jmx.find("example:name=test"); out.println("ObjectName: " + test.getObjectName()); %> ObjectName: example:name=test

MBeanRegistration is part of the JMX specification.