As some may know, we have been working on our open source Mule IDE based on Eclipse. However, with the schema-based configuration in Mule, IntelliJ IDEA users get some great features to help them build mule applications quicker too.
Mule 2 XML configurations are defined in schemas. For every module and transport in Mule there is a schema that defines the configuration elements that can be used. For example the following defines the Mule schema (default namespace), the VM transport and the Quartz connector:
<?xml version="1.0" encoding="UTF-8"?>
Essentially the schemas in Mule 2 provide an XML Domain Specific Language (DSL) for constructing integrations and service compositions. The benefits of this approach over the Mule 1.x approach is that:
- there no longer class names in XML configuration files (unless you are plugging in a custom implementation)
- all available attributes for a configuration element are provided in the schema and which gives you auto-complete in many Xml editors. Previously, developers had to look at the documentation or JavaDoc to figure out what properties to set
- required elements and attributes are validated and enforced by the schema
- attributes are typed making validation more robust
When editing a Mule Xml in IntelliJ IDEA, you will get full code-complete for the modules imported into your XML file:
While you are filling out the details of your connector you can quickly get help about the attribute you are adding by hitting Ctrl+Q on OS X and Windows. You will get context help on that attribute.
The context help also works on configuration elements:
Creating new Mule XML files can be labourious since you need to define the namespaces and schema locations each time (in Eclipse this is much easier). You can greatly simplify this in IntelliJ IDEA by using ‘Live Templates’ (from the Options dialog). Live Templates are code snippets that can be inserted into any editor window simply by typing an abbreviation and hitting the Tab key. I have lots of templates set up but 3 are useful for creating new Mule configurations:
1. Mule Xml Configuration Template [m2]
2. New Namespace [ns]
Use this to add a new schema namespace. When the template is inserted you just need to type the Mule module name , i.e. ‘jms’ or ‘http’ and then hit the Enter key.
3. New Schema Location [sl]
Use this to add a new schema location. When the template is inserted you just need to type the Mule module name , i.e. ‘jms’ or ‘http’ and then hit the Enter key.