You can create default instances of your factory configuration
when using the OSGi metatype services. One of the design principles
of the Liberty profile is to keep user configuration as small and
simple as possible. By providing default instances of your factory
configurations, you don't have to add these configurations into the server.xml file.
Example
To provide a default configuration instance, you need
to include it in an XML file within your OSGi bundle, and reference
the file by using the
IBM-Default-Config header in
the bundle manifest file as follows:
IBM-Default-Config: OSGI-INF/wlp/defaultInstances.xml
The
format of the XML file is the same as that of the
server.xml file,
but you must specify a unique identifier for each instance. For example,
to provide a default instance of the
teenager configuration
that is used in the example on the
Single versus multiple configuration instances topic, the
defaultInstances.xml file
must have the following settings:
<server>
<teenager id="predefined-teen1" name="Susie" age="19" />
</server>
The default instance
is not exposed to users through the configuration schema, and therefore
it is not visible in the development tools; however, you can document
the instance so that your users can override the individual attributes
in their
server.xml files as follows:
<teenager id="predefined-teen1" age="13" />
This
line of code will override the
age attribute
of the default instance, but the
name attribute
remains valid.