You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by di...@apache.org on 2003/06/25 04:57:55 UTC

cvs commit: jakarta-commons/jelly/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant AntTag.java

dion        2003/06/24 19:57:55

  Modified:    jelly/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant
                        AntTag.java
  Log:
  Make the failed attempts to create ant datatypes for jelly tags be handled
  more silently.
  
  Almost all of these are not a problem.
  
  And the maven.log is always full of them.
  
  Revision  Changes    Path
  1.24      +44 -13    jakarta-commons/jelly/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java
  
  Index: AntTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/jelly/jelly-tags/ant/src/java/org/apache/commons/jelly/tags/ant/AntTag.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AntTag.java	26 Jan 2003 10:40:44 -0000	1.23
  +++ AntTag.java	25 Jun 2003 02:57:55 -0000	1.24
  @@ -80,6 +80,7 @@
   import org.apache.commons.jelly.impl.StaticTag;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.IntrospectionHelper;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  @@ -426,9 +427,16 @@
               if ( ih != null ) {
                   try {
                       dataType = ih.createElement( getAntProject(), object, name.toLowerCase() );
  -                }
  -                catch (Exception e) {
  -                    log.error(e);
  +                } catch (BuildException be) {
  +                    if (be.getMessage().indexOf("doesn't support the nested") != -1
  +                        && be.getMessage().indexOf("org.apache.commons.jelly.") != -1)
  +                    {
  +                        if (log.isDebugEnabled()) {
  +                            log.debug("Failed attempt to create an ant datatype for a jelly tag", be);
  +                        }
  +                    } else {
  +                        log.error(be);
  +                    }
                   }
               }
           }
  @@ -448,7 +456,7 @@
   
           if ( type != null ) {
   
  -            try {
  +//            try {
                   Constructor ctor = null;
                   boolean noArg = false;
   
  @@ -459,23 +467,46 @@
                       noArg = true;
                   }
                   catch (NoSuchMethodException nse) {
  -                    ctor = type.getConstructor(new Class[] { Project.class });
  -                    noArg = false;
  +                    try {
  +                        ctor = type.getConstructor(new Class[] { Project.class });
  +                        noArg = false;
  +                    } catch (NoSuchMethodException nsme) {
  +                        log.error("datatype '" + name 
  +                            + "' couldn't be created by passing an Ant project", nsme);
  +                    }
                   }
   
                   if (noArg) {
  -                    dataType = ctor.newInstance(new Object[0]);
  +                    try {
  +                        dataType = ctor.newInstance(new Object[0]);
  +                    } catch (InstantiationException ie) {
  +                        log.error("datatype '" + name + "' couldn't be created with no-arg constructor", ie);
  +                    } catch (IllegalAccessException iae) {
  +                        log.error("datatype '" + name + "' couldn't be created with no-arg constructor", iae);
  +                    } catch (InvocationTargetException ite) {
  +                        log.error("datatype '" + name + "' couldn't be created with no-arg constructor", ite);
  +                    }
                   }
                   else {
  -                    dataType = ctor.newInstance(new Object[] { getAntProject() });
  +                    try {
  +                        dataType = ctor.newInstance(new Object[] { getAntProject() });
  +                    } catch (InstantiationException ie) {
  +                        log.error("datatype '" + name + "' couldn't be created with an Ant project", ie);
  +                    } catch (IllegalAccessException iae) {
  +                        log.error("datatype '" + name + "' couldn't be created with an Ant project", iae);
  +                    } catch (InvocationTargetException ite) {
  +                        log.error("datatype '" + name + "' couldn't be created with an Ant project", ite);
  +                    }
                   }
  -                ((DataType)dataType).setProject( getAntProject() );
  +                if (dataType != null) {
  +                    ((DataType)dataType).setProject( getAntProject() );
  +                } 
   
  -            }
  -            catch (Throwable t) {
  +//            }
  +//            catch (Throwable t) {
                   // ignore
  -                log.error(t);
  -            }
  +//                log.error(t);
  +//            }
           }
   
           return dataType;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org