380.4. Spring DSL での YAML の使用
Spring DSL でデータ形式を使用する場合には、最初にデータ形式を宣言する必要があります。これは DataFormats XML タグで行われます。
<dataFormats> <!-- here we define a YAML data format with the id snake and that it should use the TestPojo as the class type when doing unmarshal. The unmarshalTypeName is optional --> <yaml id="snake" library="SnakeYAML" unmarshalTypeName="org.apache.camel.component.yaml.model.TestPojo"/> <!-- here we define a YAML data format with the id snake-safe which restricts the classes to be loaded from YAML to TestPojo and those belonging to package com.mycompany --> <yaml id="snake-safe"> <typeFilter value="org.apache.camel.component.yaml.model.TestPojo"/> <typeFilter value="com.mycompany\..*" type="regexp"/> </yaml> </dataFormats>
そして、ルートでこれらの ID を参照できます。
<route> <from uri="direct:unmarshal"/> <unmarshal> <custom ref="snake"/> </unmarshal> <to uri="mock:unmarshal"/> </route> <route> <from uri="direct:unmarshal-safe"/> <unmarshal> <custom ref="snake-safe"/> </unmarshal> <to uri="mock:unmarshal-safe"/> </route>