JBoss.org Community Documentation

4.2. Deploying the service

Once the client has been created we can proceed to deploy the Human Resources service. This is done by entering the 'd' option. You should see the following log output indicating that the BasicXMLDeployer has parsed the jboss-beans.xml file using the url and instantiated the beans found within.


The microcontainer is able to instantiate the beans as their classes are available in the extension classpath inside the lib/humanResourcesService.jar file. We could have equally placed these classes in an exploded directory structure and added this to the application classpath but in general you will package them in a JAR for convenience.

Notice that our deployment descriptor is entirely separate from the humanResourcesService.jar file. This is done on purpose so that you can easily edit it and test your changes by redeploying the service. The jboss-beans.xml file in the example contains some commented out fragments of XML that you can uncomment to configure it in different ways:

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="urn:jboss:bean-deployer:2.0 bean-deployer_2_0.xsd"

    <bean name="HRService" class="org.jboss.example.service.HRManager">
        <!-- <property name="hiringFreeze">true</property>
        <property name="salaryStrategy"><inject bean="AgeBasedSalary"/></property> -->

    <!-- <bean name="AgeBasedSalary" class="org.jboss.example.service.util.AgeBasedSalaryStrategy">
        <property name="minSalary">1000</property>
        <property name="maxSalary">80000</property>

    <bean name="LocationBasedSalary"
        <property name="minSalary">2000</property>
        <property name="maxSalary">90000</property>
    </bean> -->



Depending on how you access the service at runtime you may need to shutdown the application and restart it again to redeploy the service and see your changes. This reduces the flexibility of the application but results in faster performance at runtime. Alternatively you may be able to simply redeploy the service whilst the application is running. This increases flexilibity but results in slower runtime performance. Careful consideration of these tradeoffs must be made before deciding on the approach you will take.