1.3. Spring XML 파일의 라우터 스키마

1.3.1. 네임스페이스

다음 XML 스키마의 namespace에 XML DSL between- Cryostatbelongs를 정의하는 라우터 스키마 Cryostat- Cryostat:

http://camel.apache.org/schema/spring

1.3.2. 스키마 위치 지정

라우터 스키마의 위치는 일반적으로 Apache 웹 사이트의 최신 버전의 스키마를 참조하는 http://camel.apache.org/schema/spring/camel-spring.xsd 로 지정됩니다. 예를 들어 Apache Camel Spring 파일의 루트 요소는 일반적으로 예 1.2. “라우터 스키마 위치 지정” 에 표시된 대로 구성됩니다.

예 1.2. 라우터 스키마 위치 지정

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
    <!-- Define your routing rules here -->
  </camelContext>
</beans>

1.3.3. 런타임 스키마 위치

런타임에 Apache Camel은 Spring 파일에 지정된 스키마 위치에서 라우터 스키마를 다운로드하지 않습니다. 대신 Apache Camel은 camel-spring JAR 파일의 루트 디렉토리에서 스키마 사본을 자동으로 선택합니다. 이렇게 하면 Spring 파일을 구문 분석하는 데 사용되는 스키마의 버전이 항상 현재 런타임 버전과 일치합니다. Apache 웹 사이트에 게시된 최신 버전의 스키마가 현재 사용 중인 런타임 버전과 일치하지 않을 수 있으므로 이는 중요합니다.

1.3.4. XML 편집기 사용

일반적으로 전체 기능을 갖춘 XML 편집기를 사용하여 Spring 파일을 편집하는 것이 좋습니다. XML 편집기의 자동 완성 기능을 사용하면 라우터 스키마를 준수하는 XML을 더 쉽게 작성할 수 있으며 XML이 잘못 구성된 경우 편집기는 즉시 경고할 수 있습니다.

XML 편집기는 일반적으로 xsi:schemaLocation 특성에 지정하는 위치에서 스키마를 다운로드하는 데 의존합니다. 편집하는 동안 올바른 스키마 버전을 사용하고 있는지 확인하려면 일반적으로 camel-spring.xsd 파일의 특정 버전을 선택하는 것이 좋습니다. 예를 들어 Apache Camel의 2.3 버전에 대한 Spring 파일을 편집하려면 다음과 같이 beans 요소를 수정할 수 있습니다.

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring-2.3.0.xsd">
...

편집을 완료하면 기본 camel-spring.xsd 로 다시 변경합니다. 현재 다운로드할 수 있는 스키마 버전을 확인하려면 웹 페이지인 http://camel.apache.org/schema/spring 로 이동합니다.