link
Avalon
Meta-Info Ganerator Ant Task
Home PlanetProductsCentral
Ant Meta-Info Generator Task

The meta info generator task scans sources files for the present of an avalon.meta tags and based on the tag set specification, generates either XML or serialized meta-info descriptors.

Parameters
ParameterRequiredValue
destDirtrue The directory into which the generated type and service defintions wil be created.
formatfalse The output format. May be one of xml or serial. The xml format is less compact but more portable. The serial format is appropriate when usage is know to be in the context of the Avalon Meta API. The serial format is a serialized representation of the corresponding Task or Service instance.
forcefalse A boolean flag to force regenerating of the meta-files. false (default) will generate the meta-file if the source is newer than the exisiting meta-file or if the meta-file does not exist. true will overwrite any existing meta-file irrespective of the modification date.
postfixfalse Select between "xinfo" and "xtype" as the meta-info file type that is generated. The xtype postfix is convinient when generating meta info descriptors that must cooexist with the Phoenix platform.
Nested Elements
ElementRequiredValue
filesettrue A fileset containing the defintion of the source files to be included in the scanning phase.
Ant Example
  <target name="meta" description="Generates the XML descriptors" depends="build">
    <mkdir dir="${meta.dir}" />
    <taskdef name="meta" classname="org.apache.avalon.meta.info.ant.MetaTask">
      <classpath refid="project.class.path" />
    </taskdef>
    <meta destDir="${meta.dir}" format="xml">
      <fileset dir="${src}">
        <include name="**/*.java"/>
      </fileset>
    </meta>
  </target>
Example
Java source with Tag markup

import java.io.File;

import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.Contextualizable;
import org.apache.avalon.framework.context.ContextException;

/**
 * An example component containing meta info under javadoc tags.
 *
 * @avalon.component name="secondary-component" version="2.4" lifestyle="singleton"
 * @avalon.service type="SecondaryService:0.1"
 */
public class Secondary extends AbstractLogEnabled 
  implements Serviceable, SecondaryService, Contextualizable
{
    private Logger m_system = null;
    private File m_home = null;
    private PrimaryService m_primary = null;

   /**
    * Supply of a logging channel to the component.
    * @param logger the logging channel
    * @avalon.logger name="system"
    */
    public void enableLogging( Logger logger )
    {
        super.enableLogging( logger );
        m_system = logger.getChildLogger( "system" );
    }

   /**
    * Supply of the runtime context by the container.
    * @param context the runtime context
    * @avalon.entry key="home" type="java.io.File"
    */
    public void contextualize( Context context ) throws ContextException
    {
        m_home = (File) context.get("home");
    }    

   /**
    * Supply of dependent services to this component by the container.
    * @param manager the service manager
    * @avalon.dependency type="PrimaryService" version="1.3" key="primary"
    */
    public void service( ServiceManager manager ) throws ServiceException
    {
        m_primary = (PrimaryService) manager.lookup( "primary" );
        m_system.info( "resolved primary service reference" );
    }
}
Generated meta-info descriptor
<?xml version="1.0" ?>
<!DOCTYPE type PUBLIC "-//AVALON/Type DTD Version 1.0//EN" 
  "http://avalon.apache.org/dtds/meta/type_1_1.dtd" >

<type>
  <info>
    <name>secondary-component</name>
    <version>2.4.0</version>
    <lifestyle>singleton</lifestyle>
  </info>
  <loggers>
    <logger name="system"/>
  </loggers>
  <context>
    <entry key="home" type="java.io.File"/>
  </context>
  <services>
    <service type="SecondaryService" version="0.1.0"/>
  </services>
  <dependencies>
    <dependency key="primary" type="PrimaryService" version="1.3.0"/>
  </dependencies>
</type>