JBoss AS Service Dependency: an use case
- Published: 10 December 2009
JBoss AS has plenty of services available ready for use. However sometimes you might have the need to start a certain service after that your deployments units are available. Let's see how we can choose to deploy a service after your applications.
A tutorial about the EJB3 Timer service is available here:
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>