Widgets pattern
Widgets are identical subroutines distinguished by their position in the configuration tree.
In the example in Table 1, there are two request/reply operations that call on two identical solicit/response operations. The requests use the solicits' position to call only one of the subroutines.
Example | Description |
---|---|
<folder name="Widgets"> <service name="Waiter" provision="subr"/> <mix name="Mix"> <request name="GetBeer" fields="GET" service="Waiter"> <prop name="subr.spec" ancestor="Alcoholic" function="FunBeer"/> <reply name="Ok" fields="beer"/> </request> </mix> <mix name="Alcoholic"> <solicit name="Order" clients="Waiter" fields="ORDER" service="Sequencer"> <prop name="subr.spec" function="FunBeer"/> <response name="Ok" fields="drink"> <prop name="params"><![CDATA[ beer:drink ]]></prop> </response> </solicit> </mix> <mix name="NonAlcoholic"> <solicit name="Order" clients="Waiter" fields="ORDER" service="Sequencer"> <prop name="subr.spec" function="FunBeer"/> <response name="Ok" fields="drink"> <prop name="params"><![CDATA[ beer:drink ]]></prop> </response> </solicit> </mix> </folder> |
The request/reply operation could call either solicit/response as:
The only distinction between the two solicits is a folder that exists somewhere above them. The
ancestor attribute of the
request/reply uses the folder names to differentiate between the two solicits.Tip: Since a mix counts as a folder, it can also be used
as a value for the
ancestor attribute.Without the
In either mix containing the solicits, there can be any number of
different operations that help |