ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder DefaultProjectBuilder.java
Date Tue, 21 May 2002 00:31:00 GMT
donaldp     02/05/20 17:31:00

  Modified:    container/src/java/org/apache/myrmidon/components/builder
                        DefaultProjectBuilder.java
  Log:
  Delegate to model builder.
  
  Revision  Changes    Path
  1.52      +22 -36    jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java
  
  Index: DefaultProjectBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant-myrmidon/container/src/java/org/apache/myrmidon/components/builder/DefaultProjectBuilder.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- DefaultProjectBuilder.java	18 May 2002 04:05:57 -0000	1.51
  +++ DefaultProjectBuilder.java	21 May 2002 00:31:00 -0000	1.52
  @@ -12,35 +12,34 @@
   import java.util.HashMap;
   import java.util.Map;
   import java.util.StringTokenizer;
  -import javax.xml.parsers.SAXParser;
  -import javax.xml.parsers.SAXParserFactory;
   import org.apache.avalon.excalibur.i18n.ResourceManager;
   import org.apache.avalon.excalibur.i18n.Resources;
   import org.apache.avalon.excalibur.io.FileUtil;
   import org.apache.avalon.framework.Version;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.Serviceable;
   import org.apache.myrmidon.api.metadata.ModelElement;
   import org.apache.myrmidon.components.property.DefaultNameValidator;
  +import org.apache.myrmidon.interfaces.builder.ModelBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectBuilder;
   import org.apache.myrmidon.interfaces.builder.ProjectException;
   import org.apache.myrmidon.interfaces.oldmodel.Dependency;
   import org.apache.myrmidon.interfaces.oldmodel.Project;
   import org.apache.myrmidon.interfaces.oldmodel.Target;
  -import org.apache.myrmidon.interfaces.model.ModelElementSaxHandler;
  -import org.xml.sax.ContentHandler;
  -import org.xml.sax.XMLReader;
   
   /**
    * Default implementation to construct project from a build file.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.51 $ $Date: 2002/05/18 04:05:57 $
  + * @version $Revision: 1.52 $ $Date: 2002/05/21 00:31:00 $
    *
    * @ant.type type="project-builder" name="ant2"
    */
   public class DefaultProjectBuilder
       extends AbstractLogEnabled
  -    implements ProjectBuilder
  +    implements ProjectBuilder, Serviceable
   {
       private static final Resources REZ =
           ResourceManager.getPackageResources( DefaultProjectBuilder.class );
  @@ -54,6 +53,13 @@
   
       // Use a name validator with the default rules.
       private DefaultNameValidator m_nameValidator = new DefaultNameValidator();
  +    private ModelBuilder m_modelBuilder;
  +
  +    public void service( final ServiceManager manager )
  +        throws ServiceException
  +    {
  +        m_modelBuilder = (ModelBuilder)manager.lookup( ModelBuilder.ROLE );
  +    }
   
       /**
        * build a project from file.
  @@ -82,12 +88,9 @@
                   return result;
               }
   
  -            // Parse the project file
  -            final ModelElementSaxHandler handler = new ModelElementSaxHandler();
  -            parseProject( systemID, handler );
  +            final ModelElement model = getModelBuilder().build( systemID );
   
               // Tranform the resulting model
  -            final ModelElement model = handler.getModel();
               transformProject( model );
               model.makeReadOnly();
   
  @@ -109,30 +112,13 @@
       }
   
       /**
  -     * Parses the project file using the supplied content handler.
  +     * retrieve ModelBuilder to use.
  +     *
  +     * @return the ModelBuilder
        */
  -    protected void parseProject( final String systemId,
  -                                 final ContentHandler contentHandler )
  -        throws Exception
  +    protected ModelBuilder getModelBuilder()
       {
  -
  -        try
  -        {
  -            final SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
  -            final SAXParser saxParser = saxParserFactory.newSAXParser();
  -            final XMLReader parser = saxParser.getXMLReader();
  -            parser.setFeature( "http://xml.org/sax/features/namespace-prefixes", false
);
  -            parser.setFeature( "http://xml.org/sax/features/namespaces", false );
  -            //parser.setFeature( "http://xml.org/sax/features/validation", false );
  -
  -            parser.setContentHandler( contentHandler );
  -            parser.parse( systemId );
  -        }
  -        catch( Exception e )
  -        {
  -            final String message = REZ.getString( "ant.project-parse.error" );
  -            throw new ProjectException( message, e );
  -        }
  +        return m_modelBuilder;
       }
   
       /**
  @@ -145,7 +131,7 @@
       }
   
       /**
  -     * build project from configuration.
  +     * build project from {@link ModelElement} tree.
        *
        * @param file the file from which configuration was loaded
        * @param model the project model
  @@ -245,7 +231,7 @@
        * Retrieve the version attribute from the specified model.
        * Throw exceptions with meaningful errors if malformed or missing.
        */
  -    private Version getVersion( final ModelElement model)
  +    private Version getVersion( final ModelElement model )
           throws ProjectException
       {
           final String versionString = model.getAttribute( VERSION_ATTRIBUTE );
  @@ -528,4 +514,4 @@
   
           return result;
       }
  -}
  +}
  \ No newline at end of file
  
  
  

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


Mime
View raw message