58.2. Spring XML 사용
다음 예제에서는 Castor를 사용하여 캐스트라 데이터 유형을 구성하는 Spring을 사용하여 해상을 해제하는 방법을 보여줍니다.
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:start"/>
<unmarshal>
<castor validation="true" />
</unmarshal>
<to uri="mock:result"/>
</route>
</camelContext>이 예에서는 데이터 유형을 한 번만 구성하고 여러 경로에서 재사용하는 방법을 보여줍니다. <castor> 요소를 <camelContext>에서 직접 설정해야 합니다.
<camelContext>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<dataFormats>
<castor id="myCastor"/>
</dataFormats>
<route>
<from uri="direct:start"/>
<marshal ref="myCastor"/>
<to uri="direct:marshalled"/>
</route>
<route>
<from uri="direct:marshalled"/>
<unmarshal ref="myCastor"/>
<to uri="mock:result"/>
</route>
</camelContext>