#### Model-only configurations

Model-only configurations are the ones associated with a specific model using `model` attribute of `config` element but are not associated with any name.

IMPORTANT: Model-only configurations are meant to be merged into other configurations. The provisioned installation will contain only anonymous or named configs but not the model-only ones.

IMPORTANT: A model-only configuration is merged into *all* the named configurations of the installation associated with the same model as the model-only configuration.

NOTE: A model-only configuration will simply be ignored if the installation does not include any named configuration with the same model as the model-only configuration.

The idea behind the model-only configurations is to be able to define the base for a configuration of a specific model that every final configuration of that model should include. Model-only configs are always added into the configuration before the named model configs, i.e. the named configs will be added on top of the model-only ones and will overwrite them.

Here is an example:

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <config model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="a" value="fp1-modelA"/>
      <param name="b" value="fp1-modelA"/>
    </feature>
  </config>
  <config name="main" model="modelB">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="b" value="fp1-modelB"/>
    </feature>
  </config>
</feature-pack>
----

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final"/>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="b" value="fp2-modelA"/>
    </feature>
  </config>
  <config name="test" model="modelA">
    <feature spec="feature2">
      <param name="id" value="1"/>
      <param name="a" value="fp2-modelA"/>
      <param name="b" value="fp2-modelA"/>
    </feature>
  </config>
  <config model="modelB">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="a" value="fp2-modelB"/>
      <param name="b" value="fp2-modelB"/>
    </feature>
  </config>
  <config name="test" model="modelB">
    <feature spec="feature2">
      <param name="id" value="1"/>
      <param name="a" value="fp2-modelB"/>
      <param name="b" value="fp2-modelB"/>
    </feature>
  </config>
</feature-pack>
----

Installing these two feature-packs will result in the following configurations:
[%header,options="autowidth"]
|===
|Config model |Config name |Feature spec origin |Feature spec |id |a |b
|modelA |main |fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp1-modelA |fp2-modelA
|===

[%header,options="autowidth"]
|===
|Config model |Config name |Feature spec origin |Feature spec |id |a |b
|modelA |test |fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp1-modelA |fp1-modelA
|modelA |test |fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature2 |1 |fp2-modelA |fp2-modelA
|===

[%header,options="autowidth"]
|===
|Config model |Config name |Feature spec origin |Feature spec |id |a |b
|modelB |main |fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp2-modelB |fp1-modelB
|===

[%header,options="autowidth"]
|===
|Config model |Config name |Feature spec origin |Feature spec |id |a |b
|modelB |test |fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp2-modelB |fp2-modelB
|modelB |test |fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature2 |1 |fp2-modelB |fp2-modelB
|===


##### Excluding model-only configurations with the exclude element

Normally, model-only configurations are not supposed to be explicitly excluded. If a user excludes all the named configs of a specific model, the model-only configs of that model will implicitly be ignored by the provisioning mechanism.

NOTE: Configuration model designers are encouraged to design configurations in a way that model-only configurations represent essential configuration and don't need to be excluded explicitly by users or should be excluded in exceptional cases.

In a previous chapter it was described how the default configurations could be excluded from the provisioned installation by <<excl-configs-by-model,specifying their model name>>. Here is an example once again
[source,xml]
----
<installation xmlns="urn:jboss:galleon:provisioning:1.0">
    <feature-pack location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
        <default-configs>
            <exclude model="model1"/>
        </default-configs>
    </feature-pack>
</installation>
----

`exclude` element above *does not* affect the model-only configurations. It affects *only* the named configs. And in this specific example this fact will not make any difference on the result which is why, users shouldn't care about it, since if the named configurations are excluded, the model-only configurations will automatically be ignored by the provisioning mechanism. Let's look at an example where it makes a real difference.

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <config model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="a" value="fp1-modelA"/>
      <param name="b" value="fp1-modelA"/>
      <param name="c" value="fp1-modelA"/>
    </feature>
  </config>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="b" value="fp1-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final"/>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="c" value="fp2-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

If we install these feature-packs the resulting config will contain
[%header,options="autowidth"]
|===
|Feature spec origin |Feature spec |id |a |b |c
|fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp1-modelA |fp1-modelA-main |fp2-modelA-main
|===

If we exclude `modelA` like it was shown in the previous example *in the declaration of the dependency* on `fp1`, i.e.
[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
      <default-configs>
        <exclude model="modelA"/>
      </default-configs>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="c" value="fp2-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

If we install *fp2*, the provisioned configuration will contain
[%header,options="autowidth"]
|===
|Feature spec origin |Feature spec |id |a |b |c
|fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp1-modelA |fp1-modelA |fp2-modelA-main
|===

The model-only configuration from `fp1` is still effective because it is considered being essential for any named configuration of `modelA`. In case it still has to be excluded from the provisioned configuration you can add `named-only-models="false"` attribute to `exclude` element, e.g.
[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
      <default-configs>
        <exclude model="modelA" named-only-models="false"/>
      </default-configs>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="c" value="fp2-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

`exclude` element above affects both named and model-only configurations of `modelA` from feature-pack `fp1`.

IMPORTANT: `named-only-models` attribute is optional and if abscent its value is assumed to be `true`.

The provisioned configuration of `fp2` will now contain
[%header,options="autowidth"]
|===
|Feature spec origin |Feature spec |id |c
|org.jboss.pm.test:fp1:1.0.0.Final |feature1 |1 |fp2-modelA-main
|===

##### Disabling inheritance of the model-only configurations

In an earlier chapter it was shown <<disable-def-configs,how the default configurations of a feature-pack could be suppressed>>. Let's now include a model-only configuration in the example.

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <config model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="a" value="fp1-modelA"/>
      <param name="b" value="fp1-modelA"/>
      <param name="c" value="fp1-modelA"/>
    </feature>
  </config>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="b" value="fp1-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
      <default-configs inherit="false"/>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="c" value="fp2-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

With `inherit="false"` attribute of `default-configs` element we indicated that the default configs of `fp1` should not be included into the distribution provisioned from `fp2`. But it does not affect the model-only configs. So the model-only `modelA` configuration will still be effective in `fp2`.

IMPORTANT: `inherit-unnamed-models` attributes of `default-configs` element controls whether the model-only configs are inherited or not. The attribute is optional and if not present, its value is assumed to be `true`.

Here is an example that disables the inheritance of all the anonymous, named and model-only configs:
[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:2.0"
              location="fp2@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
  <dependencies>
    <dependency location="fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final">
      <default-configs inherit="false" inherit-unnamed-models="false"/>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <feature spec="feature1">
      <param name="id" value="1"/>
      <param name="c" value="fp2-modelA-main"/>
    </feature>
  </config>
</feature-pack>
----

The provisioned configuration of `fp2` will now contain
[%header,options="autowidth"]
|===
|Feature spec origin |Feature spec |id |c
|fp1@maven(org.jboss.universe:community-universe):1#1.0.0.Final |feature1 |1 |fp2-modelA-main
|===

