LAYERING

The inspiration for the layering mechanism in Lamino came from ATG Dynamo and a similar mechanism it provided for layered assembly of XML files. We adapted its ideas to the specific context of bean declaration, and two axes of extensibility emerged:

  • Extending or overriding beans
  • Extending or overriding bean properties

Configuration files specify their parent in the inheritance hierarchy by using the "extends" attribute on the top-level element, like this (all subsequent examples in Spring):

<beans extends="other-config.xml">

All configuration files in the inheritance hierarchy are combined together using the following rules.

EXTENDING OR OVERRIDING BEANS

One can choose to override a bean altogether, like this:

<bean id="TxMgr" extends="overrides" class="foo.bar.AltTxMgrImpl">

Or, one can choose to extend a bean, like this:

<bean id="ContentManager" extends="extends">

Extending a bean is done to be able to extend of override its properties, as in the sequel.

EXTENDING OR OVERRIDING BEAN PROPERTIES

Properties of a bean can be replaced, removed, or prepended and appended to, if they are collections. The following example replaces the value specified for the "variables" property by the parents in the inheritance hierarchy, by a new value (an empty list).

        <bean id="TextReplacer" extends="extends">
            <property name="variables" combine="replace">
                <list/>
            </property>
        </bean>
One can choose to remove the property value altogether, which will result in its taking its default value. It will be as if no value assignment was ever specified in the configuration.
        <bean id="TextReplacer" extends="extends">
            <property name="variables" combine="remove"/>
        </bean>
If one wants to append or prepend elements to a collection, while leaving the configured elements intact, there are two more options for the "combine" property.
        <bean id="TextReplacer1" extends="extends">
            <property name="variables" combine="append">
                <list>
                	<value>String 1</value>
                	<value>String 2</value>
                </list>
            </property>
        </bean>

        <bean id="TextReplacer2" extends="extends">
            <property name="variables" combine="prepend">
                <list>
                	<value>String 1</value>
                	<value>String 2</value>
                </list>
            </property>
        </bean>

Thinking in terms of whole components, instead of beans, this allows one to extend or override the particular values used in a component configuration file in order to create a customized instance of a component to use in a product or a deployment.

Extending a component assembly