Provide default instances of factory configurations
We can create default instances of the 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 the factory configurations, we don't have to add these configurations into server.xml.
Example
To provide a default configuration instance, we need to include it in an XML file within the OSGi bundle, and reference the file 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 server.xml, but we must specify a unique identifier for each instance. For example, to provide a default instance of the teenager configuration 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, we can document the instance so the 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.
Parent topic: Single versus multiple configuration instances