mpoeschl 2003/06/25 23:59:56 Modified: src/generator/src/java/org/apache/torque/engine/database/model ConstraintNameGenerator.java AppData.java Table.java Index.java Database.java Column.java NameFactory.java src/generator/src/java/org/apache/torque/engine/database/transform XmlToAppData.java XmlToData.java Log: use commons-logging Revision Changes Path 1.2 +10 -9 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/ConstraintNameGenerator.java Index: ConstraintNameGenerator.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/ConstraintNameGenerator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ConstraintNameGenerator.java 10 Feb 2003 13:20:58 -0000 1.1 +++ ConstraintNameGenerator.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.EngineException; /** @@ -68,10 +71,8 @@ */ public class ConstraintNameGenerator implements NameGenerator { - /** - * Conditional compilation flag. - */ - private static final boolean DEBUG = false; + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(ConstraintNameGenerator.class); /** * First element of <code>inputs</code> should be of type [EMAIL PROTECTED] @@ -101,15 +102,15 @@ maxBodyLength = (maxColumnNameLength - namePostfix.length() - constraintNbr.length() - 2); - if (DEBUG) + if (log.isDebugEnabled()) { - System.out.println("maxColumnNameLength=" + maxColumnNameLength + log.debug("maxColumnNameLength=" + maxColumnNameLength + " maxBodyLength=" + maxBodyLength); } } catch (EngineException e) { - System.err.println(e.getMessage()); + log.error(e.getMessage(), e); } catch (NumberFormatException maxLengthUnknown) { 1.2 +13 -4 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java Index: AppData.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/AppData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AppData.java 10 Feb 2003 13:20:58 -0000 1.1 +++ AppData.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,8 +62,14 @@ import java.util.List; import java.util.Map; import java.util.Properties; + import org.apache.commons.lang.StringUtils; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.EngineException; + import org.xml.sax.Attributes; /** @@ -76,6 +82,9 @@ */ public class AppData { + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(AppData.class); + /** * The list of databases for this application. */ @@ -150,7 +159,7 @@ } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } idiosyncrasyTable.put(databaseType, idiosyncrasies); } @@ -164,7 +173,7 @@ } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } } 1.2 +16 -10 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Table.java Index: Table.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Table.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Table.java 10 Feb 2003 13:20:58 -0000 1.1 +++ Table.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001-2002 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -58,8 +58,14 @@ import java.util.Hashtable; import java.util.Iterator; import java.util.List; + import org.apache.commons.lang.StringUtils; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.EngineException; + import org.xml.sax.Attributes; /** @@ -75,8 +81,8 @@ */ public class Table implements IDMethod { - /** enables debug output */ - private static final boolean DEBUG = false; + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(Table.class); //private AttributeListImpl attributes; private List columnList; @@ -158,7 +164,7 @@ } if ("autoincrement".equals(idMethod) || "sequence".equals(idMethod)) { - System.out.println("The value '" + idMethod + "' for Torque's " + log.warn("The value '" + idMethod + "' for Torque's " + "table.idMethod attribute has been deprecated in favor " + "of '" + NATIVE + "'. Please adjust your " + "Torque XML schema accordingly."); @@ -218,9 +224,9 @@ */ private void doHeavyIndexing() { - if (DEBUG) + if (log.isDebugEnabled()) { - System.out.println("doHeavyIndex() called on table " + name); + log.debug("doHeavyIndex() called on table " + name); } List pk = getPrimaryKey(); @@ -238,7 +244,7 @@ } catch (EngineException e) { - e.printStackTrace(); + log.error(e, e); } } @@ -284,7 +290,7 @@ } catch (EngineException nameAlreadyInUse) { - nameAlreadyInUse.printStackTrace(); + log.error(nameAlreadyInUse, nameAlreadyInUse); } } @@ -657,7 +663,7 @@ } catch (EngineException e) { - e.printStackTrace(); + log.error(e, e); } } return javaName; 1.2 +11 -6 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Index.java Index: Index.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Index.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Index.java 10 Feb 2003 13:20:58 -0000 1.1 +++ Index.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,7 +57,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.EngineException; + import org.xml.sax.Attributes; /** @@ -69,8 +74,8 @@ */ public class Index { - /** enables debug output */ - private static final boolean DEBUG = false; + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(Index.class); /** name of the index */ private String indexName; /** table */ @@ -108,9 +113,9 @@ this.indexColumns = indexColumns; createName(); - if (DEBUG) + if (log.isDebugEnabled()) { - System.out.println("Created Index named " + getName() + log.debug("Created Index named " + getName() + " with " + indexColumns.size() + " columns"); } } 1.4 +10 -6 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java Index: Database.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Database.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Database.java 8 Apr 2003 21:17:05 -0000 1.3 +++ Database.java 26 Jun 2003 06:59:56 -0000 1.4 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,8 @@ import java.util.Properties; import org.apache.torque.engine.EngineException; import org.xml.sax.Attributes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** @@ -75,6 +77,8 @@ */ public class Database { + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(Database.class); private String databaseType = null; private List tableList = new ArrayList(100); private String name; @@ -419,7 +423,7 @@ + "' is marked as autoincrement, but it does not " + "have a column which declared as the one to " + "auto increment (i.e. autoIncrement=\"true\")\n"; - System.out.println("Error in XML schema: " + errorMessage); + log.error("Error in XML schema: " + errorMessage); } } @@ -433,7 +437,7 @@ Table foreignTable = getTable(currFK.getForeignTableName()); if (foreignTable == null) { - System.out.println("ERROR!! Attempt to set foreign" + log.error("ERROR!! Attempt to set foreign" + " key to nonexistent table, " + currFK.getForeignTableName() + "!"); } @@ -455,7 +459,7 @@ // that we can do, if it is to occur. if (local == null) { - System.out.println("ERROR!! Attempt to define foreign" + log.error("ERROR!! Attempt to define foreign" + " key with nonexistent column in table, " + currTable.getName() + "!"); } @@ -478,7 +482,7 @@ // external reference or a misspelling if (foreign == null) { - System.out.println("ERROR!! Attempt to set foreign" + log.error("ERROR!! Attempt to set foreign" + " key to nonexistent column: table=" + currTable.getName() + ", foreign column=" + foreignColumnName + "!"); 1.2 +9 -4 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java Index: Column.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/Column.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Column.java 10 Feb 2003 13:20:58 -0000 1.1 +++ Column.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -59,10 +59,13 @@ import java.util.Hashtable; import java.util.List; -import org.xml.sax.Attributes; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.torque.engine.EngineException; +import org.xml.sax.Attributes; + /** * A Class for holding data about a column used in an Application. * @@ -75,6 +78,8 @@ */ public class Column { + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(Column.class); private String name; private String description; private String javaName = null; @@ -268,7 +273,7 @@ } catch (EngineException e) { - e.printStackTrace(); + log.error(e, e); } } return javaName; 1.3 +10 -4 db-torque/src/generator/src/java/org/apache/torque/engine/database/model/NameFactory.java Index: NameFactory.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/model/NameFactory.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- NameFactory.java 18 Feb 2003 08:05:50 -0000 1.2 +++ NameFactory.java 26 Jun 2003 06:59:56 -0000 1.3 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -57,6 +57,9 @@ import java.util.Hashtable; import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.EngineException; /** @@ -67,6 +70,9 @@ */ public class NameFactory { + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(NameFactory.class); + /** * The fully qualified class name of the Java name generator. */ @@ -119,12 +125,12 @@ } catch (InstantiationException e) { - System.err.println("Unable to instantiate class " + name + log.error("Unable to instantiate class " + name + ": Make sure it's in your run-time classpath"); } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } algorithms.put(name, algorithm); } 1.2 +16 -13 db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java Index: XmlToAppData.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToAppData.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- XmlToAppData.java 10 Feb 2003 13:20:59 -0000 1.1 +++ XmlToAppData.java 26 Jun 2003 06:59:56 -0000 1.2 @@ -3,7 +3,7 @@ /* ==================================================================== * The Apache Software License, Version 1.1 * - * Copyright (c) 2001 The Apache Software Foundation. All rights + * Copyright (c) 2001-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,6 +61,9 @@ import java.util.Vector; import java.util.Stack; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.database.model.AppData; import org.apache.torque.engine.database.model.Column; import org.apache.torque.engine.database.model.Database; @@ -89,8 +92,8 @@ */ public class XmlToAppData extends DefaultHandler { - /** enables debug output */ - private static final boolean DEBUG = false; + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(XmlToAppData.class); private AppData app; private Database currDB; @@ -185,7 +188,7 @@ BufferedReader br = new BufferedReader(fr); try { - System.out.println("Parsing file: '" + log.info("Parsing file: '" + (new File(xmlFile)).getName() + "'"); InputSource is = new InputSource(br); parser.parse(is, this); @@ -197,7 +200,7 @@ } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } if (!isExternalSchema) { @@ -205,7 +208,7 @@ } if (errorMessage.length() > 0) { - System.out.println("Error in XML schema: " + errorMessage); + log.error("Error in XML schema: " + errorMessage); } return app; } @@ -323,7 +326,7 @@ } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } } @@ -338,9 +341,9 @@ */ public void endElement(String uri, String localName, String rawName) { - if (DEBUG) + if (log.isDebugEnabled()) { - System.out.println("endElement(" + uri + ", " + localName + ", " + log.debug("endElement(" + uri + ", " + localName + ", " + rawName + ") called"); } } @@ -383,9 +386,9 @@ */ private final void printParseError(String type, SAXParseException spe) { - System.err.println(type + "[file '" - + (new File(currentXmlFile)).getName() + "', line " - + spe.getLineNumber() + ", row " + spe.getColumnNumber() + log.error(type + "[file '" + (new File(currentXmlFile)).getName() + + "', line " + spe.getLineNumber() + + ", row " + spe.getColumnNumber() + "]: " + spe.getMessage()); } 1.3 +15 -10 db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToData.java Index: XmlToData.java =================================================================== RCS file: /home/cvs/db-torque/src/generator/src/java/org/apache/torque/engine/database/transform/XmlToData.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XmlToData.java 21 Mar 2003 17:31:09 -0000 1.2 +++ XmlToData.java 26 Jun 2003 06:59:56 -0000 1.3 @@ -66,6 +66,9 @@ import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.torque.engine.database.model.Column; import org.apache.torque.engine.database.model.Database; import org.apache.torque.engine.database.model.Table; @@ -89,6 +92,8 @@ */ public class XmlToData extends DefaultHandler implements EntityResolver { + /** Logging class from commons.logging */ + private static Log log = LogFactory.getLog(XmlToData.class); private Database database; private String errorMessage; private List data; @@ -143,11 +148,11 @@ catch (Exception e) { //System.out.println("Error : "+e); - e.printStackTrace(); + log.error(e, e); } if (errorMessage.length() > 0) { - System.out.println("ERROR in data file!!!\n" + errorMessage); + log.error("ERROR in data file!!!\n" + errorMessage); } return data; @@ -181,7 +186,7 @@ } catch (Exception e) { - e.printStackTrace(); + log.error(e, e); } } @@ -192,7 +197,7 @@ */ public void warning(SAXParseException spe) { - System.out.println("Warning Line: " + spe.getLineNumber() + log.warn("Warning Line: " + spe.getLineNumber() + " Row: " + spe.getColumnNumber() + " Msg: " + spe.getMessage()); } @@ -204,7 +209,7 @@ */ public void error(SAXParseException spe) { - System.out.println("Error Line: " + spe.getLineNumber() + log.error("Error Line: " + spe.getLineNumber() + " Row: " + spe.getColumnNumber() + " Msg: " + spe.getMessage()); } @@ -216,7 +221,7 @@ */ public void fatalError(SAXParseException spe) { - System.out.println("Fatal Error Line: " + spe.getLineNumber() + log.fatal("Fatal Error Line: " + spe.getLineNumber() + " Row: " + spe.getColumnNumber() + " Msg: " + spe.getMessage()); } @@ -230,12 +235,12 @@ { if (dataDTD != null && dtdFileName.equals(systemId)) { - System.out.println("Resolver: used " + dtdFile.getPath()); + log.info("Resolver: used " + dtdFile.getPath()); return dataDTD; } else { - System.out.println("Resolver: used " + systemId); + log.info("Resolver: used " + systemId); return getInputSource(systemId); } } @@ -255,7 +260,7 @@ } catch (IOException ex) { - ex.printStackTrace(); + log.error(ex, ex); } return new InputSource(); }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]