billbarker 2002/09/11 21:38:37 Modified: src/share/org/apache/tomcat/util/depend DependClassLoader.java DependClassLoader12.java DependManager.java Log: Converting logging to use commons-logging. First conversion to check that all the settings still work. Revision Changes Path 1.18 +11 -9 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java Index: DependClassLoader.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- DependClassLoader.java 11 Sep 2002 03:27:30 -0000 1.17 +++ DependClassLoader.java 12 Sep 2002 04:38:37 -0000 1.18 @@ -84,6 +84,9 @@ * */ public class DependClassLoader extends ClassLoader { + static org.apache.commons.logging.Log logger = + org.apache.commons.logging.LogFactory.getLog(DependClassLoader.class); + protected ClassLoader parent; protected ClassLoader parent2; @@ -126,11 +129,6 @@ this.pd=pd; } - // debug only - final void log( String s ) { - System.out.println("DependClassLoader: " + s ); - } - /** * Resolves the specified name to a Class. The method loadClass() * is called by the virtual machine. As an abstract method, @@ -156,7 +154,8 @@ protected Class loadClassInternal1( String name, boolean resolve ) throws ClassNotFoundException { - if( debug>9) log( "loadClass() " + name + " " + resolve); + if( logger.isTraceEnabled() ) + logger.trace( "loadClass() " + name + " " + resolve); // The class object that will be returned. Class c = null; @@ -205,7 +204,8 @@ } is.close(); } catch(IOException ex ) { - if( debug > 0 ) ex.printStackTrace(); + if( logger.isDebugEnabled() ) + logger.debug(" error reading " + name, ex); data=null; throw new ClassNotFoundException( name + " error reading " + ex.toString()); } @@ -242,7 +242,8 @@ File f=null; if( "file".equals( res.getProtocol() )) { f=new File( res.getFile()); - if( debug > 9 ) log( "File dep " +f ); + if( logger.isTraceEnabled() ) + logger.trace( "File dep " +f ); if( ! f.exists()) f=null; } if( "jar".equals( res.getProtocol() )) { @@ -257,7 +258,8 @@ if( fileN.startsWith( "/file:" )) fileN=fileN.substring( 6 ); f=new File(fileN); - if( debug > 9 ) log( "Jar dep " +f + " " + f.exists() ); + if( logger.isTraceEnabled() ) + logger.trace( "Jar dep " +f + " " + f.exists() ); if( ! f.exists()) f=null; } 1.13 +11 -9 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader12.java Index: DependClassLoader12.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependClassLoader12.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- DependClassLoader12.java 11 Sep 2002 03:27:30 -0000 1.12 +++ DependClassLoader12.java 12 Sep 2002 04:38:37 -0000 1.13 @@ -79,6 +79,9 @@ */ class DependClassLoader12Impl extends URLClassLoader { + static org.apache.commons.logging.Log logger = + org.apache.commons.logging.LogFactory.getLog(DependClassLoader12Impl.class); + private final static String FILE_PROTOCOL = "file:"; private final static String BANG = "!"; @@ -197,18 +200,14 @@ return parent.getResources(name); } - // debug only - final void log( String s ) { - System.out.println("DependClassLoader12: " + s ); - } - /** Actual class loading. The name 'loadClassInternal' generates a warning, * as a private method with the same name exists int ClassLoader in JDK1.1 ( Sun impl ). */ protected Class loadClassInternal1( String name, boolean resolve ) throws ClassNotFoundException { - if( debug>9) log( "loadClass() " + name + " " + resolve); + if( logger.isTraceEnabled() ) + logger.trace( "loadClass() " + name + " " + resolve); // The class object that will be returned. Class c = null; @@ -257,7 +256,8 @@ } is.close(); } catch(IOException ex ) { - if( debug > 0 ) ex.printStackTrace(); + if( logger.isDebugEnabled() ) + logger.debug("error reading " + name, ex); data=null; throw new ClassNotFoundException( name + " error reading " + ex.toString()); } @@ -285,7 +285,8 @@ File f=null; if( "file".equals( res.getProtocol() )) { f=new File( res.getFile()); - if( debug > 9 ) log( "File dep " +f ); + if( logger.isTraceEnabled() ) + logger.trace( "File dep " +f ); if( ! f.exists()) f=null; } if( "jar".equals( res.getProtocol() )) { @@ -300,7 +301,8 @@ if( fileN.startsWith( "/file:" )) fileN=fileN.substring( 6 ); f=new File(fileN); - if( debug > 9 ) log( "Jar dep " +f + " " + f.exists() ); + if( logger.isTraceEnabled() ) + logger.trace( "Jar dep " +f + " " + f.exists() ); if( ! f.exists()) f=null; } 1.8 +29 -19 jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependManager.java Index: DependManager.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/depend/DependManager.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DependManager.java 13 Jun 2001 01:42:16 -0000 1.7 +++ DependManager.java 12 Sep 2002 04:38:37 -0000 1.8 @@ -75,6 +75,9 @@ servers ( with many contexts) it have scalability problems. */ public class DependManager { + static org.apache.commons.logging.Log logger = + org.apache.commons.logging.LogFactory.getLog(DependManager.class); + int delay=4000; Dependency deps[]; int depsCount=0; @@ -123,7 +126,7 @@ public boolean shouldReload() { boolean b=shouldReload1(); if( b!=expired && noWarnBadVM ) { - log("BUG ( VM or Tomcat? ) shouldReload returns expired=" + b + + logger.info("BUG ( VM or Tomcat? ) shouldReload returns expired=" + b + " and the real value is " + expired); noWarnBadVM=false; } @@ -134,22 +137,30 @@ public boolean shouldReload1() { // somebody else is checking, so we don't know yet. // assume we're fine - reduce the need for sync - if( debug > 0 && expired ) - log( "ShouldReload1 E=" + expired + " C=" + checking); + if( expired ) { + if(logger.isDebugEnabled()) + logger.debug( "ShouldReload1 E=" + expired + " C=" + checking); + } if( checking ) return expired; synchronized(this) { try { // someone else got here and did it before me - if( debug>0 && expired ) - log( "ShouldReload2 E=" + expired + " C=" + checking); + if( expired ) { + if(logger.isDebugEnabled()) + logger.debug( "ShouldReload2 E=" + expired + + " C=" + checking); + } if( checking ) return expired; // did a check in the last N seconds long startCheck=System.currentTimeMillis(); if( startCheck - lastCheck < delay ) { - if( debug > 0 && expired ) - log( "ShouldReload3 E=" + expired + " C=" + checking); + if( expired ) { + if(logger.isDebugEnabled()) + logger.debug( "ShouldReload3 E=" + expired + + " C=" + checking); + } return expired; } @@ -161,14 +172,13 @@ Dependency d=deps[i]; if( d.checkExpiry() ) { // something got modified - if( debug > 0) - log("Found expired file " + + if( logger.isDebugEnabled()) + logger.debug("Found expired file " + d.getOrigin().getName()); if( ! d.isLocal() ) { // if d is local, it'll just be marked as expired, // the DependManager will not. - // if( debug >0 ) expired=true; } } @@ -179,8 +189,10 @@ } finally { checking=false; } - if( debug > 0 && expired ) - log( "ShouldReload5 E=" + expired + " C=" + checking); + if( expired ) { + if(logger.isDebugEnabled()) + logger.debug( "ShouldReload5 E=" + expired + " C=" + checking); + } return expired; } } @@ -195,8 +207,8 @@ } public void setExpired( boolean e ) { - if( debug > 0 ) { - log( "SetExpired " + e ); + if( logger.isDebugEnabled() ) { + logger.debug( "SetExpired " + e ); } for( int i=0; i<depsCount; i++ ) { deps[i].setExpired( e ); @@ -210,7 +222,8 @@ deps=deps1; } deps[depsCount++]= dep ; - if( debug>2) log( "Added " + dep.getOrigin() + " " + dep.getTarget()); + if( logger.isDebugEnabled() ) + logger.debug( "Added " + dep.getOrigin() + " " + dep.getTarget()); } // -------------------- Private @@ -220,8 +233,5 @@ public void setDebug( int i ) { debug=i; } - - void log( String s ) { - System.out.println("DependManager: " + s ); - } + }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>