Service Lifecycle and Dependencies
JBoss recognises four special operations on your service's management interface.
- the service should do any setup and not reference another service
- the service can reference other services
- destroys links to other services
- destroys itself
You will notice it is two phase. In most circumstances only one phase is required, usually
to do work on other services, e.g. binding/unbinding to jndi.
NOTE: you do not have to implement all lifecyle operations
With the lifecycle operations implementated, you can setup dependencies between services.
i.e. JBoss ensures that the
operation on the dependee service is invoked before the dependent service.
e.g. if the
depends upon the
, the order of the operations at deployment will be:
TransactionService.create() DBService.create() TransactionService.start() DBService.start()
and at undeployment in the reverse order
DBService.stop() TransactionService.stop() DBService.destroy() TransactionService.destroy()
Notification based Dependencies
There are cases where it is desirable to associate the lifecycle of an MBean
with the the reception of certain JMX Notifications. Consider, for example, a service that needs to be started only after the reception of a notification indicating that the Tomcat connectors are active. For this kind of dependencies
you can use the BarrierController service.