Skip to end of metadata
Go to start of metadata

Authors: Paul Hammant

Overview

Contextualized Dependency Lookup is the type of dependency resolution that Avalon, Loom, Keel and alike do. It is where the container or embedder hands dependencies after instantiation and via an interface/method that the component implements to indicate that it has dependencies. The method in question typically hands in an reference to the component that has a lookup mechanism. Only the component dependencies declared will be returned on lookup. Typically XML is used to describe the dependancies for a particular component.

Example

A component has to have service (component) declarations in an external file. The popular Loom (forked from Phoenix) container has .xinfo files for such needs. All Avalon container have some mechanism for storing configuration and assembly externally to the class. Cross referenced against the xinfo files, Loom's assembly.xml defines the implementations to be used for component types. This all Avalon components must be interface/implementation separated. This in itself is not a bad thing in my (Paul) opinion.

Using Contextualized Dependency Lookup Components Without a Container.

The downside of the this design is that components can only be used without the container with great difficulty. If at all. This a proper container is needed at all times, and you have to choose one for different purposes (that not withstanding the efforts of the Avalon team to make a single all-purpose container). If you do manage to instantiate components without a container, you might miss one of the essential service dependencies. The component-using class will continue to compile, but at run time it will be apparent that there are missing dependencies.

Container support

The Avalon and JContainer's Loom are the best example of containers that support contextulaized lookup. PicoContainer does not directly support this type of dependency resultion. See Avalon Framework page to see how this works.

  • No labels