0

Is there any tool available that can convert java DSL to XML route or vice versa.

I want to convert the following XML route into Java DSL

<route id="test">
    <from uri="file://{{VAR_DATA_PATH}}/test/xml"/>
    <multicast>
        <choice>
            <when>
                <xpath>/bookinfo</xpath>
                <doTry>
                    <to uri="downloadBook"/>
                    <marshal ref="xstream-utf8"/>
                    <to uri="another URI"/>
                    <doCatch>
                        <exception>java.lang.Exception</exception>
                        <handled>
                            <constant>false</constant>
                        </handled>
                        <to uri="3rd URI"/>
                    </doCatch>
                </doTry>
            </when>
            <when>
                <xpath>somePath</xpath>
                <to uri="4th URI" />
                <to uri="5th URI"/>
            </when>
        </choice>
        <to uri="6th URI" />
    </multicast>
</route>
DavidDomain
  • 14,976
  • 4
  • 42
  • 50
Ritesh
  • 1,053
  • 5
  • 16
  • 29
  • 1
    No there is no such tool. Its also easy to convert the xml to java code, as the DSL between XML and Java is from the same source. – Claus Ibsen Aug 04 '15 at 07:47

1 Answers1

1

From Java DSL to XML, it's fairly easy. You can use Hawtio or karaf's "route-info" command. Even though the routes are in Java DSL, when you view them it would be XML.

I'm not aware of the other way around (from XML to Java) but it's not difficult at all to do it yourself.

Ramin Arabbagheri
  • 790
  • 2
  • 11
  • 25