Babel Extension creation

This page will explains how you can extends the DSL from Babel Camel by adding new keywords and grammar parts to the existing DSL.

Warning

The extension of the DSL requires some knowledge of the Scala language.

Existing Extensions

Create an extension

To create an extension, you need to create a new DSL, some definition objects and a Parser.

Explanation

  1. Choose a package for your the new extension like io.xtech.babel.camel.mock
  2. Create some definition objects that extends io.xtech.babel.fish.parsing.StepDefinition.
  3. Create a DSL with your new keywords using the definition objects. The DSL will take a io.xtech.babel.fish.BaseDSL and extends a io.xtech.babel.fish.DSL2BaseDSL
  4. Create a trait that extends io.xtech.babel.camel.parsing.CamelParsing.
    1. Declare your parser by defining a parse method which returns a Process type and add it to the steps of the trait.
    2. Declare an implicit method using your new DSL.

Example

import io.xtech.babel.camel.mock._

//The Mock extension is added simply by
//  extending the RouteBuilder with
val routeDef = new RouteBuilder with Mock {
  //the mock keyword is the same as typing
  //  to("mock:output1")
  from("direct:input").
    requireAs[String].
    mock("output1").
    //the mock keyword keeps the same body type (here: String)
    processBody(x => x.toUpperCase).
    mock("output2")

}