In the previous chapters we have learnt how to develop JMX MBean services using simple EJB 3.0 style annotations. In this trail we'll see how services can collaborate with other services, in other words we'll define the dependencies between services.
The @Depends annotation specifies that this service depends on the service created for calculateInterest. i.e. it cannot be started until the service created for calculateInterest has been started.
What about if your service is dependant on an array of Services ? no problem, simply add a comma to specify the list of dependany services.
One particular type of dependancy is the "Dependancy Injection". With this Instead of annotating the dependancy at Class level the dependencies are specified on fields and setter methods.
Here the effect of this annotation is the injection of the Service calculateInterest into our service through a setter method. Those familiar with framework like Spring will find familiar with this pattern.
You can define interceptors for your service beans in the same way as shown in EJB3 Interceptors. This example defines one in the ServiceThree bean class itself.
The call to ctx.proceed() causes the next object in the chain of interceptors to get invoked. At the end of the chain of interceptors, the actual bean method gets called.
In this trail, you learned how to develop JMX MBean services using simple EJB 3.0 style annotations. MBean services are very useful when you need to provide manageable services to other components or services inside the JBoss application server.
Download the code of this article here.