このコンテンツは選択した言語では利用できません。

A.4. Variable Substitution


Overview

When defining properties for a profile, you can use a variable substitution mechanism, which has the general syntax ${ResourceReference}. This variable substitution mechanism can be used in any profile resource, including the agent properties, PID properties, and other resources—for example, the mq-base profile's broker.xml resource references the ${broker.name} and ${data} variables.

Simple variable substitution

Simple variables can be substituted in a profile resource using the following syntax:
${PropName}
Copy to Clipboard Toggle word wrap
Where PropName can be the name of any Java system property. In particular, Java system properties can be defined in the following locations:
  • The etc/system.properties file, relative to the container's home directory.
  • System property settings in the profile's agent properties.
Some of the more useful system properties defined in the etc/system.properties file are, as follows:
${karaf.home}
The directory where Red Hat JBoss Fuse is installed.
${karaf.data}
Location of the current container's data directory, which is usually ${karaf.home}/data for a main container or ${karaf.home}/instances/InstanceName/data for a child container.
${karaf.name}
The name of the current container.

Substituting a profile URL

The profile URL enables you to substitute properties from a specific PID. A variable substitution using a profile URL has the following format:
${profile:PID/Property}
Copy to Clipboard Toggle word wrap
Where PID is the OSGi Config Admin persistent ID (which corresponds to the profile resource PID.properties) and Property is the name of the property you want to substitute.
For example, the fabric profile's org.fusesource.fabric.maven.properties resource includes the following property setting:
remoteRepositories=${profile:org.fusesource.fabric.agent/org.ops4j.pax.url.mvn.repositories}
Copy to Clipboard Toggle word wrap
So that the remoteRepositories property is set to the value of the org.ops4j.pax.url.mvn.repositories agent property (org.fusesource.fabric.agent is the PID for the agent properties).

Substituting a zk URL

You can substitue the contents of a ZooKeeper node using the zk URL. The URL can be specified either as an absolute node:
${zk:/PathToNode}
Copy to Clipboard Toggle word wrap
Or you can reference configuration properties from a specific container using the following syntax:
${zk:ContainerName/Property}
Copy to Clipboard Toggle word wrap
The preceding syntax is effectively a short cut to the following URL reference:
${zk:/fabric/registry/containers/config/ContainerName/Property}
Copy to Clipboard Toggle word wrap

Recursive variable substitution

It is also possible to use a variable within a variable (recursive substitution). For example, the dosgi profile's org.fusesource.fabric.dosgi.properties resource defines the following property:
exportedAddress=${zk:${karaf.name}/ip}
Copy to Clipboard Toggle word wrap

How to reference the current version of a resource

A potential problem arises with ZooKeeper URLs if you need to reference a ZooKeeper node that has a version number embedded in it. For example, suppose you want to reference the my-profile profile's my-resource resource, which can be done using the following ZooKeeper URL:
 ${zk:/fabric/configs/versions/1.0/profiles/my-profile/my-resource}
Copy to Clipboard Toggle word wrap
Notice that the profile version number, 1.0, is embedded in this path. But if you decide to upgrade this profile to version 1.1, this means you must manually edit all occurrences of this ZooKeeper URL, changing the version number to 1.1 in order to reference the upgraded resource. To avoid this extra work, and to ensure that the URL always references the current version of the resource, you can use the following trick which exploits recursive variable substitution:
 ${zk:/fabric/configs/versions/${zk:/fabric/configs/containers/${karaf.name}}/profiles/my-profile/my-resource}
Copy to Clipboard Toggle word wrap
This works because the /fabric/configs/containers/${karaf.name} ZooKeeper node contains the current profile version deployed in the container.
トップに戻る
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2025 Red Hat