Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

About the XML Configuration File

The most common way to configure Mule ESB is with Spring XML files that use custom Mule namespaces. This page describes the format of the file. Note that the XML schema and namespace declarations are filled in automatically when you see the Mule IDE.

XML Schema

The configuration files are based on XML schema, which are specified in the header.


         
      
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance
        xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
        xmlns:file="http://www.mulesoft.org/schema/mule/file"
        xsi:schemaLocation="
        http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd
        http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd
        http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/3.2/mule-file.xsd">

Be sure to specify all the necessary schema files. This can be time-consuming when setting up the configuration file, but importing schema provides the following time-saving benefits:

  • Auto-completetion and context-specific help in your favorite IDE

  • Design-time configuration validation

  • Typed properties

Namespaces

Each Mule module or transport has its own XML schema. When you import a schema, it has its own namespace. For example, the following lines from the previous header declare the jms namespace:


         
      
1
2
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.2/mule-jms.xsd"

This example binds the mule-jms.xsd schema to the jms namespace. Therefore, any XML element starting with <jms: assumes the element comes from the mule-jms.xsd schema.

Default Namespace

Typically, you set the Mule core schema as the default namespace for your configuration file. This means that any XML element without a prefix will come from the Mule core schema, (mule.xsd). To set the default namespace schema, specify xmlns immediately followed by the URL of the Mule schema, without the colon or namespace prefix you set in the previous example (e.g., xmlns instead of xmlns:jms):


          
       
1
2
3
4
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.2/mule.xsd">
   ...config...
</mule>

Spring

Although your configuration files appears to be Mule-specific, they are really just Spring configuration files when Mule-specific [extensions]. This approach allows you to use anything Spring offers within your Mule configuration, such as beans, factory beans, resource loaders, EJBs, JNDI, AOP, and even integration with other software such as jBPM, Gigaspaces, JBoss, Rules, etc.

To use the standard Spring elements, import the standard Spring namespaces:


         
      
1
2
3
4
5
6
7
8
9
10
11
xmlns:spring="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
...
    <spring:bean id="myBean" class="com.acme.CoolBean">
        <spring:property name="sessionFactory">
            <spring:ref local="mySessionFactory" />
        </spring:property>
        <spring:property name="configuration">
            <spring:value>my-config.xml</spring:value>
        </spring:property>
    </spring:bean>

For complete information on Spring configuration, see the Spring Framework reference documentation.

Merging Configuration Files

If you have multiple configuration files, you can import them into one configuration file so that you only have to specify one configuration. For example:


         
      
1
2
3
4
5
6
7
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns=http://www.mulesoft.org/schema/mule/core ....>
  <spring:beans>
    <spring:import resource="mule-sub-config1.xml" />
    <spring:import resource="mule-sub-config2.xml" />
  </spring:beans>
...