Javadoc Tags

Dependency Tag

Component types may declare multiple service dependencies through the service tag. Each service tag references a versioned service identifier that the container will supply to the component type on request relative to the declared dependency key.

Attributes

Attribute Required Description
type yes

The service interface classname that the component is dependent on.

version no

The service version. If not declared the service dependency shall match any version.

optional no

A value of 'true' or 'false'. If true, the supply of a dependency is at the discression of the container. If false (the default) a container is required to resolve and supply a service matching the dependency declaration.

Example

package net.osm;

/**
 * Example of a component declaring multiple service dependencies.
 *
 * @avalon.component version="1.0" name="demo"
 */
public class Demo implements Serviceable
{
    ...

   /**
    * Supply of dependent services to this component by 
    *  the container.
    * @param manager the service manager
    * @avalon.dependency key="home" type="Home" version="1.3" 
    * @avalon.dependency type="Resource" version="5" optional="true"
    */
    public void service( ServiceManager manager ) 
      throws ServiceException
    {
        m_home = (Home) manager.lookup( "home" );
        try
        {
            m_resource = (Resource) manager.lookup( 
              Resource.getClass().getName() );
        }
        catch( ServiceException se )
        {
            // it's optional
        }
    }
}

Generated meta-info type descriptor:

<type>
  <info>
    <version>1.3.0</version>
    <name>demo</name>
  </info>
  <dependencies>
    <dependency key="home" type="Home" version="1.3.0"/>
    <dependency type="Resource" version="5.0.0" optional="true"/>
  </dependencies>
</type>