10.6. Fabric8 Karaf Blueprint サポートの追加
fabric8-karaf-blueprint は Aries PropertyEvaluator と、fabric8-karaf-core からのプロパティープレースホルダーリゾルバーを使用して、Blueprint XML ファイルのプレースホルダーを解決します。
手順
カスタム Karaf ディストリビューションに Blueprint サポートの機能を含めるには、プロジェクトの
pom.xmlファイルのstartupFeaturesセクションにfabric8-karaf-blueprintを追加します。<startupFeatures> ... <feature>fabric8-karaf-blueprint</feature> ... </startupFeatures>
例
Fabric8 エバリュエーターは、${env+service:MY_ENV_VAR} のようなチェーンされたエバリュエーターをサポートします。MY_ENV_VAR 変数を環境変数に対して解決する必要があります。結果はサービス関数を使用して解決されます。以下に例を示します。
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.2.0"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0
https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint
http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.3.0
http://aries.apache.org/schemas/blueprint-ext/blueprint-ext-1.3.xsd">
<ext:property-placeholder evaluator="fabric8" placeholder-prefix="$[" placeholder-suffix="]"/>
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="userName" value="$[k8s:secret:$[env:ACTIVEMQ_SERVICE_NAME]/username]"/>
<property name="password" value="$[k8s:secret:$[env:ACTIVEMQ_SERVICE_NAME]/password]"/>
<property name="brokerURL" value="tcp://$[env+service:ACTIVEMQ_SERVICE_NAME]"/>
</bean>
</blueprint>重要
入れ子のプロパティープレースホルダーの置換には Aries Blueprint Core 1.7.0 以上が必要です。