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:
For example, if we are interested in the default datasource the name of the
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.
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: