<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
      "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">

<chapter id="mbeans">
   <title>MBeans extensions</title>

   <para>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
      <ulink url="http://docs.jboss.org/jbossas/jboss4guide/r1/html/ch2.chapter.html#d0e3460">XMBeans</ulink>.
      But with the change of the underlying Kernel, moving away from an JMX MBeanServer to a 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.
   </para>

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

   <para>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.
   </para>

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

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

</chapter>
