True to our goal of simplifying the configuration of Mule, we will be adding the capacity to programmatically configure Mule 3 in the coming releases.
With configuration patterns aiming at reducing the amount of XML configuration and a new IDE in the works for graphically configuring Mule, the third angle we wanted to take on simplification was the creation of an API fluent enough that it becomes possible to configure Mule with your favorite JVM language.
If you’ve peeked into Mule 3’s source code, you may have noticed that this effort is already on-going. Indeed, each of the newly introduced configuration patterns is backed by a builder class that is used to instantiate it. Read on for a quick demonstration of how this can be used…
The following shows how to use the builder associated with the Simple Service configuration pattern to configure a fully functional SOAP-style web service:
To try the above example, you’ll need Mule 3.0.1 or above. At the time this post is written, Mule 3.0.1 is available as a development release.
As you can see, the API exposed by the builder is pretty fluent: a handful of chained methods is all it takes to expose a JAX-WS annotated POJO as a web service, WSDL included! The even cooler part is that this can be done at runtime, after Mule has been started.
This is of course just a first step towards a completely fluent API: we need a complete infrastructure to support the full extent of Mule’s configuration. Nevertheless, this example gives you a good idea of what we’re after.
What do you think about this approach? Is it something you’ve been looking for in previous Mule releases? Please feel free to share your suggestions and comments directly on this post.