4. Beginner - Outsource SU configuration in a properties file

This tutorial teaches you how to externalize SU configuration in a dedicated properties file (on a special location or in the ServiceMix classpath).

Using this, you are able to change the service configuration without rebuilding your SU (just a service restart is required).

To do it, we use a Spring PropertyPlaceholderConfigurer.

Here is an example of it in a HTTP SU.

The HTTP SU xbean.xml looks like this :

xbean.xml
<beans xmlns:http="http://servicemix.apache.org/http/1.0"
       xmlns:myService="http://www.example.com/myService">

   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
         <value>classpath:/myService.properties</value>
      </property>
   </bean>

   <http:consumer service="myService"
                  endpoint="my-service-http-consumer"
                  locationURI="${service.locationURI}"/>

</beans>

You can see that the HTTP locationURI uses

${service.locationURI}
contained in the myService.properties (located in the ServiceMix classpath).

The myService.properties file simply contains :

myService.properties
service.locationURI=http://0.0.0.0:8081/myService