COMPONENTS

All IoC containers supported by Lamino provide a facility whereby a sub-configuration is loaded from an external file. This facility enables some separation of concerns but has the following shortcomings:

  • There is no way to reuse this sub-configuration more than one time
  • There is no way to hide internals from the importer

Adding those two capabilities brings to life the notion of components. A component provides services to its importer (exported services) and requests services (imported services) from it.

Component

INSTANTIATING COMPONENTS

The syntax to import a component builds on the existing syntax for importing, but it adds optional directives for hiding and renaming services exported by the component, and providing imported services to it (all subsequent examples in Windsor Castle):

<include uri="WidsorComponent.xml">
	<hiding object="OtherPublicComponentToBeHidden"/>
	<renaming object="ExplicitlyPublicComponent" as="Compo1"/>
	<renaming object="ImplicitlyPublicComponent" as="Compo2"/>
	<providing object="NewObject" as="External"/>
</include>

Using this capability allows one to instantiate (import) the same component more than once, without objects in the many instances conflicting with one another.

COMPONENT SYNTAX

A component is basically just a fragment of configuration. The only modification of the syntax is the ability to mark objects as public or hidden:

<configuration>
	<components>
		<component id="ExplicitlyPublicComponent" visibility="public">
			<parameters>
				<Property3>foobar original</Property3>
				<Property4>${Hidden}</Property4> 
			</parameters>
		</component>
		<component id="ImplicitlyPublicComponent">
			<parameters>
				<Property6>foobaz original</Property6>
				<Property7>${External}</Property7> 
			</parameters>
		</component>
		<component id="OtherPublicComponentToBeHidden"/>
		<component id="Hidden" visibility="private">
			<parameters>
				<Property5>baz original</Property5>
			</parameters>
		</component> 
	</components>
</configuration>

Hidden objects cannot conflict with other objects of the importing configuration.

Extending a component, to create a derived component, is done as described in the page about Layering.