#### Nesting feature groups under features

It was mentioned in an earlier chapter that a <<feature-fk-init,feature may nest other features that reference it>>. [[fg-in-features]]It is also possible to nest a feature group under a feature with the condition that all the features included directly into the definition of the feature group reference the same parent feature.

For example, suppose we have a parent feature spec `featureP` and child feature specs `featureA` and `featureB`:

[source,xml]
----
 <feature-spec xmlns="urn:jboss:galleon:feature-spec:1.0" name="featureP">
   <params>
     <param name="parent" feature-id="true"/>
   </params>
 </feature-spec>
----

[source,xml]
----
 <feature-spec xmlns="urn:jboss:galleon:feature-spec:1.0" name="featureA">
   <refs>
     <ref feature="featureP"/>
   </refs>
   <params>
     <param name="parent" feature-id="true"/>
     <param name="a" feature-id="true"/>
   </params>
 </feature-spec>
----

[source,xml]
----
 <feature-spec xmlns="urn:jboss:galleon:feature-spec:1.0" name="featureB">
   <refs>
     <ref feature="featureP"/>
   </refs>
   <params>
     <param name="parent" feature-id="true"/>
     <param name="b" feature-id="true"/>
   </params>
 </feature-spec>
----

Now let's suppose that there is a group which includes features of `featureA` and `featureB` specs.
[source,xml]
----
<feature-group-spec name="group1" xmlns="urn:jboss:galleon:feature-group:1.0">

  <feature spec="featureA">
    <param name="a" value="a1"/>
  </feature>
  <feature spec="featureB">
    <param name="id" value="b1"/>
  </feature>

</feature-group-spec>
----

This group can be nested under any instance of `featureP` and parameter `parent` of the features in the group will implicitly be initialized to the value of parameter `parent` of the outer `featureP` instance.
[source,xml]
----
<config name="main">
  <feature spec="featureP">
    <param name="parent" value="p1"/>
    <feature-group name="group1"/>
  </feature>
  <feature spec="featureP">
    <param name="parent" value="p2"/>
    <feature-group name="group1"/>
  </feature>
</config>
----

The resulting config will include:

. `featureP:parent=p1`;

. `featureP:parent=p2`;

. `featureA:parent=p1,a=a1`;

. `featureA:parent=p2,a=a1`;

. `featureB:parent=p1,b=b1`;

. `featureB:parent=p2,b=b1`.

