如何使用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
发布评论