Version 3

    The DynamicInterceptor


    JBoss XMBeans introduced in the 3.2.x series provide the ability to plugin

    interceptors to the MBean invocation chain. Those interceptors need to

    implement the interface and they

    are specified statically in the xmbean descriptor when the MBean gets



    This is a nice feature of JBoss that predates the JBoss AOP technology and

    allows you to code to an interceptor design. It is by no means as powerful

    as JBoss AOP, but it is simple and will work, as long as you are dealing

    with (X)MBeans.


    Now, what if you want to to dynamically add/remove an interceptor to an



    Starting from JBoss v4.0.3, the DynamicInterceptor provides this

    capability. It is a normal interceptor added to any (X)MBean as follows:


      <!-- Sample from ejb-deployer -->
          <description>The EJBDeployer responsible for ejb jar deployment</description>
              <interceptor code=""></interceptor>  <!-- HERE -->


    When added to the (X)MBean, the DynamicInterceptor "implements" two new operations

    addOperationInterceptor(Interceptor) and removeOperationInterceptor(Interceptor),

    corresponding to a new internal interface

    Adding and removing interceptors is done over the normal MBean inteface, so it

    is necessary to declare those operations as part of the (X)Mbean interface.


    In the case of a standalone xmbean descriptor, just use the interceptable

    ENTITY defined in the jboss_xmbean_1_1.dtd, jboss_xmbean_1_2.dtd:

      <!-- Operations section -->


    In the case of an xmbean descriptor inlined to the mbean deployment descriptor,

    the interceptable ENTITY is not available, so you need to use:

      <!-- Operations section -->
        <description>Add dynamically an operation interceptor</description>
          <description>The Interceptor</description>
        <description>Remove dynamically an operation interceptor</description>
          <description>The Interceptor</description>


    The addition of the DynamicInterceptor has minimal impact to an (X)Mbean.

    The only difference is that whenever one of the above methods gets called,

    it will be served by the DynamicInterceptor and not delegated to the target



    Note that, any interceptor added dynamically to the (X)MBean, is put

    first in the internal interceptor chain. Also, the dynamically introduced

    interceptor(s) will only intercept operation calls, and not attribute

    get/sets. This is a limitation that maybe removed in the future.


    Having (X)Mbean-ized and DynamicInterceptor enabled your MBeans, you can

    proceed to add/remove dynamically interceptors to it. A convenient way

    to do this is by extending the org.jboss.system.InterceptorServiceMBeanSupport

    base class.








    Referenced by: