+

Search Tips   |   Advanced Search

Extensions to the OSGi metatype service

The Liberty runtime environment and developer tools recognize some extensions to the OSGi metatype specification for more complex configurations and a better presentation in a user interface.


Runtime metatype extensions

Add this namespace to the metatype.xml file to use the following extensions:

ibm:alias

The alias extension is used to define a user-friendly name for the configuration while reducing the risk of clashes in the names of configuration elements in server.xml.

The following example shows the ibm:alias: extension:

<OCD id="com.ibm.ws.jdbc.dataSource.properties"
    name="%properties" 
    description="%properties.desc"
     ibm:alias="properties">
   <AD id="username".../>
</OCD>

In this example properties is the user-friendly name for the configuration. The alias must be different from the id.

When the ibm:alias entry is used in server.xml, it must be prefixed with the product extension name. The product extension name for extensions installed in the default user location is usr. For product extensions defined to the Liberty profile installation using an extension-name.properties file in the wlp/etc/extension directory, the product extension name is the name chosen for extension-name.

For the metatype shown in the previous example, if the feature is installed in the default usr location then the following are examples of valid server.xml entries:

    <usr_properties username="JANE"/>

    <com.ibm.ws.jdbc.dataSource.properties username="JANE"/>

ibm:type

Standard attribute types are defined in the metatype specification. Several IBM extended types are available.

See Extended types.

ibm:reference

The reference attribute specifies the OCD type that a PID references. It is used only with the ibm:pid type and supports nesting of elements in server.xml; see Nesting configuration elements.

The following example shows the ibm:reference extension: <AD id="fooRef" type="String" ibm:type="pid" ibm:reference="com.ibm.ws.foo".../>

ibm:final

The final attribute indicates that the value cannot be specified in the config. Instead, the default value from the metatype is always used. Use name="internal" to indicate that tools not display this property.

The following example shows the ibm:final extension: <AD id="foo" name="internal" ibm:final="true" type="String" default=${someVariable}"/>

ibm:variable

The variable attribute is used to specify a variable to be used for the default value if one is not specified. The behavior is to choose, in order:

  • The value specified in server.xml

  • The value specified as a system property, for example in bootstrap.properties

  • The default value from the metatype

The following example shows ibm:variable: <AD id="traceString" ibm:variable="trace.string" default=*.all=enabled".../>

ibm:unique

The unique attribute indicates that a configuration value must be unique across all attribute definitions that use the same unique attribute group. The following unique attribute groups are supported:

default value syntax

We can use ${prop-name} syntax in default expressions to construct strings out of other configuration properties.

The following example shows a default value syntax:

<AD id="httpEndpoint.target"
    name="internal" description="internal use only" 
    ibm:final="true"  required="false" type="String"
     default="(&amp;(virtualHost=${id}) (enabled=true))"/>


Extended types

Duration

The duration type is used to express a time. It is described in multiple units of time. For example, "1h30m" would be an hour and a half. "1d5h10s" would be 1 day, 5 hours, and 10 seconds. The units are globalized, so users enter the values using abbreviations from their local language.

For English, the following list shows the available units:

  • d - Days

  • h - Hours

  • m - Minutes

  • s - Seconds

  • ms - Milliseconds

By default, when using the type duration, the value specified by the user is evaluated in milliseconds. For example, "10s" would be a long value of 10000 in the dictionary. Furthermore, if a user specifies a value without any unit, this value will be evaluated in milliseconds. For example, a value of "10" would be evaluated as 10 milliseconds. We can also specify the duration type such that it evaluates into a different unit. For example, specifying a value of "10" with ibm:type="duration(s)" will be evaluated as 10 seconds, and stored as 10 in the dictionary.

The following list shows the possible types:

  • duration(h)

  • duration(m)

  • duration(s)

  • duration(ms)

  • duration

There is no difference between specifying duration and duration(ms).

Always include a unit in the value, and express the value with the unit that is easiest to read. For example, instead of specifying a value of "7200" with ibm:type="duration(s)", specify the value as "2h".

The following examples show the duration type:

  • <AD id="timeout" type="String" ibm:type="duration(s)".../>

  • <AD id="timeout" type="String" ibm:type="duration".../>

Location

The location type allows UI tools to provide a more helpful presentation of attributes that represent various file and directory locations. It does not affect processing by the runtime environment. The dictionary object is always a String.

The following examples show the possible types:

location

References a file. The reference can be an absolute, relative file, or it can be a url to a file.

location(file)

References a file using an absolute or relative file path.

location(dir)

References a dir using an absolute or relative file path.

location(url)

References a file at the end of a url.

The following example shows the location type: <AD id="location" name="%appmgr.location.name" description="%appmgr.location.desc" type="String" required="true" ibm:type="location"/>

Password

The password type is used for password fields. When used, the dictionary object is an instance of com.ibm.wsspi.kernel.service.utils.SerializableProtectedString. The value of the password field is not logged in the trace file. Developer tools displays the encoding options that can be used for a password field. Valid encoding options are xor and aes.

The following example shows the password type: <AD id="password" type="String" ibm:type="password".../>

Hashed password

The passwordHash type is similar to the password type and is used for hashed password fields. When used, the dictionary object is an instance of com.ibm.wsspi.kernel.service.utils.SerializableProtectedString. The value of the hashed password field is not logged in the trace file. Developer tools displays the encoding options that can be used for a hashed password field. Valid encoding options are xor, aes, and hash.

Validate a new password against a hashed password using the PasswordUtil.encode(String, String, Map) method, with the following parameters:

  1. New password.

  2. Hash algorithm, which is obtained by calling the PasswordUtil.getCryptoAlgorithm method. The hash algorithm must match the algorithm of the hashed password.

  3. Properties object, where one of the properties uses PasswordUtil.PROPERTY_HASH_ENCODED for the key and the hashed password for the value.

If the return value of PasswordUtil.encode is the same as the hashed password, then the passwords match.

The following example shows the passwordHash type: <AD id="hashedPassword" type="String" ibm:type="passwordHash".../>

Pid

The pid type is used to reference another object in the config. It is used with the ibm:reference attribute and supports nesting of elements in the server.xml; see Nesting configuration elements.

The following example shows the pid type: <AD id="fooRef" type="String" ibm:type="pid" ibm:reference="com.ibm.ws.foo".../>

OnError

The onError type results in an instance of the onError enumeration in the dictionary. The possible values are WARN, FAIL, and IGNORE.

The following example shows the onError type: <AD id="errorBehavior" type="String" ibm:type="onError".../>


User interface metatype extensions

Add this namespace to the metatype.xml file to use the following extensions:

ibmui:localization

The localization extension is used to specify the metatype localization file. The metatype localization file is used to look up the translations for labels and descriptions of other UI extensions. In most cases, the value of the ibmui:localization extension matches the localization attribute on the <Metadata> element.

The following example shows the ibmui:localization extension:

<OCD id="com.ibm.ws.jdbc.dataSource.properties"
    name="%properties" 
    description="%properties.desc"
     ibmui:localization="OSGI-INF/l10n/metatype">
   <AD id="username".../>
</OCD>

ibmui:extraProperties

The extraProperties extension is used to indicate that an arbitrary set of configuration attributes can be set on this configuration.

The following example shows the ibmui:extraproperties extension:

<OCD id="com.ibm.ws.jdbc.dataSource.properties"
    name="%properties" 
    description="%properties.desc"
     ibmui:extraProperties="true">
   <AD id="username".../>
</OCD>

The label and description that is associated with extension is looked up in the metatype localization file (if one is specified using the ibmui:localization extension). For the extension label, first extraProperties.<ocd id>.name and then extraProperties.name keys are checked. For the extension description, first extraProperties.<ocd id>.description and then extraProperties.description keys are checked.

ibmui:group

The group extension is used to specify that the attribute belongs to a group. In the user interface, the attributes that are annotated with the same group are grouped.

The following examples show the ibmui:group extension:

  • <AD id="username" ibmui:group="userInfo".../>

  • <AD id="password" ibmui:group="userInfo".../>

  • <AD id="port" ibmui:group="hostInfo".../>

The group label and description information are looked up in the metatype localization file (if one is specified using the ibmui:localization extension). For the group label, first <group>.<ocd id>.name and then <group>.name keys are checked. For the group description, first <group>.<ocd id>.description and then <group>.description keys are checked.


Subtopics


Parent topic: Advanced Configuration

Concepts:

  • Product extension