You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Erik Hatcher <eh...@apache.org> on 2002/02/03 04:01:39 UTC

Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Scott,

Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
for XMLLogger (yes, which is inappropriately named - and I'm going to
convert it to an actual BuildLogger soon)?

I just can't help but cringe with code duplication or cut-and-pasting - so
if your XMListener is a plug-in replacement for our XMLLogger then we'd
gladly replace ours and you could use it from Ant's codebase instead.

    Erik

----- Original Message -----
From: <sa...@apache.org>
To: <ja...@apache.org>
Sent: Saturday, February 02, 2002 9:53 PM
Subject: cvs commit:
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
Vindico.java XMLListener.java


> sanders     02/02/02 18:53:01
>
>   Added:       proposal/vindico/src/java/org/apache/alexandria/ant
>                         Vindico.java XMLListener.java
>   Removed:     proposal/vindico/src/java/org/apache/alexandria
Vindico.java
>   Log:
>   Created a faster XMLListener than the DOM based one
>   in Ant.
>
>   Revision  Changes    Path
>   1.1
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/Vindi
co.java
>
>   Index: Vindico.java
>   ===================================================================
>   /*
>    * $Header:
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
/ant/Vindico.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
>    * $Revision: 1.1 $
>    * $Date: 2002/02/03 02:53:01 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution, if
>    *    any, must include the following acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
itself,
>    *    if and wherever such third-party acknowlegements normally appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
>    *    Foundation" must not be used to endorse or promote products
derived
>    *    from this software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache"
>    *    nor may "Apache" appear in their names without prior written
>    *    permission of the Apache Group.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    *
>    */
>   package org.apache.alexandria.ant;
>
>
>   import org.apache.alexandria.exc.VindicoException;
>   import org.apache.alexandria.om.Workspace;
>   import org.apache.alexandria.om.WorkspaceLoader;
>   import org.apache.tools.ant.BuildException;
>   import org.apache.tools.ant.Task;
>
>
>   /**
>    * Vindico provides ...
>    *
>    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
>    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
>    */
>   public class Vindico extends Task {
>
>       private String workspace;
>
>       public String getWorkspace() {
>           return workspace;
>       }
>
>       public void setWorkspace(String workspace) {
>           this.workspace = workspace;
>       }
>
>       public void execute() throws BuildException {
>           Workspace space = new Workspace();
>           space = WorkspaceLoader.loadWorkspace(space, workspace);
>           String basedir = space.getBasedir();
>           this.getProject().setProperty("vindico.basedir", basedir);
>           try {
>               space.execute();
>           } catch (VindicoException ve) {
>               throw new BuildException(ve.getMessage(), ve);
>           }
>       }
>   }
>
>
>
>   1.1
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/XMLLi
stener.java
>
>   Index: XMLListener.java
>   ===================================================================
>   /*
>    * $Header:
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
/ant/XMLListener.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
>    * $Revision: 1.1 $
>    * $Date: 2002/02/03 02:53:01 $
>    *
>    * ====================================================================
>    *
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with or without
>    * modification, are permitted provided that the following conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above copyright
>    *    notice, this list of conditions and the following disclaimer.
>    *
>    * 2. Redistributions in binary form must reproduce the above copyright
>    *    notice, this list of conditions and the following disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the redistribution, if
>    *    any, must include the following acknowlegement:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowlegement may appear in the software
itself,
>    *    if and wherever such third-party acknowlegements normally appear.
>    *
>    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
>    *    Foundation" must not be used to endorse or promote products
derived
>    *    from this software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called "Apache"
>    *    nor may "Apache" appear in their names without prior written
>    *    permission of the Apache Group.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>    * SUCH DAMAGE.
>    * ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation.  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    *
>    */
>   package org.apache.alexandria.ant;
>
>
>   import java.io.FileWriter;
>   import java.io.StringWriter;
>   import java.io.PrintWriter;
>   import java.text.ChoiceFormat;
>   import java.text.MessageFormat;
>   import java.text.SimpleDateFormat;
>   import java.util.Date;
>
>   import org.apache.alexandria.util.XMLHelper;
>   import org.apache.tools.ant.BuildEvent;
>   import org.apache.tools.ant.BuildListener;
>
>
>   /**
>    * XMLListener provides ...
>    *
>    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
>    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
>    */
>   public class XMLListener implements BuildListener {
>
>       private XMLHelper helper;
>       private FileWriter writer;
>       private long startTime;
>
>
>       private static String[] priorities = new String[]{"ERROR", "WARN",
"INFO", "VERBOSE", "DEBUG"};
>
>       /**
>        * Code borrowed from Ant's DefaultLogger since it was private
>        */
>       private final static MessageFormat MINUTE_SECONDS =
>               new MessageFormat("Total time: {0}{1}.");
>
>       private final static double[] LIMITS = {0, 1, 2};
>
>       private final static String[] MINUTES_PART =
>               {"", "1 minute, ", "{0,number} minutes, "};
>
>       private final static String[] SECONDS_PART =
>               {"no seconds", "1 second", "{1,number} seconds"};
>
>       private final static ChoiceFormat MINUTES_FORMAT =
>               new ChoiceFormat(LIMITS, MINUTES_PART);
>
>       private final static ChoiceFormat SECONDS_FORMAT =
>               new ChoiceFormat(LIMITS, SECONDS_PART);
>
>       static {
>           MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
>           MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
>       }
>
>       private final static SimpleDateFormat TIME_FORMAT =
>               new SimpleDateFormat("HH:mm");
>
>       /**
>        * Code borrowed from Ant's DefaultLogger since it was protected
>        */
>       protected static String formatTime(long millis) {
>           long seconds = millis / 1000;
>           long minutes = seconds / 60;
>
>           Object[] args = {
>               new Long(minutes),
>               new Long(seconds % 60)
>           };
>
>           return MINUTE_SECONDS.format(args);
>       }
>
>       /**
>        * Taken from Ant's StringUtils.
>        */
>       public static String getStackTrace(Throwable t) {
>           StringWriter sw = new StringWriter();
>           PrintWriter pw = new PrintWriter(sw, true);
>           t.printStackTrace(pw);
>           pw.flush();
>           pw.close();
>           return sw.toString();
>       }
>
>
>       public void buildStarted(BuildEvent event) {
>           startTime = System.currentTimeMillis();
>           writer = new
FileWriter(event.getProject().getProperty("vindico.log.file"));
>           helper = new XMLHelper(writer);
>           helper.element("ant-build");
>       }
>
>       public void buildFinished(BuildEvent event) {
>           long endTime = System.currentTimeMillis();
>           long totalTime = endTime - startTime;
>           helper.attribute("start-time", TIME_FORMAT.format(new
Date(startTime)));
>           helper.attribute("end-time", TIME_FORMAT.format(new
Date(endTime)));
>           helper.attribute("total-time", formatTime(startTime));
>           helper.element("build-stats", true);
>
>           if (event.getException() != null) {
>               helper.attribute("exception",
event.getException().toString());
>               helper.element("build-error");
>
>               Throwable t = event.getException();
>               helper.element("stack-trace", getStackTrace(t), true);
>
>               helper.popElement();
>           }
>
>           helper.popElement(); //root element
>           writer.close();
>       }
>
>       public void targetStarted(BuildEvent event) {
>           helper.attribute("name", event.getTarget().getName());
>           helper.element("target");
>       }
>
>       public void targetFinished(BuildEvent event) {
>           helper.popElement();
>       }
>
>       public void taskStarted(BuildEvent event) {
>           helper.attribute("name", event.getTask().getTaskName());
>           //FIXME - Should we add the Ant Location info here?
>           helper.element("task");
>       }
>
>       public void taskFinished(BuildEvent event) {
>           helper.popElement();
>       }
>
>       public void messageLogged(BuildEvent event) {
>           helper.attribute("priority", priorities[event.getPriority()]);
>           helper.element("message", event.getMessage(), true);
>       }
>   }
>
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Sun, Feb 03, 2002 at 12:53:39PM +0100, Stephane Bailliez wrote:
> ----- Original Message -----
> From: "Erik Hatcher" <eh...@apache.org>
> 
> 
> > Would your XMLListener be better at home in Ant's CVS?  Is it a
> replacement
> > for XMLLogger (yes, which is inappropriately named - and I'm going to
> > convert it to an actual BuildLogger soon)?
> 
> I suppose that Scott wanted to avoid keeping all nodes in memory since in
> XMLLogger we are forced to wait for the end of the build. (error message and
> elapsed timee are root node attributes).
> I think it was also a RFE from Robert (more or less it was a filtering
> feature) for CruiseControl.
>

All those nodes in memory will eat a *lot* of memory.  My stack-based impl, inspired by SAX, was to help the memory issue, but as Conor notes it may have threading issues.  I would like to see if this can be solved, and see this in Ant.
 
> > I just can't help but cringe with code duplication or cut-and-pasting - so
> > if your XMListener is a plug-in replacement for our XMLLogger then we'd
> > gladly replace ours and you could use it from Ant's codebase instead.
> 
> Scott, I also think you would like to avoid any human time formatting in the
> XML since it will be a pain to play with in any XSL (just like for example
> localizing the time for my poor french fellows!), you will be forced to
> parse just every attribute to get the real numbers and do whatever you want
> in the XML or in your Java code (stats or whatever) and as the pattern is
> not regular, this template author will shoot himself. Using the ISO8601
> pattern http://www.w3.org/TR/xmlschema-2/#dateTime should make things
> easier. (I'm also tempted to include the information in ms as well to ease
> time differences computation)
>

Sure, I will happily change any and all formatting.  I am over here bootstrapping this, so I needed human formattinf for now.  ISO8601 is a great idea and I would love to see a patch.  If not, I can code this up later.
 
> If you use Xalan, you can manipulate Java objects directly in the XSL so you
> can format time with locale easily, otherwise MSXML has 2 extensions
> format-date, format-time or you can get use an extension here that does the
> dirty job:
> http://www.exslt.org/date/functions/format-date/ and that can deal with
> patterns.
>

Understood.  I am just not there yet.  Still debugging in the raw XML.  I need to get some of it posted so I can get some help with the formatting XSL.
 
> As a side note, we may want to avoid duplication in Ant as well. The bug
> fixed for time formatting in DefaultLogger was also open for VAJToolGUI task
> but the later was not fixed and I don't feel like duplicating the code as
> well. Maybe a public static method in DefaultLogger should do or adding this
> method to StringUtils...but I feel DateUtils would be more appropriate
> (mmm...this starts to look like jakarta-commons :)
>

I understand the feelings of duplication avoidance, and I will look into the ISO8601 Route. I beleive there are 2 classes in the commons-sandbox to do this, so I will look into it.  The only reason I duplicated now was because the method I wanted was unavailable to me (protected).  I am happy to remove this duplication, and I think it will remove itself once I plug in the ISO8601 stuff.

I strongly believe that this formatting stuff belongs over in Commons, so I will use stuff from there if possible.  Again, I did not intend to duplicate, just bootstrap with the code I found in Ant.  It will go away.
 
> thoughts ?
>

So, if we can fix the threading issues Conor speaks of, I would be happy to see the XMLListener end up in Ant.  And I am very glad that you guys are watching ;-)

Scott
 
> Stephane
> 
> > ----- Original Message -----
> > From: <sa...@apache.org>
> > To: <ja...@apache.org>
> > Sent: Saturday, February 02, 2002 9:53 PM
> > Subject: cvs commit:
> > jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
> > Vindico.java XMLListener.java
> >
> >
> > > sanders     02/02/02 18:53:01
> > >
> > >   Added:       proposal/vindico/src/java/org/apache/alexandria/ant
> > >                         Vindico.java XMLListener.java
> > >   Removed:     proposal/vindico/src/java/org/apache/alexandria
> > Vindico.java
> > >   Log:
> > >   Created a faster XMLListener than the DOM based one
> > >   in Ant.
> > >
> > >   Revision  Changes    Path
> > >   1.1
> >
> jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/Vindi
> > co.java
> > >
> > >   Index: Vindico.java
> > >   ===================================================================
> > >   /*
> > >    * $Header:
> >
> /home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> > /ant/Vindico.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> > >    * $Revision: 1.1 $
> > >    * $Date: 2002/02/03 02:53:01 $
> > >    *
> > >    *
> ====================================================================
> > >    *
> > >    * The Apache Software License, Version 1.1
> > >    *
> > >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> > >    * reserved.
> > >    *
> > >    * Redistribution and use in source and binary forms, with or without
> > >    * modification, are permitted provided that the following conditions
> > >    * are met:
> > >    *
> > >    * 1. Redistributions of source code must retain the above copyright
> > >    *    notice, this list of conditions and the following disclaimer.
> > >    *
> > >    * 2. Redistributions in binary form must reproduce the above
> copyright
> > >    *    notice, this list of conditions and the following disclaimer in
> > >    *    the documentation and/or other materials provided with the
> > >    *    distribution.
> > >    *
> > >    * 3. The end-user documentation included with the redistribution, if
> > >    *    any, must include the following acknowlegement:
> > >    *       "This product includes software developed by the
> > >    *        Apache Software Foundation (http://www.apache.org/)."
> > >    *    Alternately, this acknowlegement may appear in the software
> > itself,
> > >    *    if and wherever such third-party acknowlegements normally
> appear.
> > >    *
> > >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> > >    *    Foundation" must not be used to endorse or promote products
> > derived
> > >    *    from this software without prior written permission. For written
> > >    *    permission, please contact apache@apache.org.
> > >    *
> > >    * 5. Products derived from this software may not be called "Apache"
> > >    *    nor may "Apache" appear in their names without prior written
> > >    *    permission of the Apache Group.
> > >    *
> > >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> > >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> > >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> > >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> > >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> > >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> > >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> > >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > >    * SUCH DAMAGE.
> > >    *
> ====================================================================
> > >    *
> > >    * This software consists of voluntary contributions made by many
> > >    * individuals on behalf of the Apache Software Foundation.  For more
> > >    * information on the Apache Software Foundation, please see
> > >    * <http://www.apache.org/>.
> > >    *
> > >    */
> > >   package org.apache.alexandria.ant;
> > >
> > >
> > >   import org.apache.alexandria.exc.VindicoException;
> > >   import org.apache.alexandria.om.Workspace;
> > >   import org.apache.alexandria.om.WorkspaceLoader;
> > >   import org.apache.tools.ant.BuildException;
> > >   import org.apache.tools.ant.Task;
> > >
> > >
> > >   /**
> > >    * Vindico provides ...
> > >    *
> > >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> > >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> > >    */
> > >   public class Vindico extends Task {
> > >
> > >       private String workspace;
> > >
> > >       public String getWorkspace() {
> > >           return workspace;
> > >       }
> > >
> > >       public void setWorkspace(String workspace) {
> > >           this.workspace = workspace;
> > >       }
> > >
> > >       public void execute() throws BuildException {
> > >           Workspace space = new Workspace();
> > >           space = WorkspaceLoader.loadWorkspace(space, workspace);
> > >           String basedir = space.getBasedir();
> > >           this.getProject().setProperty("vindico.basedir", basedir);
> > >           try {
> > >               space.execute();
> > >           } catch (VindicoException ve) {
> > >               throw new BuildException(ve.getMessage(), ve);
> > >           }
> > >       }
> > >   }
> > >
> > >
> > >
> > >   1.1
> >
> jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/XMLLi
> > stener.java
> > >
> > >   Index: XMLListener.java
> > >   ===================================================================
> > >   /*
> > >    * $Header:
> >
> /home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> > /ant/XMLListener.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> > >    * $Revision: 1.1 $
> > >    * $Date: 2002/02/03 02:53:01 $
> > >    *
> > >    *
> ====================================================================
> > >    *
> > >    * The Apache Software License, Version 1.1
> > >    *
> > >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> > >    * reserved.
> > >    *
> > >    * Redistribution and use in source and binary forms, with or without
> > >    * modification, are permitted provided that the following conditions
> > >    * are met:
> > >    *
> > >    * 1. Redistributions of source code must retain the above copyright
> > >    *    notice, this list of conditions and the following disclaimer.
> > >    *
> > >    * 2. Redistributions in binary form must reproduce the above
> copyright
> > >    *    notice, this list of conditions and the following disclaimer in
> > >    *    the documentation and/or other materials provided with the
> > >    *    distribution.
> > >    *
> > >    * 3. The end-user documentation included with the redistribution, if
> > >    *    any, must include the following acknowlegement:
> > >    *       "This product includes software developed by the
> > >    *        Apache Software Foundation (http://www.apache.org/)."
> > >    *    Alternately, this acknowlegement may appear in the software
> > itself,
> > >    *    if and wherever such third-party acknowlegements normally
> appear.
> > >    *
> > >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> > >    *    Foundation" must not be used to endorse or promote products
> > derived
> > >    *    from this software without prior written permission. For written
> > >    *    permission, please contact apache@apache.org.
> > >    *
> > >    * 5. Products derived from this software may not be called "Apache"
> > >    *    nor may "Apache" appear in their names without prior written
> > >    *    permission of the Apache Group.
> > >    *
> > >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> > >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> > >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> > >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> > >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> > >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> > >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> > >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> > >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> > >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> > >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> > >    * SUCH DAMAGE.
> > >    *
> ====================================================================
> > >    *
> > >    * This software consists of voluntary contributions made by many
> > >    * individuals on behalf of the Apache Software Foundation.  For more
> > >    * information on the Apache Software Foundation, please see
> > >    * <http://www.apache.org/>.
> > >    *
> > >    */
> > >   package org.apache.alexandria.ant;
> > >
> > >
> > >   import java.io.FileWriter;
> > >   import java.io.StringWriter;
> > >   import java.io.PrintWriter;
> > >   import java.text.ChoiceFormat;
> > >   import java.text.MessageFormat;
> > >   import java.text.SimpleDateFormat;
> > >   import java.util.Date;
> > >
> > >   import org.apache.alexandria.util.XMLHelper;
> > >   import org.apache.tools.ant.BuildEvent;
> > >   import org.apache.tools.ant.BuildListener;
> > >
> > >
> > >   /**
> > >    * XMLListener provides ...
> > >    *
> > >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> > >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> > >    */
> > >   public class XMLListener implements BuildListener {
> > >
> > >       private XMLHelper helper;
> > >       private FileWriter writer;
> > >       private long startTime;
> > >
> > >
> > >       private static String[] priorities = new String[]{"ERROR", "WARN",
> > "INFO", "VERBOSE", "DEBUG"};
> > >
> > >       /**
> > >        * Code borrowed from Ant's DefaultLogger since it was private
> > >        */
> > >       private final static MessageFormat MINUTE_SECONDS =
> > >               new MessageFormat("Total time: {0}{1}.");
> > >
> > >       private final static double[] LIMITS = {0, 1, 2};
> > >
> > >       private final static String[] MINUTES_PART =
> > >               {"", "1 minute, ", "{0,number} minutes, "};
> > >
> > >       private final static String[] SECONDS_PART =
> > >               {"no seconds", "1 second", "{1,number} seconds"};
> > >
> > >       private final static ChoiceFormat MINUTES_FORMAT =
> > >               new ChoiceFormat(LIMITS, MINUTES_PART);
> > >
> > >       private final static ChoiceFormat SECONDS_FORMAT =
> > >               new ChoiceFormat(LIMITS, SECONDS_PART);
> > >
> > >       static {
> > >           MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
> > >           MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
> > >       }
> > >
> > >       private final static SimpleDateFormat TIME_FORMAT =
> > >               new SimpleDateFormat("HH:mm");
> > >
> > >       /**
> > >        * Code borrowed from Ant's DefaultLogger since it was protected
> > >        */
> > >       protected static String formatTime(long millis) {
> > >           long seconds = millis / 1000;
> > >           long minutes = seconds / 60;
> > >
> > >           Object[] args = {
> > >               new Long(minutes),
> > >               new Long(seconds % 60)
> > >           };
> > >
> > >           return MINUTE_SECONDS.format(args);
> > >       }
> > >
> > >       /**
> > >        * Taken from Ant's StringUtils.
> > >        */
> > >       public static String getStackTrace(Throwable t) {
> > >           StringWriter sw = new StringWriter();
> > >           PrintWriter pw = new PrintWriter(sw, true);
> > >           t.printStackTrace(pw);
> > >           pw.flush();
> > >           pw.close();
> > >           return sw.toString();
> > >       }
> > >
> > >
> > >       public void buildStarted(BuildEvent event) {
> > >           startTime = System.currentTimeMillis();
> > >           writer = new
> > FileWriter(event.getProject().getProperty("vindico.log.file"));
> > >           helper = new XMLHelper(writer);
> > >           helper.element("ant-build");
> > >       }
> > >
> > >       public void buildFinished(BuildEvent event) {
> > >           long endTime = System.currentTimeMillis();
> > >           long totalTime = endTime - startTime;
> > >           helper.attribute("start-time", TIME_FORMAT.format(new
> > Date(startTime)));
> > >           helper.attribute("end-time", TIME_FORMAT.format(new
> > Date(endTime)));
> > >           helper.attribute("total-time", formatTime(startTime));
> > >           helper.element("build-stats", true);
> > >
> > >           if (event.getException() != null) {
> > >               helper.attribute("exception",
> > event.getException().toString());
> > >               helper.element("build-error");
> > >
> > >               Throwable t = event.getException();
> > >               helper.element("stack-trace", getStackTrace(t), true);
> > >
> > >               helper.popElement();
> > >           }
> > >
> > >           helper.popElement(); //root element
> > >           writer.close();
> > >       }
> > >
> > >       public void targetStarted(BuildEvent event) {
> > >           helper.attribute("name", event.getTarget().getName());
> > >           helper.element("target");
> > >       }
> > >
> > >       public void targetFinished(BuildEvent event) {
> > >           helper.popElement();
> > >       }
> > >
> > >       public void taskStarted(BuildEvent event) {
> > >           helper.attribute("name", event.getTask().getTaskName());
> > >           //FIXME - Should we add the Ant Location info here?
> > >           helper.element("task");
> > >       }
> > >
> > >       public void taskFinished(BuildEvent event) {
> > >           helper.popElement();
> > >       }
> > >
> > >       public void messageLogged(BuildEvent event) {
> > >           helper.attribute("priority", priorities[event.getPriority()]);
> > >           helper.element("message", event.getMessage(), true);
> > >       }
> > >   }
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stephane Bailliez <sb...@apache.org>.
----- Original Message -----
From: "Erik Hatcher" <eh...@apache.org>


> Would your XMLListener be better at home in Ant's CVS?  Is it a
replacement
> for XMLLogger (yes, which is inappropriately named - and I'm going to
> convert it to an actual BuildLogger soon)?

I suppose that Scott wanted to avoid keeping all nodes in memory since in
XMLLogger we are forced to wait for the end of the build. (error message and
elapsed timee are root node attributes).
I think it was also a RFE from Robert (more or less it was a filtering
feature) for CruiseControl.

> I just can't help but cringe with code duplication or cut-and-pasting - so
> if your XMListener is a plug-in replacement for our XMLLogger then we'd
> gladly replace ours and you could use it from Ant's codebase instead.

Scott, I also think you would like to avoid any human time formatting in the
XML since it will be a pain to play with in any XSL (just like for example
localizing the time for my poor french fellows!), you will be forced to
parse just every attribute to get the real numbers and do whatever you want
in the XML or in your Java code (stats or whatever) and as the pattern is
not regular, this template author will shoot himself. Using the ISO8601
pattern http://www.w3.org/TR/xmlschema-2/#dateTime should make things
easier. (I'm also tempted to include the information in ms as well to ease
time differences computation)

If you use Xalan, you can manipulate Java objects directly in the XSL so you
can format time with locale easily, otherwise MSXML has 2 extensions
format-date, format-time or you can get use an extension here that does the
dirty job:
http://www.exslt.org/date/functions/format-date/ and that can deal with
patterns.

As a side note, we may want to avoid duplication in Ant as well. The bug
fixed for time formatting in DefaultLogger was also open for VAJToolGUI task
but the later was not fixed and I don't feel like duplicating the code as
well. Maybe a public static method in DefaultLogger should do or adding this
method to StringUtils...but I feel DateUtils would be more appropriate
(mmm...this starts to look like jakarta-commons :)

thoughts ?

Stephane

> ----- Original Message -----
> From: <sa...@apache.org>
> To: <ja...@apache.org>
> Sent: Saturday, February 02, 2002 9:53 PM
> Subject: cvs commit:
> jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
> Vindico.java XMLListener.java
>
>
> > sanders     02/02/02 18:53:01
> >
> >   Added:       proposal/vindico/src/java/org/apache/alexandria/ant
> >                         Vindico.java XMLListener.java
> >   Removed:     proposal/vindico/src/java/org/apache/alexandria
> Vindico.java
> >   Log:
> >   Created a faster XMLListener than the DOM based one
> >   in Ant.
> >
> >   Revision  Changes    Path
> >   1.1
>
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/Vindi
> co.java
> >
> >   Index: Vindico.java
> >   ===================================================================
> >   /*
> >    * $Header:
>
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> /ant/Vindico.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> >    * $Revision: 1.1 $
> >    * $Date: 2002/02/03 02:53:01 $
> >    *
> >    *
====================================================================
> >    *
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms, with or without
> >    * modification, are permitted provided that the following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the above copyright
> >    *    notice, this list of conditions and the following disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the above
copyright
> >    *    notice, this list of conditions and the following disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution, if
> >    *    any, must include the following acknowlegement:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowlegement may appear in the software
> itself,
> >    *    if and wherever such third-party acknowlegements normally
appear.
> >    *
> >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> >    *    Foundation" must not be used to endorse or promote products
> derived
> >    *    from this software without prior written permission. For written
> >    *    permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be called "Apache"
> >    *    nor may "Apache" appear in their names without prior written
> >    *    permission of the Apache Group.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    *
> >    */
> >   package org.apache.alexandria.ant;
> >
> >
> >   import org.apache.alexandria.exc.VindicoException;
> >   import org.apache.alexandria.om.Workspace;
> >   import org.apache.alexandria.om.WorkspaceLoader;
> >   import org.apache.tools.ant.BuildException;
> >   import org.apache.tools.ant.Task;
> >
> >
> >   /**
> >    * Vindico provides ...
> >    *
> >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> >    */
> >   public class Vindico extends Task {
> >
> >       private String workspace;
> >
> >       public String getWorkspace() {
> >           return workspace;
> >       }
> >
> >       public void setWorkspace(String workspace) {
> >           this.workspace = workspace;
> >       }
> >
> >       public void execute() throws BuildException {
> >           Workspace space = new Workspace();
> >           space = WorkspaceLoader.loadWorkspace(space, workspace);
> >           String basedir = space.getBasedir();
> >           this.getProject().setProperty("vindico.basedir", basedir);
> >           try {
> >               space.execute();
> >           } catch (VindicoException ve) {
> >               throw new BuildException(ve.getMessage(), ve);
> >           }
> >       }
> >   }
> >
> >
> >
> >   1.1
>
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/XMLLi
> stener.java
> >
> >   Index: XMLListener.java
> >   ===================================================================
> >   /*
> >    * $Header:
>
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> /ant/XMLListener.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> >    * $Revision: 1.1 $
> >    * $Date: 2002/02/03 02:53:01 $
> >    *
> >    *
====================================================================
> >    *
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms, with or without
> >    * modification, are permitted provided that the following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the above copyright
> >    *    notice, this list of conditions and the following disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the above
copyright
> >    *    notice, this list of conditions and the following disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution, if
> >    *    any, must include the following acknowlegement:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowlegement may appear in the software
> itself,
> >    *    if and wherever such third-party acknowlegements normally
appear.
> >    *
> >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> >    *    Foundation" must not be used to endorse or promote products
> derived
> >    *    from this software without prior written permission. For written
> >    *    permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be called "Apache"
> >    *    nor may "Apache" appear in their names without prior written
> >    *    permission of the Apache Group.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    *
> >    */
> >   package org.apache.alexandria.ant;
> >
> >
> >   import java.io.FileWriter;
> >   import java.io.StringWriter;
> >   import java.io.PrintWriter;
> >   import java.text.ChoiceFormat;
> >   import java.text.MessageFormat;
> >   import java.text.SimpleDateFormat;
> >   import java.util.Date;
> >
> >   import org.apache.alexandria.util.XMLHelper;
> >   import org.apache.tools.ant.BuildEvent;
> >   import org.apache.tools.ant.BuildListener;
> >
> >
> >   /**
> >    * XMLListener provides ...
> >    *
> >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> >    */
> >   public class XMLListener implements BuildListener {
> >
> >       private XMLHelper helper;
> >       private FileWriter writer;
> >       private long startTime;
> >
> >
> >       private static String[] priorities = new String[]{"ERROR", "WARN",
> "INFO", "VERBOSE", "DEBUG"};
> >
> >       /**
> >        * Code borrowed from Ant's DefaultLogger since it was private
> >        */
> >       private final static MessageFormat MINUTE_SECONDS =
> >               new MessageFormat("Total time: {0}{1}.");
> >
> >       private final static double[] LIMITS = {0, 1, 2};
> >
> >       private final static String[] MINUTES_PART =
> >               {"", "1 minute, ", "{0,number} minutes, "};
> >
> >       private final static String[] SECONDS_PART =
> >               {"no seconds", "1 second", "{1,number} seconds"};
> >
> >       private final static ChoiceFormat MINUTES_FORMAT =
> >               new ChoiceFormat(LIMITS, MINUTES_PART);
> >
> >       private final static ChoiceFormat SECONDS_FORMAT =
> >               new ChoiceFormat(LIMITS, SECONDS_PART);
> >
> >       static {
> >           MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
> >           MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
> >       }
> >
> >       private final static SimpleDateFormat TIME_FORMAT =
> >               new SimpleDateFormat("HH:mm");
> >
> >       /**
> >        * Code borrowed from Ant's DefaultLogger since it was protected
> >        */
> >       protected static String formatTime(long millis) {
> >           long seconds = millis / 1000;
> >           long minutes = seconds / 60;
> >
> >           Object[] args = {
> >               new Long(minutes),
> >               new Long(seconds % 60)
> >           };
> >
> >           return MINUTE_SECONDS.format(args);
> >       }
> >
> >       /**
> >        * Taken from Ant's StringUtils.
> >        */
> >       public static String getStackTrace(Throwable t) {
> >           StringWriter sw = new StringWriter();
> >           PrintWriter pw = new PrintWriter(sw, true);
> >           t.printStackTrace(pw);
> >           pw.flush();
> >           pw.close();
> >           return sw.toString();
> >       }
> >
> >
> >       public void buildStarted(BuildEvent event) {
> >           startTime = System.currentTimeMillis();
> >           writer = new
> FileWriter(event.getProject().getProperty("vindico.log.file"));
> >           helper = new XMLHelper(writer);
> >           helper.element("ant-build");
> >       }
> >
> >       public void buildFinished(BuildEvent event) {
> >           long endTime = System.currentTimeMillis();
> >           long totalTime = endTime - startTime;
> >           helper.attribute("start-time", TIME_FORMAT.format(new
> Date(startTime)));
> >           helper.attribute("end-time", TIME_FORMAT.format(new
> Date(endTime)));
> >           helper.attribute("total-time", formatTime(startTime));
> >           helper.element("build-stats", true);
> >
> >           if (event.getException() != null) {
> >               helper.attribute("exception",
> event.getException().toString());
> >               helper.element("build-error");
> >
> >               Throwable t = event.getException();
> >               helper.element("stack-trace", getStackTrace(t), true);
> >
> >               helper.popElement();
> >           }
> >
> >           helper.popElement(); //root element
> >           writer.close();
> >       }
> >
> >       public void targetStarted(BuildEvent event) {
> >           helper.attribute("name", event.getTarget().getName());
> >           helper.element("target");
> >       }
> >
> >       public void targetFinished(BuildEvent event) {
> >           helper.popElement();
> >       }
> >
> >       public void taskStarted(BuildEvent event) {
> >           helper.attribute("name", event.getTask().getTaskName());
> >           //FIXME - Should we add the Ant Location info here?
> >           helper.element("task");
> >       }
> >
> >       public void taskFinished(BuildEvent event) {
> >           helper.popElement();
> >       }
> >
> >       public void messageLogged(BuildEvent event) {
> >           helper.attribute("priority", priorities[event.getPriority()]);
> >           helper.element("message", event.getMessage(), true);
> >       }
> >   }
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Sat, Feb 02, 2002 at 10:01:39PM -0500, Erik Hatcher wrote:
> Scott,
> 
> Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
> for XMLLogger (yes, which is inappropriately named - and I'm going to
> convert it to an actual BuildLogger soon)?
> 
> I just can't help but cringe with code duplication or cut-and-pasting - so
> if your XMListener is a plug-in replacement for our XMLLogger then we'd
> gladly replace ours and you could use it from Ant's codebase instead.
> 
>     Erik
>

I would be happy to see this in the Ant CVS.  I only wrote this since My build was spitting out a HUGE xml file at the end, because it was waiting for the DOM to become fully formatted.

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
Sorry, I tuned out of this conversation for a bit because of <parallel>
issues with my mail folders!  :)

I'm caught back up and I'm glad Stefan and Stephane have addressed all the
issues so far (since I wouldn't have been able to answer them with the
expertise that they just did).

    Erik


----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <al...@jakarta.apache.org>
Sent: Monday, February 04, 2002 12:17 PM
Subject: Re: cvs commit:
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
Vindico.java XMLListener.java


> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
>
> > So if the task is instanceof TaskContainer, then I *can* become
> > parallel aware?
>
> You *must* 8-)
>
> This is not strictly an indicator for whether tasks could be logging
> messages in parallel, there are other possibilities as well, but tasks
> that are nested into TaskContainers are the most common case.
>
> Nobody is stopping you from writing a task that spawns of Threads that
> go on forever and log messages even after the task itself is finished
> according to Ant, but this is a situation that XmlLogger doesn't
> handle either.
>
> > So, parallel can call ant, which could call parallel, which could
> > call ant...?
>
> Yes.
>
> Stefan
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:

> So if the task is instanceof TaskContainer, then I *can* become
> parallel aware?

You *must* 8-)

This is not strictly an indicator for whether tasks could be logging
messages in parallel, there are other possibilities as well, but tasks
that are nested into TaskContainers are the most common case.  

Nobody is stopping you from writing a task that spawns of Threads that
go on forever and log messages even after the task itself is finished
according to Ant, but this is a situation that XmlLogger doesn't
handle either.

> So, parallel can call ant, which could call parallel, which could
> call ant...?

Yes.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Mon, Feb 04, 2002 at 05:59:55PM +0100, Stefan Bodewig wrote:
> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
> > On Mon, Feb 04, 2002 at 05:30:35PM +0100, Stefan Bodewig wrote:
> >> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
> >> 
> >> > So, I only need to watch messages, and put them in the right
> >> > task?
> >> 
> >> Well, yes.  Each message comes with the task instance as part of
> >> the BuildEvent, so you can pile the messages up on a task by task
> >> basis (this is what the current XmlLogger does AFAIK).
> >>
> > 
> > Cool.  Well building up a string on a task by task basis is still
> > less memory-consuming than DOM.  I will give it a try.
> 
> Be aware, that parallel is a task itself, so you have a taskStarted
> event for parallel followed by taskStarted and taskEnded events for
> all the nested tasks (in more or less random order, but you can rely
> on taskStarted being called before any call to messageLogged and that
> taskFinished will be the last call for each individual task) and
> finally taskFinished for the parallel task.
>

OK
 
> > What I meant was, if I see the taskStarted() come by and it was the
> > parallel task, could I become 'parallel-aware' then, and then
> > default back to the single-threaded, less consuming model after
> > taskFinished()?
> 
> No, because somebody else could write a task container that did the
> same as well.  Maybe you could become "parallel aware" as soon as a
> taskStarted gets fired for something that is instanceof TaskContainer.
>

So if the task is instanceof TaskContainer, then I *can* become parallel aware?
 
> There is one thing, that adds another level of complexity here, sorry
> ;-), you can nest any task into <parallel> including <ant>, which
> means you can even get buildStarted and targetStarted events while you
> are logging different messages for the "normal" tasks that are also
> children of the parallel task.
>

So, parallel can call ant, which could call parallel, which could call ant...?

That is OK, that just means that the parallel aware code also has to be stack aware in some sense.  I will give it a try.

Thanks,
Scott

 
> Stefan
> 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
> On Mon, Feb 04, 2002 at 05:30:35PM +0100, Stefan Bodewig wrote:
>> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
>> 
>> > So, I only need to watch messages, and put them in the right
>> > task?
>> 
>> Well, yes.  Each message comes with the task instance as part of
>> the BuildEvent, so you can pile the messages up on a task by task
>> basis (this is what the current XmlLogger does AFAIK).
>>
> 
> Cool.  Well building up a string on a task by task basis is still
> less memory-consuming than DOM.  I will give it a try.

Be aware, that parallel is a task itself, so you have a taskStarted
event for parallel followed by taskStarted and taskEnded events for
all the nested tasks (in more or less random order, but you can rely
on taskStarted being called before any call to messageLogged and that
taskFinished will be the last call for each individual task) and
finally taskFinished for the parallel task.

> What I meant was, if I see the taskStarted() come by and it was the
> parallel task, could I become 'parallel-aware' then, and then
> default back to the single-threaded, less consuming model after
> taskFinished()?

No, because somebody else could write a task container that did the
same as well.  Maybe you could become "parallel aware" as soon as a
taskStarted gets fired for something that is instanceof TaskContainer.

There is one thing, that adds another level of complexity here, sorry
;-), you can nest any task into <parallel> including <ant>, which
means you can even get buildStarted and targetStarted events while you
are logging different messages for the "normal" tasks that are also
children of the parallel task.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Mon, Feb 04, 2002 at 05:30:35PM +0100, Stefan Bodewig wrote:
> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
> 
> > So, I only need to watch messages, and put them in the right task?
> 
> Well, yes.  Each message comes with the task instance as part of the
> BuildEvent, so you can pile the messages up on a task by task basis
> (this is what the current XmlLogger does AFAIK).
>

Cool.  Well building up a string on a task by task basis is still less memory-consuming than DOM.  I will give it a try.
 
> > Is the parallel task logged somehow?
> 
> It is a built-in task starting with Ant 1.4.  But it is just one
> implementation of the more general TaskContainer concept and nobody
> would stop people from writing their own task containers that invoked
> other tasks in parallel as well.
>

What I meant was, if I see the taskStarted() come by and it was the parallel task, could I become 'parallel-aware' then, and then default back to the single-threaded, less consuming model after taskFinished()?

 
> > Would I know that something is being paralleled?
> 
> No, even the tasks themselves usually don't know that.
>

I understand the tasks don't, but can I as the logger or the container know?

Thanks a lot Stefan.  I will work on this.
 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:

> So, I only need to watch messages, and put them in the right task?

Well, yes.  Each message comes with the task instance as part of the
BuildEvent, so you can pile the messages up on a task by task basis
(this is what the current XmlLogger does AFAIK).

> Is the parallel task logged somehow?

It is a built-in task starting with Ant 1.4.  But it is just one
implementation of the more general TaskContainer concept and nobody
would stop people from writing their own task containers that invoked
other tasks in parallel as well.

> Would I know that something is being paralleled?

No, even the tasks themselves usually don't know that.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Mon, Feb 04, 2002 at 05:19:04PM +0100, Stefan Bodewig wrote:
> On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:
> 
> > Does the current Ant parallel tasks?
> 
> Yes, tasks that live inside a <parallel> task.
>

So, I only need to watch messages, and put them in the right task?  Is the parallel task logged somehow?  Would I know that something is being paralleled?

Scott
 
> Stefan
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 4 Feb 2002, Scott Sanders <sa...@apache.org> wrote:

> Does the current Ant parallel tasks?

Yes, tasks that live inside a <parallel> task.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Scott Sanders <sa...@apache.org>.
On Sun, Feb 03, 2002 at 11:24:17PM +1100, Conor MacNeill wrote:
> Erik Hatcher wrote:
> 
> > Scott,
> > 
> > Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
> > for XMLLogger (yes, which is inappropriately named - and I'm going to
> > convert it to an actual BuildLogger soon)?
> > 
> > I just can't help but cringe with code duplication or cut-and-pasting - so
> > if your XMListener is a plug-in replacement for our XMLLogger then we'd
> > gladly replace ours and you could use it from Ant's codebase instead.
> > 
> 
> 
> Erik,
> 
> I don't believe Scott's listener is a plug-in replacement. As far as I 
> can see, it does not consider multithreaded operation. When multiple 
> tasks execute in parallel, you can't rely on the sequence of messages 
> (i.e. a task started message can be received before the previous task's 
> taskFinished message is received). I believe the current XML logger 
> handles this.
> 
> Conor
>

Conor, 

Does the current Ant parallel tasks?  If so, how?  I would like to see this work, unfortunately I do not completely understand the operation of Ant.

Scott
 
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Scott Sanders - sanders@apache.org

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Erik Hatcher wrote:

> Scott,
> 
> Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
> for XMLLogger (yes, which is inappropriately named - and I'm going to
> convert it to an actual BuildLogger soon)?
> 
> I just can't help but cringe with code duplication or cut-and-pasting - so
> if your XMListener is a plug-in replacement for our XMLLogger then we'd
> gladly replace ours and you could use it from Ant's codebase instead.
> 


Erik,

I don't believe Scott's listener is a plug-in replacement. As far as I 
can see, it does not consider multithreaded operation. When multiple 
tasks execute in parallel, you can't rely on the sequence of messages 
(i.e. a task started message can be received before the previous task's 
taskFinished message is received). I believe the current XML logger 
handles this.

Conor




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Erik Hatcher wrote:

> Scott,
> 
> Would your XMLListener be better at home in Ant's CVS?  Is it a replacement
> for XMLLogger (yes, which is inappropriately named - and I'm going to
> convert it to an actual BuildLogger soon)?
> 
> I just can't help but cringe with code duplication or cut-and-pasting - so
> if your XMListener is a plug-in replacement for our XMLLogger then we'd
> gladly replace ours and you could use it from Ant's codebase instead.
> 


Erik,

I don't believe Scott's listener is a plug-in replacement. As far as I 
can see, it does not consider multithreaded operation. When multiple 
tasks execute in parallel, you can't rely on the sequence of messages 
(i.e. a task started message can be received before the previous task's 
taskFinished message is received). I believe the current XML logger 
handles this.

Conor




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: cvs commit: jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant Vindico.java XMLListener.java

Posted by Stephane Bailliez <sb...@apache.org>.
----- Original Message -----
From: "Erik Hatcher" <eh...@apache.org>


> Would your XMLListener be better at home in Ant's CVS?  Is it a
replacement
> for XMLLogger (yes, which is inappropriately named - and I'm going to
> convert it to an actual BuildLogger soon)?

I suppose that Scott wanted to avoid keeping all nodes in memory since in
XMLLogger we are forced to wait for the end of the build. (error message and
elapsed timee are root node attributes).
I think it was also a RFE from Robert (more or less it was a filtering
feature) for CruiseControl.

> I just can't help but cringe with code duplication or cut-and-pasting - so
> if your XMListener is a plug-in replacement for our XMLLogger then we'd
> gladly replace ours and you could use it from Ant's codebase instead.

Scott, I also think you would like to avoid any human time formatting in the
XML since it will be a pain to play with in any XSL (just like for example
localizing the time for my poor french fellows!), you will be forced to
parse just every attribute to get the real numbers and do whatever you want
in the XML or in your Java code (stats or whatever) and as the pattern is
not regular, this template author will shoot himself. Using the ISO8601
pattern http://www.w3.org/TR/xmlschema-2/#dateTime should make things
easier. (I'm also tempted to include the information in ms as well to ease
time differences computation)

If you use Xalan, you can manipulate Java objects directly in the XSL so you
can format time with locale easily, otherwise MSXML has 2 extensions
format-date, format-time or you can get use an extension here that does the
dirty job:
http://www.exslt.org/date/functions/format-date/ and that can deal with
patterns.

As a side note, we may want to avoid duplication in Ant as well. The bug
fixed for time formatting in DefaultLogger was also open for VAJToolGUI task
but the later was not fixed and I don't feel like duplicating the code as
well. Maybe a public static method in DefaultLogger should do or adding this
method to StringUtils...but I feel DateUtils would be more appropriate
(mmm...this starts to look like jakarta-commons :)

thoughts ?

Stephane

> ----- Original Message -----
> From: <sa...@apache.org>
> To: <ja...@apache.org>
> Sent: Saturday, February 02, 2002 9:53 PM
> Subject: cvs commit:
> jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant
> Vindico.java XMLListener.java
>
>
> > sanders     02/02/02 18:53:01
> >
> >   Added:       proposal/vindico/src/java/org/apache/alexandria/ant
> >                         Vindico.java XMLListener.java
> >   Removed:     proposal/vindico/src/java/org/apache/alexandria
> Vindico.java
> >   Log:
> >   Created a faster XMLListener than the DOM based one
> >   in Ant.
> >
> >   Revision  Changes    Path
> >   1.1
>
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/Vindi
> co.java
> >
> >   Index: Vindico.java
> >   ===================================================================
> >   /*
> >    * $Header:
>
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> /ant/Vindico.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> >    * $Revision: 1.1 $
> >    * $Date: 2002/02/03 02:53:01 $
> >    *
> >    *
====================================================================
> >    *
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms, with or without
> >    * modification, are permitted provided that the following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the above copyright
> >    *    notice, this list of conditions and the following disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the above
copyright
> >    *    notice, this list of conditions and the following disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution, if
> >    *    any, must include the following acknowlegement:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowlegement may appear in the software
> itself,
> >    *    if and wherever such third-party acknowlegements normally
appear.
> >    *
> >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> >    *    Foundation" must not be used to endorse or promote products
> derived
> >    *    from this software without prior written permission. For written
> >    *    permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be called "Apache"
> >    *    nor may "Apache" appear in their names without prior written
> >    *    permission of the Apache Group.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    *
> >    */
> >   package org.apache.alexandria.ant;
> >
> >
> >   import org.apache.alexandria.exc.VindicoException;
> >   import org.apache.alexandria.om.Workspace;
> >   import org.apache.alexandria.om.WorkspaceLoader;
> >   import org.apache.tools.ant.BuildException;
> >   import org.apache.tools.ant.Task;
> >
> >
> >   /**
> >    * Vindico provides ...
> >    *
> >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> >    */
> >   public class Vindico extends Task {
> >
> >       private String workspace;
> >
> >       public String getWorkspace() {
> >           return workspace;
> >       }
> >
> >       public void setWorkspace(String workspace) {
> >           this.workspace = workspace;
> >       }
> >
> >       public void execute() throws BuildException {
> >           Workspace space = new Workspace();
> >           space = WorkspaceLoader.loadWorkspace(space, workspace);
> >           String basedir = space.getBasedir();
> >           this.getProject().setProperty("vindico.basedir", basedir);
> >           try {
> >               space.execute();
> >           } catch (VindicoException ve) {
> >               throw new BuildException(ve.getMessage(), ve);
> >           }
> >       }
> >   }
> >
> >
> >
> >   1.1
>
jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria/ant/XMLLi
> stener.java
> >
> >   Index: XMLListener.java
> >   ===================================================================
> >   /*
> >    * $Header:
>
/home/cvs/jakarta-alexandria/proposal/vindico/src/java/org/apache/alexandria
> /ant/XMLListener.java,v 1.1 2002/02/03 02:53:01 sanders Exp $
> >    * $Revision: 1.1 $
> >    * $Date: 2002/02/03 02:53:01 $
> >    *
> >    *
====================================================================
> >    *
> >    * The Apache Software License, Version 1.1
> >    *
> >    * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
> >    * reserved.
> >    *
> >    * Redistribution and use in source and binary forms, with or without
> >    * modification, are permitted provided that the following conditions
> >    * are met:
> >    *
> >    * 1. Redistributions of source code must retain the above copyright
> >    *    notice, this list of conditions and the following disclaimer.
> >    *
> >    * 2. Redistributions in binary form must reproduce the above
copyright
> >    *    notice, this list of conditions and the following disclaimer in
> >    *    the documentation and/or other materials provided with the
> >    *    distribution.
> >    *
> >    * 3. The end-user documentation included with the redistribution, if
> >    *    any, must include the following acknowlegement:
> >    *       "This product includes software developed by the
> >    *        Apache Software Foundation (http://www.apache.org/)."
> >    *    Alternately, this acknowlegement may appear in the software
> itself,
> >    *    if and wherever such third-party acknowlegements normally
appear.
> >    *
> >    * 4. The names "The Jakarta Project", "Commons", and "Apache Software
> >    *    Foundation" must not be used to endorse or promote products
> derived
> >    *    from this software without prior written permission. For written
> >    *    permission, please contact apache@apache.org.
> >    *
> >    * 5. Products derived from this software may not be called "Apache"
> >    *    nor may "Apache" appear in their names without prior written
> >    *    permission of the Apache Group.
> >    *
> >    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
> >    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
> >    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
> >    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
> >    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
> >    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
> >    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
> >    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
> >    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
> >    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
> >    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> >    * SUCH DAMAGE.
> >    *
====================================================================
> >    *
> >    * This software consists of voluntary contributions made by many
> >    * individuals on behalf of the Apache Software Foundation.  For more
> >    * information on the Apache Software Foundation, please see
> >    * <http://www.apache.org/>.
> >    *
> >    */
> >   package org.apache.alexandria.ant;
> >
> >
> >   import java.io.FileWriter;
> >   import java.io.StringWriter;
> >   import java.io.PrintWriter;
> >   import java.text.ChoiceFormat;
> >   import java.text.MessageFormat;
> >   import java.text.SimpleDateFormat;
> >   import java.util.Date;
> >
> >   import org.apache.alexandria.util.XMLHelper;
> >   import org.apache.tools.ant.BuildEvent;
> >   import org.apache.tools.ant.BuildListener;
> >
> >
> >   /**
> >    * XMLListener provides ...
> >    *
> >    * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
> >    * @version $Revision: 1.1 $ $Date: 2002/02/03 02:53:01 $
> >    */
> >   public class XMLListener implements BuildListener {
> >
> >       private XMLHelper helper;
> >       private FileWriter writer;
> >       private long startTime;
> >
> >
> >       private static String[] priorities = new String[]{"ERROR", "WARN",
> "INFO", "VERBOSE", "DEBUG"};
> >
> >       /**
> >        * Code borrowed from Ant's DefaultLogger since it was private
> >        */
> >       private final static MessageFormat MINUTE_SECONDS =
> >               new MessageFormat("Total time: {0}{1}.");
> >
> >       private final static double[] LIMITS = {0, 1, 2};
> >
> >       private final static String[] MINUTES_PART =
> >               {"", "1 minute, ", "{0,number} minutes, "};
> >
> >       private final static String[] SECONDS_PART =
> >               {"no seconds", "1 second", "{1,number} seconds"};
> >
> >       private final static ChoiceFormat MINUTES_FORMAT =
> >               new ChoiceFormat(LIMITS, MINUTES_PART);
> >
> >       private final static ChoiceFormat SECONDS_FORMAT =
> >               new ChoiceFormat(LIMITS, SECONDS_PART);
> >
> >       static {
> >           MINUTE_SECONDS.setFormat(0, MINUTES_FORMAT);
> >           MINUTE_SECONDS.setFormat(1, SECONDS_FORMAT);
> >       }
> >
> >       private final static SimpleDateFormat TIME_FORMAT =
> >               new SimpleDateFormat("HH:mm");
> >
> >       /**
> >        * Code borrowed from Ant's DefaultLogger since it was protected
> >        */
> >       protected static String formatTime(long millis) {
> >           long seconds = millis / 1000;
> >           long minutes = seconds / 60;
> >
> >           Object[] args = {
> >               new Long(minutes),
> >               new Long(seconds % 60)
> >           };
> >
> >           return MINUTE_SECONDS.format(args);
> >       }
> >
> >       /**
> >        * Taken from Ant's StringUtils.
> >        */
> >       public static String getStackTrace(Throwable t) {
> >           StringWriter sw = new StringWriter();
> >           PrintWriter pw = new PrintWriter(sw, true);
> >           t.printStackTrace(pw);
> >           pw.flush();
> >           pw.close();
> >           return sw.toString();
> >       }
> >
> >
> >       public void buildStarted(BuildEvent event) {
> >           startTime = System.currentTimeMillis();
> >           writer = new
> FileWriter(event.getProject().getProperty("vindico.log.file"));
> >           helper = new XMLHelper(writer);
> >           helper.element("ant-build");
> >       }
> >
> >       public void buildFinished(BuildEvent event) {
> >           long endTime = System.currentTimeMillis();
> >           long totalTime = endTime - startTime;
> >           helper.attribute("start-time", TIME_FORMAT.format(new
> Date(startTime)));
> >           helper.attribute("end-time", TIME_FORMAT.format(new
> Date(endTime)));
> >           helper.attribute("total-time", formatTime(startTime));
> >           helper.element("build-stats", true);
> >
> >           if (event.getException() != null) {
> >               helper.attribute("exception",
> event.getException().toString());
> >               helper.element("build-error");
> >
> >               Throwable t = event.getException();
> >               helper.element("stack-trace", getStackTrace(t), true);
> >
> >               helper.popElement();
> >           }
> >
> >           helper.popElement(); //root element
> >           writer.close();
> >       }
> >
> >       public void targetStarted(BuildEvent event) {
> >           helper.attribute("name", event.getTarget().getName());
> >           helper.element("target");
> >       }
> >
> >       public void targetFinished(BuildEvent event) {
> >           helper.popElement();
> >       }
> >
> >       public void taskStarted(BuildEvent event) {
> >           helper.attribute("name", event.getTask().getTaskName());
> >           //FIXME - Should we add the Ant Location info here?
> >           helper.element("task");
> >       }
> >
> >       public void taskFinished(BuildEvent event) {
> >           helper.popElement();
> >       }
> >
> >       public void messageLogged(BuildEvent event) {
> >           helper.attribute("priority", priorities[event.getPriority()]);
> >           helper.element("message", event.getMessage(), true);
> >       }
> >   }
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>