Mule IntelliJ Tips

January 21 2009


As some may know, we have been working on our open source Mule 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.

Quick Introduction

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:

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:

Unfortunately, these Xml editing features do not currently work with Eclispe unless you are using the Altova Xml Spy Eclipse plugin or Oxygen Xml for Eclipse.

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]

This can be used in a blank XML document.

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.

We'd love to hear your opinion on this post

7 Responses to “Mule IntelliJ Tips”

  1. Ross, for me the quick doc lookup is Ctrl-Q (standard quick doc for any file type in IDEA). Same for both win and linux. Probably you have a typo, as Ctrl-J is a live template shortcut for me.

    On the other hand, I wish they could export Live Templates in IDEA, so far this seems to be the only section which wasn’t transferable between IDEA instances.

  2. Thanks Andrew, I have updated the post. I agree that it would be go to be able to export Live Templates.

  3. Here’s another tip, though now also Maven-related. There is a major bug in the current publicly available maven-idea-plugin, which really hinders development for projects depending on Mule classes. By default, it generates wrong source artifact file paths for test-jar dependencies (Mule TCK classes, for example).

    So, this is the patch and here’s the svn checkout link:

    Unfortunately, the development of the plugin has stalled (time to change an owner?), there was no response for about 2 months. Maybe casting more votes on the issue will change it?

  4. Any plans in developing an IDEA plug-in to debug services in Mule like you can do with Eclipse?

    Richard L. Burton III

  5. Rich,
    Unfortunately we don’t have any IDEA developers…

  6. What I do to achieve it in IDEA is create a Java application Run config, specify org.mule.MuleServer as the main class and pass it a -config my-mule-config.xml parameter.

  7. The quick-doc lookup is Ctrl-J on macs, Ctrl-Q on everything else.