On Sun, Feb 03, 2002 at 12:53:39PM +0100, Stephane Bailliez wrote:
> ----- Original Message -----
> From: "Erik Hatcher" <[EMAIL PROTECTED]>
> 
> 
> > 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: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > 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 [EMAIL PROTECTED]
> > >    *
> > >    * 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:[EMAIL PROTECTED]";>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 [EMAIL PROTECTED]
> > >    *
> > >    * 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:[EMAIL PROTECTED]";>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:
> > <mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
> > <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
> 

-- 
Scott Sanders - [EMAIL PROTECTED]

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to