Re: Is there a tools to convert java dsl to xml ?
I also am a new user and tend to like XML. Maybe that will change as I get used to Camel. I don't know of any automated way, but you can get edit access to camel and make the changes yourself: http://camel.apache.org/how-do-i-edit-the-website.html Dan On Tue, Jun 9, 2015 at 3:11 AM, cloud wrote: > hi team, > > Is there a tools to convert java dsl to xml ? > Is every java dsl code have a equal xml counterpart? > > When I am reading the camel document's , there are many snippets code that > writen by java dsl . > > As a new user , sometimes I have to use xml instead of java dsl . > > In fact , I want to know how could I convert the below code to xml > > from("direct:start") > .setHeader("decisionSlip").method(OrderProcessorBean.class, > "calculateRoute") > .routingSlip("decisionSlip"); > > > thanks. > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015.html > Sent from the Camel - Users mailing list archive at Nabble.com. >
Re: Is there a tools to convert java dsl to xml ?
I'm the opposite. I avoid XML, and use Java DSL exclusively. I really like the way it reads, and easy to test using camel test On Tue, Jun 9, 2015 at 10:48 AM Dan Moore wrote: > I also am a new user and tend to like XML. Maybe that will change as I get > used to Camel. > > I don't know of any automated way, but you can get edit access to camel and > make the changes yourself: > http://camel.apache.org/how-do-i-edit-the-website.html > > Dan > > On Tue, Jun 9, 2015 at 3:11 AM, cloud wrote: > > > hi team, > > > > Is there a tools to convert java dsl to xml ? > > Is every java dsl code have a equal xml counterpart? > > > > When I am reading the camel document's , there are many snippets code > that > > writen by java dsl . > > > > As a new user , sometimes I have to use xml instead of java dsl . > > > > In fact , I want to know how could I convert the below code to xml > > > > from("direct:start") > > .setHeader("decisionSlip").method(OrderProcessorBean.class, > > "calculateRoute") > > .routingSlip("decisionSlip"); > > > > > > thanks. > > > > > > > > > > > > -- > > View this message in context: > > > http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > >
Re: Is there a tools to convert java dsl to xml ?
Hi, cloud wrote > Is there a tools to convert java dsl to xml ? No, although you can see an XML representation of a route defined in any DSL (Java, XML, Groovy, Scala etc.) by calling a method called dumpRouteAsXml() when looking at it though JMX. cloud wrote > Is every java dsl code have a equal xml counterpart? > > When I am reading the camel document's , there are many snippets code that > writen by java dsl . > > As a new user , sometimes I have to use xml instead of java dsl . Yes it does. A good reference (shameless self-promotion) is the Apache Camel Developer's Cookbook - it contains examples of every DSL element in both the Java and XML DSLs. cloud wrote > In fact , I want to know how could I convert the below code to xml > > from("direct:start") > .setHeader("decisionSlip").method(OrderProcessorBean.class, > "calculateRoute") > .routingSlip("decisionSlip"); decisionSlip Hope that helps. Jakub -- View this message in context: http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015p5768023.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Is there a tools to convert java dsl to xml ?
I should also say that there is a runtime tool that allows you to see the XML of running routes - HawtIO (http://hawt.io). Jakub -- View this message in context: http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015p5768024.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Is there a tools to convert java dsl to xml ?
Hi At runtime you can output any Camel route as xml, there is api on camel context or jmx api to do so. This is what tooling such as the camel commands / hawtio etc uses to visualize the running routes. On Tue, Jun 9, 2015 at 11:11 AM, cloud wrote: > hi team, > > Is there a tools to convert java dsl to xml ? > Is every java dsl code have a equal xml counterpart? > > When I am reading the camel document's , there are many snippets code that > writen by java dsl . > > As a new user , sometimes I have to use xml instead of java dsl . > > In fact , I want to know how could I convert the below code to xml > > from("direct:start") > .setHeader("decisionSlip").method(OrderProcessorBean.class, > "calculateRoute") > .routingSlip("decisionSlip"); > > > thanks. > > > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen - Red Hat, Inc. Email: cib...@redhat.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen hawtio: http://hawt.io/ fabric8: http://fabric8.io/
Re: Is there a tools to convert java dsl to xml ?
thanks for all ! jkorab , I will read you book , and follow you on Twitter . thanks . -- View this message in context: http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015p5768088.html Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Is there a tools to convert java dsl to xml ?
I was playing with just this a few weeks ago. Here's an example of what I got working. The one gotcha I encountered was that you can't use beans inline in the Java DSL. Instead you need to put the bean in the registry and reference it from there. Other than that it seems to work "as expected". Tim /** * Example of how to add a new route to a running Camel context. * The route is set as XML. The tricky bit is that any beans used in the route * need to be set to the registry before setting the route. */ package foo import org.apache.camel.model.language.XQueryExpression import org.apache.camel.model.language.GroovyExpression import org.apache.camel.model.* import org.apache.camel.* import org.apache.camel.builder.RouteBuilder import org.apache.camel.impl.DefaultCamelContext import org.apache.camel.impl.SimpleRegistry // define route 1 as XML String xml1 = ''' http://camel.apache.org/schema/spring";>\n\ ''' // generate route 2 and convert to XML RoutesDefinition routes = new RoutesDefinition() RouteDefinition route = routes.route() route.from("timer://foo?fixedRate=true&period=200") route.log("Hello from Java!") route.processRef("simpleProcessor2") // the reference to the bean in the registry String xml2 = ModelHelper.dumpModelAsXml(null, routes) println xml2 // create and start context long t0 = System.currentTimeMillis(); SimpleRegistry registry = new SimpleRegistry() CamelContext camelContext = new DefaultCamelContext(registry) camelContext.start() long t1 = System.currentTimeMillis(); System.out.println("Camel Context creation took " + (t1 - t0)); // add beans to the registry registry.put("simpleProcessor1", new SimpleProcessor("simpleProcessor1")) registry.put("simpleProcessor2", new SimpleProcessor("simpleProcessor2")) // set route to context RoutesDefinition routes1 = camelContext.loadRoutesDefinition(new ByteArrayInputStream(xml1.bytes)) camelContext.addRouteDefinitions(routes1.getRoutes()) long t3 = System.currentTimeMillis(); RoutesDefinition routes2 = camelContext.loadRoutesDefinition(new ByteArrayInputStream(xml2.bytes)) camelContext.addRouteDefinitions(routes2.getRoutes()) long t4 = System.currentTimeMillis(); System.out.println("New route creation took " + (t4 - t3)); // shutdown sleep(5000) camelContext.stop() On 09/06/2015 16:32, Claus Ibsen wrote: Hi At runtime you can output any Camel route as xml, there is api on camel context or jmx api to do so. This is what tooling such as the camel commands / hawtio etc uses to visualize the running routes. On Tue, Jun 9, 2015 at 11:11 AM, cloud wrote: hi team, Is there a tools to convert java dsl to xml ? Is every java dsl code have a equal xml counterpart? When I am reading the camel document's , there are many snippets code that writen by java dsl . As a new user , sometimes I have to use xml instead of java dsl . In fact , I want to know how could I convert the below code to xml from("direct:start") .setHeader("decisionSlip").method(OrderProcessorBean.class, "calculateRoute") .routingSlip("decisionSlip"); thanks. -- View this message in context: http://camel.465427.n5.nabble.com/Is-there-a-tools-to-convert-java-dsl-to-xml-tp5768015.html Sent from the Camel - Users mailing list archive at Nabble.com.