如何使用Scala Camel DSL进行类型转换(How to do type conversion with the Scala Camel DSL)

编程入门 行业动态 更新时间:2024-10-28 01:22:28
如何使用Scala Camel DSL进行类型转换(How to do type conversion with the Scala Camel DSL)

如何使用Camel Scala DSL进行类型转换?

换句话说,这个Java DSL示例的Scala DSL版本是什么:

from("file:/tmp/myfile").convertBodyTo(String.class).to("log:com.example")

How can I do type conversion with the Camel Scala DSL?

In other words, what is the Scala DSL version of this Java DSL example:

from("file:/tmp/myfile").convertBodyTo(String.class).to("log:com.example")

最满意答案

而不是convertBodyTo你应该使用as(...)方法。

如果您尝试在Scala和Java DSL元素之间找到映射,那么在源代码中查看的一个有用的地方是SAbstractDefinition。 这就是我找到你问题答案的方法,因为http://camel.apache.org/scala-dsl-eip.html只提到了另一个例子的一部分(并没有说它是convertBodyTo的替代品)

Instead of convertBodyTo you should use as(...) method.

If you try to find the mapping between Scala and Java DSL elements one of the useful places to take a look at in sources is SAbstractDefinition. This is how I found out the answer to your question because http://camel.apache.org/scala-dsl-eip.html only mentions as as part of another example (and doesn't say it's a replacement for convertBodyTo)

更多推荐

DSL,Scala,example,Java,file,电脑培训,计算机培训,IT培训"/> <meta name="d

本文发布于:2023-07-14 13:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104795.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   类型   Scala   DSL   Camel

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!