avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet BlockInfoSubTask.java ManifestSubTask.java PhoenixXDoclet.java blockinfo.j manifest.j
Date Tue, 26 Feb 2002 11:15:49 GMT
donaldp     02/02/26 03:15:49

  Added:       src/java/org/apache/avalon/phoenix/tools/xdoclet
                        BlockInfoSubTask.java ManifestSubTask.java
                        PhoenixXDoclet.java blockinfo.j manifest.j
  Log:
  Started to integrate XDoclet into the build process.
  Committed a task that generates the manifest and blockinfo from a properly decorated source
file.
  
  based on work originally Submitted By: vinay nair <vinayc77@yahoo.com>
  
  Revision  Changes    Path
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet/BlockInfoSubTask.java
  
  Index: BlockInfoSubTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.tools.xdoclet;
  
  import com.sun.javadoc.ClassDoc;
  import java.io.File;
  import xdoclet.TemplateSubTask;
  import xdoclet.XDocletException;
  
  /**
   * Generates BlockInfo 'xinfo' for Blocks
   *
   * @author <a href="mailto:vinay_chandran@users.sourceforge.net">Vinay Chandrasekharan</a>
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/02/26 11:15:48 $
   */
  public class BlockInfoSubTask 
      extends TemplateSubTask
  {
      public final static String SUBTASK_NAME = "blockinfo";
  
      private static final String GENERATED_FILE_NAME = "{0}.xinfo";
      private static final String DEFAULT_TEMPLATE_FILE = 
          "/org/apache/avalon/phoenix/tools/xdoclet/blockinfo.j";
  
      private static String c_classPattern;
  
      private String m_templatePath;
  
      public BlockInfoSubTask ()
      {
          setTemplateFile( new File( DEFAULT_TEMPLATE_FILE) );
          setDestinationFile( GENERATED_FILE_NAME );
          setOfType( "org.apache.avalon.phoenix.Block" );
  
          final TemplateSubTask.ExtentTypes extent = new TemplateSubTask.ExtentTypes();
          extent.setValue( "hierarchy" );
          setExtent( extent );
      }
  
      public void setTemplatePath( final String templatePath )
      {
          m_templatePath = templatePath;
          setTemplateFile( new File( templatePath ) );
      }
  
      public static String getClassPattern()
      {
          return c_classPattern;
      }
  
      public String getSubTaskName()
      {
          return SUBTASK_NAME;
      }
  
      public void setPattern( final String classPattern )
      {
          c_classPattern = classPattern;
      }
  
      /**
       * Called to validate configuration parameters.
       */
      public void validateOptions() 
          throws XDocletException
      {
          super.validateOptions();
  
          if( null == m_templatePath )
          {
              throw new XDocletException( "'templatePath' attribute is missing ." );
          }
  
          if( null == getTemplateFile() || 
              !(getTemplateFile().exists()) || getTemplateFile().isDirectory())
          {
              throw new XDocletException( "'template' file is missing parameter missing ."
);
          }
  
  
          if( null == getClassPattern() || getClassPattern().trim().equals( "" ) )
          {
              throw new XDocletException( "'pattern' parameter missing or empty." );
          }
  
          if( -1 == getClassPattern().indexOf( "{0}" ) )
          {
              throw new XDocletException( "'pattern' parameter does not have a " + 
                                          "'{0}' in it. '{0}' is replaced by Block " + 
                                          "name of the class under processing." );
          }
      }
  
      protected boolean matchesGenerationRules( final ClassDoc clazz )
          throws XDocletException
      {
          if( !super.matchesGenerationRules( clazz ) )
          {
              return false;
          }
          else if( clazz.isAbstract() )
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  }
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet/ManifestSubTask.java
  
  Index: ManifestSubTask.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.tools.xdoclet;
  
  import com.sun.javadoc.ClassDoc;
  import java.io.File;
  import xdoclet.TemplateSubTask;
  import xdoclet.XDocletException;
  
  /**
   * Generates Manifest file for Blocks
   *
   * @author <a href="mailto:vinay_chandran@users.sourceforge.net">Vinay Chandrasekharan</a>
   * @author <a href="mailto:peter@apache.org">Peter Donald</a>
   * @version $Revision: 1.1 $ $Date: 2002/02/26 11:15:48 $
   */
  public class ManifestSubTask
      extends TemplateSubTask
  {
      public static final String SUBTASK_NAME = "manifest";
  
      private static final String GENERATED_FILE_NAME = "manifest.mf";
      private static final String DEFAULT_TEMPLATE_FILE =
          "/org/apache/avalon/phoenix/tools/xdoclet/manifest.j";
  
      private static String c_classPattern;
  
      private String m_templatePath;
      private String m_manifestFile;
  
      public ManifestSubTask()
      {
          setTemplateFile( new File( DEFAULT_TEMPLATE_FILE) );
          setDestinationFile( GENERATED_FILE_NAME );
          setOfType( "org.apache.avalon.phoenix.Block" );
  
          final TemplateSubTask.ExtentTypes extent  = new TemplateSubTask.ExtentTypes();
          extent.setValue( "hierarchy" );
          setExtent( extent );
      }
  
      public void setTemplatePath( final String templatePath )
      {
          m_templatePath = templatePath;
          setTemplateFile(  new File( templatePath ) );
      }
  
      public void setManifestFile( final String manifestFile )
      {
          m_manifestFile = manifestFile;
          setDestinationFile( m_manifestFile );
      }
  
      public static String getClassPattern()
      {
          return c_classPattern;
      }
  
      public String getSubTaskName()
      {
          return SUBTASK_NAME;
      }
  
      public void setPattern( final String classPattern )
      {
          c_classPattern = classPattern;
      }
  
      /**
       * Called to validate configuration parameters.
       */
      public void validateOptions()
          throws XDocletException
      {
          super.validateOptions();
  
          if( null == m_manifestFile )
          {
              throw new XDocletException( "'manifestFile' attribute is missing ." );
          }
  
          if( null == getDestinationFile() ||
              getDestinationFile().trim().equals( "" ) )
          {
              throw new XDocletException( "Error with the 'manifestFile' attribute." );
          }
  
  
          if( null == getClassPattern() ||
              getClassPattern().trim().equals( "" ) )
          {
              throw new XDocletException( "'pattern' parameter missing or empty." );
          }
  
          if( -1 == getClassPattern().indexOf( "{0}" ) )
          {
              throw new XDocletException( "'pattern' parameter does not have a '{0}' in it.
" );
          }
      }
  
      protected boolean matchesGenerationRules( final ClassDoc clazz )
          throws XDocletException
      {
          if( !super.matchesGenerationRules( clazz ) )
          {
              return false;
          }
          else if( clazz.isAbstract() )
          {
              return false;
          }
          else
          {
              return true;
          }
      }
  }
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet/PhoenixXDoclet.java
  
  Index: PhoenixXDoclet.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.avalon.phoenix.tools.xdoclet;
  
  import java.util.Vector;
  import xdoclet.DocletTask;
  
  /**
   *
   * @author <a href="mailto:vinay_chandran@users.sourceforge.net">Vinay Chandrasekharan</a>
   * @version $Revision: 1.1 $ $Date: 2002/02/26 11:15:48 $
   */
  public class PhoenixXDoclet 
      extends DocletTask
  {
      private BlockInfoSubTask m_blockInfoSubTask;
      private ManifestSubTask m_manifestSubTask;
  
      public BlockInfoSubTask createBlockinfo()
      {
          m_blockInfoSubTask = new BlockInfoSubTask();
          return m_blockInfoSubTask;
      }
  
      public ManifestSubTask createManifest()
      {
          m_manifestSubTask = new ManifestSubTask();
          return m_manifestSubTask;
      }
  
        
      protected Vector getSubTasks()
      {
          final Vector subtasks = super.getSubTasks();
          subtasks.addElement( m_blockInfoSubTask );
          subtasks.addElement( m_manifestSubTask );
          return subtasks;
      }
  }
  
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet/blockinfo.j
  
  Index: blockinfo.j
  ===================================================================
  <?xml version="1.0"?>
  <!DOCTYPE blockinfo PUBLIC "-//PHOENIX/Block Info DTD Version 1.0//EN" 
                    "http://jakarta.apache.org/phoenix/blockinfo_1_0.dtd">
  
  <blockinfo>
  
    <!-- section to describe block -->
    <block>
      <version><XDtClass:classTagValue tagName="phoenix:version" default="1.0"/></version>
    </block>
  
    <!-- services that are offered by this block -->
    <services>
      <XDtClass:forAllClassTags tagName="phoenix:service">
        <service name="<XDtClass:classTagValue tagName="phoenix:service" paramName="name"/>"
                 version="<XDtClass:classTagValue tagName="phoenix:service" paramName="version"
default="1.0"/>" />
      </XDtClass:forAllClassTags>
    </services>
  
    <!-- services that are required by this block -->
    <dependencies>
      <XDtMethod:ifHasMethod name="compose" 
                             parameters="org.apache.avalon.framework.component.ComponentManager">
        <XDtMethod:setCurrentMethod name="compose"
                                    parameters="org.apache.avalon.framework.component.ComponentManager">
        <dependency>
          <service name="<XDtMethod:methodTagValue tagName="phoenix:dependency" paramName="name"/>"

                   version="<XDtMethod:methodTagValue tagName="phoenix:dependency" paramName="version"
default="1.0"/>"/>
        </dependency>
        </XDtMethod:setCurrentMethod>
      </XDtMethod:ifHasMethod>
    </dependencies>
  
  </blockinfo>
  
  
  
  1.1                  jakarta-avalon-phoenix/src/java/org/apache/avalon/phoenix/tools/xdoclet/manifest.j
  
  Index: manifest.j
  ===================================================================
  Manifest-Version: 1.0
  Created-By: Apache Avalon Project
  
  <XDtClass:forAllClasses abstract="false" type="org.apache.avalon.phoenix.Block">
  Name:	<XDtPackage:packageNameAsPath/>/<XDtClass:className/>.class
  Avalon-Block: true
  </XDtClass:forAllClasses>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message