263.9. Spring XML での設定
Spring XML には、設定する 2 つのバリエーションがあります。Spring Bean を、Java DSL で行われる方法に似た PropertiesComponent
として定義できます。または、<propertyPlaceholder>
タグを使用できます。
<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent"> <property name="location" value="classpath:com/mycompany/myprop.properties"/> </bean>
<propertyPlaceholder>
タグを使用すると、設定が次のように少し新しくなります。
<camelContext ...> <propertyPlaceholder id="properties" location="com/mycompany/myprop.properties"/> </camelContext>
location タグを使用してプロパティーのロケーションを設定することは問題なく機能しますが、考慮すべきリソースが多数ある場合があり、Camel 2.19.0 以降では、専用の propertiesLocation を使用してプロパティーの場所を設定できます。
<camelContext ...> <propertyPlaceholder id="myPropertyPlaceholder"> <propertiesLocation resolver = "classpath" path = "com/my/company/something/my-properties-1.properties" optional = "false"/> <propertiesLocation resolver = "classpath" path = "com/my/company/something/my-properties-2.properties" optional = "false"/> <propertiesLocation resolver = "file" path = "${karaf.home}/etc/my-override.properties" optional = "true"/> </propertyPlaceholder> </camelContext>
ヒント
XML 内のキャッシュオプションの指定
Camel 2.10 以降では、Spring 内と Blueprint XML 内の両方で cache オプションの値を指定できます。