Archived

This forum has been archived. Please start a new discussion on GitHub.

Question on default values in parameters

Hi,

it seems like that it's not possible to use parameters as default values for other parameters in icegrids XML templating language.

Example:
[HTML]
<server-template id="MyTemplate">
<icebox id="${id}Box" exe="/usr/local/bin/icebox" activation="on-demand">
<parameter name="id"/>
<parameter name="providedBy" default="${id}"/>
<service name="${name}Service" entry="${providedBy}Service:create">
<adapter name="${service}" id="${name}" endpoints="ssl"/>
</service>
</icebox>
</server-template>
[/HTML]

Unfortunately this leads to the following exception on update:
error: IceGrid::DeploymentException:
node `Node1':
invalid value for attribute `default parameter `providedBy'':
invalid variable `${id}':
 undefined variable `id'

Is there any other way to model this in an elegant way, or will I have to define two separate templates? (the background is that there are many similar icebox services, providing one service per instance but a few libraries can provide different services depending on configuration.) So the way I intended to use this would be:

[HTML]
<server-instance id="Simple1" template="MyTemplate" />
<server-instance id="Simple2" template="MyTemplate" />
<server-instance id="Simple3" template="MyTemplate" />
<server-instance id="Red" providedBy="Colors" template="MyTemplate">
<properties service="${id}Service">
<property name="ColorHex" value="F00"/>
</properties>
</server-instance>
<server-instance id="Green" providedBy="Colors" template="MyTemplate">
<properties service="${id}Service">
<property name="ColorHex" value="0F0"/>
</properties>
</server-instance>
<server-instance id="Blue" providedBy="Colors" template="MyTemplate">
<properties service="${id}Service">
<property name="ColorHex" value="00F"/>
</properties>
</server-instance>
[/HTML]

cheers
Michael

Comments

  • benoit
    benoit Rennes, France
    Yes, a parameter can't depend on another parameter, see here for the semantics of variables and parameters in IceGrid descriptors.

    I would use 2 server templates instead:
    <icegrid>
      <application name="MyApp">
    
        <server-template id="MyTemplate">
          <parameter name="id"/>
          <icebox id="${id}Box" exe="/usr/local/bin/icebox" activation="on-demand">
            <service name="Service" entry="${id}Service:create">
              <adapter name="${service}" endpoints="ssl"/>
            </service>
          </icebox>
        </server-template>
    
        <server-template id="MyColorsTemplate">
          <parameter name="id"/>
          <parameter name="color"/>
          <icebox id="${id}Box" exe="/usr/local/bin/icebox" activation="on-demand">
            <service name="Service" entry="ColorsService:create">
              <adapter name="${service}" endpoints="ssl"/>
              <property name="ColorHex" value="${color}"/>
            </service>
          </icebox>
        </server-template>
    
        <node name="node1">
          <server-instance id="Simple1" template="MyTemplate"/>
          <server-instance id="Red" color="0F0" template="MyColorsTemplate"/>
        </node>
    
      </application>
    </icegrid>
    

    Cheers,
    Benoit.
  • Hi Benoit,

    what a pity. Colors was of course just an example, in practice there are many different of those and the general question was about having dynamic default values for parameters (deployed by somebody who can just use an existing template in the UI and add the properties as required). Well, in the end it's just an inconvenience ;)

    Thanks for your answer anyway.

    cheers
    Michael