Menu Close
9.6. OSGi 設定の機能への追加
アプリケーションが OSGi Configuration Admin サービスを使用する場合は、機能定義の config
子要素を使用して、このサービスの設定を指定できます。たとえば、prefix
プロパティーに値 MyTransform が設定されていること
を指定するには、以下の config
子要素を機能の設定に追加します。
<?xml version="1.0" encoding="UTF-8"?>
<features name="MyFeaturesRepo">
<feature name="example-camel-bundle">
<config name="org.fusesource.fuseesb.example">
prefix=MyTransform
</config>
</feature>
</features>
config
要素の name
属性は、プロパティー設定 の永続 ID を指定します(永続 ID は、プロパティー名の名前スコープとして機能します)。config
要素の内容は、Java プロパティーファイルと同じ方法で解析されます。
config
要素の設定は、以下のように、永続 ID の後に名前が付けられる InstallDir/etc
ディレクトリーにある Java プロパティーファイルの設定によって任意で上書きできます。
InstallDir/etc/org.fusesource.fuseesb.example.cfg
上記の設定プロパティーを使用する方法の例として、OSGi 設定プロパティーにアクセスする以下の Blueprint XML ファイルを見てみましょう。
<?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:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"> <!-- osgi blueprint property placeholder --> <cm:property-placeholder id="placeholder" persistent-id="org.fusesource.fuseesb.example"> <cm:default-properties> <cm:property name="prefix" value="DefaultValue"/> </cm:default-properties> </cm:property-placeholder> <bean id="myTransform" class="org.fusesource.fuseesb.example.MyTransform"> <property name="prefix" value="${prefix}"/> </bean> </blueprint>
このブループリント XML ファイルが example-camel-bundle
バンドルにデプロイされると、プロパティー参照 ${prefix}
は feature リポジトリーの config
要素によって指定される MyTransform
の値に置き換えられます。