Tuesday, August 26, 2008

Eclipse Templates for Apache Camel

If you didn't know already, Eclipse allows you to define custom templates for commonly used code snippets. Its a very neat feature for those of us who are memory challenged or don't like typing things twice!

I think that Apache Camel users could really benefit from having predefined templates for doing Camel routing. I also hear a lot of requests like "I have this Java DSL route, how do I do this in the Spring XML DSL?" so having both Java and XML templates for the same thing is essential.

You can find the templates I did up here & here. To import these browse to the template screens defined at:

Window -> Preferences -> Java -> Editor -> Templates
Window -> Preferences -> Web and XML -> XML Files -> Templates.

Once imported, you can type Ctrl + Space and then type 'camel' to search for the camel templates. You should see something like this in the Java and XML editors:

When you select, say a Content Based Router, you'll get a route something like this in the Java and XML editors:

The formatting was a bit wonky for these Eclipse templates so you might want to pretty up your routes before showing anyone else :)

Let me know what you think!