JBoss.org Community Documentation

Chapter 29. Service POJOs (JBoss extension of EJB3) using deployment descriptors

This tutorial is similar to the "service" tutorial which shows how to use Service POJOs in JBoss. In this tutorial we will use deployment descriptors instead of annotations to configure the services.

Take a look at org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOne and the corresponding deployment descriptor META-INF/jboss.xml. The <service> tag defines it as a singleton service in JBoss. It implements org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOneRemote and org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOneLocal using the <business-remote> and <business-local> tags.

ServiceOne also implements org.jboss.tutorial.service_deployment_descriptor.bean.ServiceOneManagement identified through the <management> tag. JBoss will inspect this interface, and create and install an MBean implementing the attributes and operations defined in the interface. The MBean will work on the same singleton bean instance as the remote and local interfaces.

The META-INF/jboss.xml also shows that the default ObjectName of the service can be overriden using the <object-name> tag:


Take a look at org.jboss.tutorial.service_deployment_descriptor.bean.ServiceThree and org.jboss.tutorial.service_deployment_descriptor.bean.ServiceTwo where we use the @Depends annotation to add dependencies between services.


For a detailed explanation of @Depends in @Service, take a look at our "service" tutorial.

Building and Running

From the command prompt, move to the "service_deployment_descriptor" folder under the Section 1.3, “Set the EJB3_TUTORIAL_HOME”

Ant Users:

Make sure the "default" server configuration of JBossAS-5.x is running

$ ant
$ ant run

     [java] attribute value for singleton obtained via JMX is what we set via remote interface: 100
     [java] Hello from service One
     [java] Hello from service Two

Maven Users: Make sure the AS is not running.

$ mvn clean install -PRunSingleTutorial

On the server side when the application is deployed, you will notice these logs:

17:37:17,869 INFO  [STDOUT] ServiceOne - Started
17:37:17,910 INFO  [STDOUT] ServiceTwo - Started
17:37:17,949 INFO  [STDOUT] ServiceThree - Started


Notice that the order is maintained because of the dependencies we have configured on the @Service.