In JBoss 5, the load order of MBeans is determined by the dependencies between MBeans and the order in which they are defined in the
MBeans can depend on other MBeans, and the MBean server will ensure that the dependencies are satisfied before starting an MBean. For example, if MBean A depends on MBean B, then MBean B will be started before MBean A.
jboss-service.xml file is an XML configuration file that defines the MBeans that make up the JBoss application server. The MBeans are defined in the file in the order in which they should be started.
To determine the load order of MBeans in JBoss 5, you can examine the
jboss-service.xml file and look at the dependencies between MBeans and the order in which they are defined. You can also use the JMX console to view the MBeans and their dependencies.
For example, here is an HelloWorldService that depends on the application.ear:
<server> <mbean code="sample.HelloWorldService" name="sample:service=HelloWorld,id=1"> <depends>jboss.j2ee:service=EARDeployment,url='application.ear'</depends> </mbean> </server>
You can also apply the same criteria to other packages such as a JAR file:
<server> <mbean code="sample.HelloWorldService" name="sample:service=HelloWorld,id=1"> <depends>jboss.j2ee:service=JARDeployment,url='ejbsample.jar'</depends> </mbean> </server>
How to determine the order of load between Services?
Supposing you want your Timer service to be started after that your applications (a Web application and an EJB application) are deployed as shown here:
All you have to do is adding a <depends> attribute to the EJB3TimerService MBean. Open the ejb3-timer-service.xml. This file already contains some dependancies on other services, we will add here our deployment dependency:
<server> <mbean code="org.jboss.ejb3.timerservice.quartz.jmx.EJB3TimerService" name="jboss.ejb:service=EJB3TimerService"> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> <depends optional-attribute-name="DataSource">jboss.jca:service=DataSourceBinding,name=DefaultDS</depends> <!-- WEB dependency --> <depends>jboss.web.deployment:war=/WebApplication</depends> <!-- EJB dependency --> <depends>jboss.j2ee:jar=EJBApplication.jar,name=TestEJBBean,service=EJB3</depends> <attribute name="Properties"> <!-- commented for brevity --> </attribute> </mbean> </server>
As you can see, adding a dependency for a Web application is quite easy, you have just to add the WebContext name of the application. Dependency of an EJB application is also easy, you have just to state some additional information like the EJB Class name and the Service type (EJB3) as it falls in the generic jboss.j2ee tree.