tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From billbar...@apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/util/compat Jdk11Compat.java Jdk12Support.java SimpleClassLoader.java
Date Fri, 13 Sep 2002 04:47:02 GMT
billbarker    2002/09/12 21:47:02

  Modified:    src/share/org/apache/tomcat/util/compat Jdk11Compat.java
                        Jdk12Support.java SimpleClassLoader.java
  Log:
  Converting to using commons-logging.
  
  Revision  Changes    Path
  1.14      +7 -10     jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk11Compat.java
  
  Index: Jdk11Compat.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk11Compat.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Jdk11Compat.java	18 Sep 2001 23:24:46 -0000	1.13
  +++ Jdk11Compat.java	13 Sep 2002 04:47:02 -0000	1.14
  @@ -74,7 +74,9 @@
       The base class supports JDK1.1 behavior. 
   */
   public class Jdk11Compat {
  -
  +    static org.apache.commons.logging.Log logger =
  +	org.apache.commons.logging.LogFactory.getLog(Jdk11Compat.class);
  +    
       /** Return java version as a string
        */
       public static String getJavaVersion() {
  @@ -209,7 +211,8 @@
   	    try {
   		URL url=new URL( "jar:file:/test.jar!/foo");
   	    } catch( MalformedURLException ex ) {
  -		if( dL >0) d( "Installing jar protocol handler ");
  +		if( logger.isDebugEnabled() ) 
  +		    logger.debug( "Installing jar protocol handler ");
   		String handlers=System.getProperty("java.protocol.handler.pkgs");
   		if( handlers==null ) {
   		    handlers=URL_COMPAT_HANDLERS;
  @@ -219,12 +222,11 @@
   		    }
   		}
   		System.getProperties().put("java.protocol.handler.pkgs", handlers);
  -		if( dL > 0 ) {
  +		if( logger.isDebugEnabled() ) {
   		    try {
   			URL url=new URL( "jar:file:/test.jar!/foo");
   		    } catch( MalformedURLException ex1 ) {
  -			d("Jar protocol failing ");
  -			ex1.printStackTrace();
  +			logger.debug("Jar protocol failing ", ex1);
   		    }
   		}
   	    }
  @@ -233,10 +235,5 @@
   
       private static final String URL_COMPAT_HANDLERS=
   	"org.apache.tomcat.util.compat";
  -
  -    private static final int dL=10;
  -    private static void d(String s ) {
  -        System.err.println( "Jdk11Compat: " + s );
  -    }
   
   }
  
  
  
  1.11      +0 -1      jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk12Support.java
  
  Index: Jdk12Support.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/compat/Jdk12Support.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Jdk12Support.java	11 Jan 2002 06:55:30 -0000	1.10
  +++ Jdk12Support.java	13 Sep 2002 04:47:02 -0000	1.11
  @@ -72,7 +72,6 @@
    */
   public class Jdk12Support extends Jdk11Compat {
   
  -
       /** Return a class loader. For JDK1.2+ will return a URLClassLoader.
        *  For JDK1.1 will return the util.SimepleClassLoader
        */
  
  
  
  1.5       +26 -23    jakarta-tomcat/src/share/org/apache/tomcat/util/compat/SimpleClassLoader.java
  
  Index: SimpleClassLoader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/util/compat/SimpleClassLoader.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SimpleClassLoader.java	17 Jun 2001 18:09:13 -0000	1.4
  +++ SimpleClassLoader.java	13 Sep 2002 04:47:02 -0000	1.5
  @@ -86,7 +86,8 @@
    * The class path can be set only when the object is constructed.
    */
   public class SimpleClassLoader extends ClassLoader {
  -    private static final int debug=0;
  +    static org.apache.commons.logging.Log logger =
  +	org.apache.commons.logging.LogFactory.getLog(SimpleClassLoader.class);
       
       /**
        * The classpath which this classloader searches for class definitions.
  @@ -168,11 +169,6 @@
   	}
       }
       
  -    // debug only 
  -    void log( String s ) {
  -	System.out.println("SimpleClassLoader: " + s );
  -    }
  -
       //------------------------------------ Implementation of Classloader
   
       /*
  @@ -202,7 +198,8 @@
       protected synchronized Class loadClass(String name, boolean resolve)
           throws ClassNotFoundException
       {
  -        if( debug>0) log( "loadClass() " + name + " " + resolve);
  +        if( logger.isDebugEnabled() )
  +	    logger.debug( "loadClass() " + name + " " + resolve);
   	// The class object that will be returned.
           Class c = null;
   
  @@ -219,7 +216,8 @@
   	    try {
   		c = parent.loadClass(name);
   		if (c != null) {
  -		    if( debug>0) log( "loadClass() from parent " + name);
  +		    if( logger.isDebugEnabled() ) 
  +			logger.debug( "loadClass() from parent " + name);
   		    if (resolve) resolveClass(c);
   		    return c;
   		}
  @@ -232,7 +230,8 @@
   	try {
   	    c = findSystemClass(name);
   	    if (c != null) {
  -		if( debug>0) log( "loadClass() from system " + name);
  +		if( logger.isDebugEnabled() ) 
  +		    logger.debug( "loadClass() from system " + name);
   		if (resolve) resolveClass(c);
   		return c;
   	    }
  @@ -253,7 +252,8 @@
   	if( reserved!=null ) {
   	    for( int i=0; i<reserved.length; i++ ) {
   		if( name.startsWith( reserved[i] )) {
  -		    if( debug>0) log( "reserved: " + name + " " + reserved[i]);
  +		    if( logger.isDebugEnabled() ) 
  +			logger.debug( "reserved: " + name + " " + reserved[i]);
   		    throw new ClassNotFoundException(name);
   		}
   	    }
  @@ -306,11 +306,12 @@
   	    try {
   		c = defineClass(name, classData, 0, classData.length );
   		if (resolve) resolveClass(c);
  -		if( debug>0) log( "loadClass() from local repository " +
  +		if( logger.isDebugEnabled() ) 
  +		    logger.debug( "loadClass() from local repository " +
   				  name);
   		return c;
   	    } catch(Throwable t ) {
  -		t.printStackTrace();
  +		logger.error("Error Defining class: " + name,t);
   	    }
   	}
   
  @@ -327,7 +328,7 @@
        * @return  an URL on the resource, or null if not found.
        */
       public URL getResource(String name) {
  -        if( debug > 0 ) log( "getResource() " + name );
  +        if( logger.isDebugEnabled() ) logger.debug( "getResource() " + name );
   	URL u = null;
   
   	if (parent != null) {
  @@ -352,7 +353,7 @@
   		return new URL("file", null,
   			       r.file.getAbsolutePath());
   	    } catch(java.net.MalformedURLException badurl) {
  -		badurl.printStackTrace();
  +		logger.error("bad file: " + r.file, badurl);
   		return null;
   	    }
   	}
  @@ -366,7 +367,7 @@
   			       r.repository.getPath() + "!/" +
   			       name);
   	    } catch(java.net.MalformedURLException badurl) {
  -		badurl.printStackTrace();
  +		logger.error("bad jar: " + r.repository, badurl);
   		return null;
   	    } finally {
   		try {
  @@ -394,13 +395,15 @@
        */
       public InputStream getResourceAsStream(String name) {
           // Try to load it from the system class
  -        if( debug > 0 ) log( "getResourceAsStream() " + name );
  +        if( logger.isDebugEnabled() ) 
  +	    logger.debug( "getResourceAsStream() " + name );
   	//	InputStream s = getSystemResourceAsStream(name);
   	InputStream s = null;
   
   	if (parent != null) {
   	    s = parent.getResourceAsStream(name);
  -	    if( debug>0 ) log( "Found resource in parent " + s );
  +	    if( logger.isDebugEnabled() ) 
  +		logger.debug( "Found resource in parent " + s );
   	    if (s != null)
   		return s;
   	}
  @@ -408,7 +411,8 @@
   	// Get this resource from system class loader 
   	s = getSystemResourceAsStream(name);
   
  -        if( debug>0 ) log( "System resource " + s );
  +        if( logger.isDebugEnabled() ) 
  +	    logger.debug( "System resource " + s );
   	if (s != null) {
   	    return s;
   	}
  @@ -418,16 +422,16 @@
   	if( r==null ) return null;
   	
   	if( r.file!=null ) {
  -	    if( debug > 0 ) log( "Found "  + r.file);
  +	    if( logger.isDebugEnabled() ) logger.debug( "Found "  + r.file);
   	    try {
                   InputStream res=new FileInputStream(r.file);
   		return res;
               } catch (IOException shouldnothappen) {
  -		shouldnothappen.printStackTrace();
  +		logger.error("No File: " + r.file, shouldnothappen);
   		return null;
               }
   	} else if( r.zipEntry != null ) {
  -	    if( debug > 0 ) log( "Found "  + r.zipEntry);
  +	    if( logger.isDebugEnabled() ) logger.debug( "Found "  + r.zipEntry);
   	    // workaround - the better solution is to not close the
   	    // zipfile !!!!
   	    try {
  @@ -498,8 +502,7 @@
                       }
   		    zf.close();
                   } catch (IOException ioe) {
  -                    ioe.printStackTrace();
  -		    System.out.println("Name= " + name + " " + file );
  +                    logger.error("Name= " + name + " " + file , ioe);
                       return null;
                   }
               }   
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message