179.7. インライン Simple 例外
Camel 2.18 から利用可能
Simple 構文 ${xxx} を使用して、JSonPath 式でインライン化された Simple 言語式を使用できるようになりました。以下に例を示します。
from("direct:start")
.choice()
.when().jsonpath("$.store.book[?(@.price < ${header.cheap})]")
.to("mock:cheap")
.when().jsonpath("$.store.book[?(@.price < ${header.average})]")
.to("mock:average")
.otherwise()
.to("mock:expensive");
XML DSL の場合:
<route>
<from uri="direct:start"/>
<choice>
<when>
<jsonpath>$.store.book[?(@.price < ${header.cheap})]</jsonpath>
<to uri="mock:cheap"/>
</when>
<when>
<jsonpath>$.store.book[?(@.price < ${header.average})]</jsonpath>
<to uri="mock:average"/>
</when>
<otherwise>
<to uri="mock:expensive"/>
</otherwise>
</choice>
</route>
以下のように allowSimple オプションを false に設定すると、インラインの Simple 式のサポートをオフにできます。
.when().jsonpath("$.store.book[?(@.price < 10)]", false, false)
XML DSL の場合:
<jsonpath allowSimple="false">$.store.book[?(@.price < 10)]</jsonpath>