JBoss.org Community Documentation

3.5. Packaging a service

Now that we have successfully created and tested our service it is time to package it up so that others can use it. The simplest way to do this is to create a JAR containing all of the classes. You can choose to include the deployment descriptor if there is a sensible default way to configure the service but you are not required to do so.

If you do choose to include the deployment descriptor then by convention you should call it jboss-beans.xml and put it in a META-INF directory. This helps if you want to later deploy the service in JBoss AS 5 as the JAR deployer recognises this layout by default and will automatically perform the deployment.

In our case we will not include it as we want to configure the service by editing the descriptor directly as a separate file. To generate a JAR in the target directory containing all of the compiled classes simply enter mvn package from the humanResourcesService/ directory.

To make the JAR available to other maven projects you then need to enter mvn install in order to copy it to your local maven repository.

The final layout of the JAR is as follows:

org/jboss/example/service/Address.class
                         /Employee.class
                         /HRManager.class
org/jboss/example/service/util/AgeBasedSalaryStrategy.class
                              /LocationBasedSalaryStrategy.class
                              /SalaryStrategy.class
META-INF/MANIFEST.MF
META-INF/maven/org.jboss.microcontainer.examples/humanResourcesService/pom.xml
                                                                      /pom.properties

The META-INF/maven directory is automatically produced by maven and is required so that other maven projects can use this JAR as a dependency. If you are not using maven as your build system then you will not have this directory.