Version 4

    How can an MBean depend on a Datasource?

     

    Datasources are created using -ds.xml descriptors that are mapped in memory

    to normal -service.xml descriptors after an XSL transformation takes place.

    During this transformation a number of MBeans are created. The mbean of

    interest in this case is the one that follows this naming convention:

       jboss.jca:service=DataSourceBinding,name={jndi-name}
    

    For example, if we are interested in the default datasource the name of the

    mbean is:

       jboss.jca:service=DataSourceBinding,name=DefaultDS
    

     

    Adding a dependency to your MBean is easy. Add the following statement to your -service.xml file which contains the definition of your MBean:

    <mbean code="my.mbean.class" name="mydomain:name=myname">
         ...
         <depends>jboss.jca:service=DataSourceBinding,name=DefaultDS</depends>
       </mbean>
    

    In the above dependency, change name=DefaultDS to name=theJndiNameToWhichYourDatasourceIsBound

     

     

    In its start() and stop() methods the DataSourceBinding mbean binds and

    unbinds from JNDI the ConnectionFactory for the datasource. By depending

    on this particular mbean, we can safely lookup and use the datasource.

     

    JBoss 3.2.x

     

    When using JBoss 3.2.x you may have to specify the dependencies on the DataSource connection pool, factory and transaction manager instead as there is no DataSourceBinding service:

     

     

     

    }}

     

    __Referenced by:__