#### Model-only configs

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

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

IMPORTANT: Model only configs are merged into *all* the named configs of the installation that are associated with the same model as the model-only config.

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

The idea behind the model-only configs is to be able to define the base for a config 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:1.0"
              groupId="org.jboss.pm.test" artifactId="fp1" version="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:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="b" value="fp2-modelA"/>
      </feature>
    </origin>
  </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">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="a" value="fp2-modelB"/>
        <param name="b" value="fp2-modelB"/>
      </feature>
    </origin>
  </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 |org.jboss.pm.test:fp1: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 |org.jboss.pm.test:fp1:1.0.0.Final |feature1 |1 |fp1-modelA |fp1-modelA
|modelA |test |org.jboss.pm.test:fp2: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 |org.jboss.pm.test:fp1:1.0.0 |feature1 |1 |fp2-modelB |fp1-modelB
|===

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


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

Normally, model-only configs 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: Config model designers are encouraged to design configs in a way that model-only configs represent essential configuration and don't need to be excluded explicitly by the users or should be excluded in exceptional cases.

In a previous chapter it was described how the default configs 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 groupId="org.pm.test" artifactId="fp1" version="1.0.0.Final">
        <default-configs>
            <exclude model="model1"/>
        </default-configs>
    </feature-pack>
</installation>
----

`exclude` element above *does not* affect the model-only configs. It affects *only* the named configs. And in this specific example this fact will not make any difference on the result which is why, a user shouldn't care about it, since if the named configs are excluded, the model-only configs 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:1.0"
              groupId="org.jboss.pm.test" artifactId="fp1" version="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-modelB-main"/>
    </feature>
  </config>
</feature-pack>
----

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="c" value="fp2-modelA-main"/>
      </feature>
    </origin>
  </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
|org.jboss.pm.test:fp1: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:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
      <default-configs>
        <exclude model="modelA"/>
      </default-configs>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="c" value="fp2-modelA-main"/>
      </feature>
    </origin>
  </config>
</feature-pack>
----

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

The model-only config from *fp1* is still effective because it is considered being essential for any named config of *modelA*. In case it still has to be excluded from the provisioned config you can add `named-only-models="false"` attribute to `exclude` element, e.g.
[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
      <default-configs>
        <exclude model="modelA" named-only-models="false"/>
      </default-configs>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="c" value="fp2-modelA-main"/>
      </feature>
    </origin>
  </config>
</feature-pack>
----

`exclude` element above affects both named and model-only configs 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 configs

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

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
              groupId="org.jboss.pm.test" artifactId="fp1" version="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-modelB-main"/>
    </feature>
  </config>
</feature-pack>
----

[source,xml]
----
<feature-pack xmlns="urn:jboss:galleon:feature-pack:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
      <default-configs inherit="false"/>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="c" value="fp2-modelA-main"/>
      </feature>
    </origin>
  </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 provisioned installation of *fp2*. But it does not affect the model-only configs. So the model-only *modelA* config 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:1.0"
              groupId="org.jboss.pm.test" artifactId="fp2" version="1.0.0.Final">
  <dependencies>
    <dependency groupId="org.jboss.pm.test" artifactId="fp1" version="1.0.0.Final">
      <name>fp1-dep</name>
      <default-configs inherit="false" inherit-unnamed-models="false"/>
    </dependency>
  </dependencies>
  <config name="main" model="modelA">
    <origin name="fp1-dep">
      <feature spec="feature1">
        <param name="id" value="1"/>
        <param name="c" value="fp2-modelA-main"/>
      </feature>
    </origin>
  </config>
</feature-pack>
----

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
|===

