Chapter 8. MBeans extensions

In previous versions (pre 5.x) of JBoss Application Server core services were implemented as MBeans. To make things a bit easier, not forcing the requrement for a direct implementation of the DynamicMBean interface, we introduced XMBeans. But with the change of underlying Kernel, moving away from JMX MBeanServer to plain POJO Controller, we also let the handling of the existing MBeans to the new Controller. Apart from supporting all of the existing XMBean features, we also ported some of the rich features from the new Microcontainer IoC model to the XBeans. We'll show these features in the examples below.

      <mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
         <attribute name="Attribute">
            <inject bean="TestName" property="getSomething" state="Instantiated"/>
         </attribute>
      </mbean>
   

Here we transparently add a dependency on a bean named TestName, which must be, in order to be injected, in the Instantiated state. Once the dependency is satisfied, we actually don't inject the bean itself into the attribute, but we inject the return value of getSomething method being executed on TestName bean instance. Property and state attributes are optional, by default the dependant state is Installed.

      <mbean name="jboss.test:type=BasicMBeanName" code="BasicMBeanCode">
         <alias>BasicBean</alias>
         <alias>${system.basic.name}</alias>
      </mbean>
   

Here we can see that a MBean can also have alias names. When adding alias you can also use System property replacement.