costin      2002/12/18 21:31:47

  Modified:    util/java/org/apache/tomcat/util/net PoolTcpEndpoint.java
  Log:
  Use commons-loggign directly.
  
  This way any logger can be used ( and the same logger config ).
  
  Revision  Changes    Path
  1.9       +42 -25    
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java
  
  Index: PoolTcpEndpoint.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/PoolTcpEndpoint.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- PoolTcpEndpoint.java      28 Nov 2002 15:16:31 -0000      1.8
  +++ PoolTcpEndpoint.java      19 Dec 2002 05:31:46 -0000      1.9
  @@ -67,10 +67,12 @@
   import org.apache.tomcat.util.res.*;
   import org.apache.tomcat.util.collections.SimplePool;
   import org.apache.tomcat.util.threads.*;
  -import org.apache.tomcat.util.log.*;
  +//import org.apache.tomcat.util.log.*;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
  +
   import java.io.*;
   import java.net.*;
  -import java.util.*;
   
   /* Similar with MPM module in Apache2.0. Handles all the details related with
      "tcp server" functionality - thread management, accept policy, etc.
  @@ -123,7 +125,10 @@
       static final int debug=0;
   
       ThreadPool tp;
  -    protected Log _log=Log.getLog("tc/PoolTcpEndpoint", "PoolTcpEndpoint");
  +    // XXX Do we need it for backward compat ?
  +    //protected Log _log=Log.getLog("tc/PoolTcpEndpoint", "PoolTcpEndpoint");
  +
  +    static Log log=LogFactory.getLog(PoolTcpEndpoint.class );
   
       protected boolean tcpNoDelay=false;
       protected int linger=100;
  @@ -133,7 +138,11 @@
        //      super("tc_log");        // initialize default logger
        tp = new ThreadPool();
       }
  -    
  +
  +    public PoolTcpEndpoint( ThreadPool tp ) {
  +        this.tp=tp;
  +    }
  +
       // -------------------- Configuration --------------------
   
       public void setPoolOn(boolean isPool) {
  @@ -294,7 +303,7 @@
            listener = new TcpWorkerThread(this);
               tp.runIt(listener);
           } else {
  -         log("XXX Error - need pool !", null, Log.ERROR);
  +         log.error("XXX Error - need pool !");
        }
       }
   
  @@ -315,12 +324,12 @@
                }
                s.close();
            } catch(Exception e) {
  -                log("Caught exception trying to unlock accept.", e);
  +                log.error("Caught exception trying to unlock accept.", e);
            }
            try {
                serverSocket.close();
            } catch(Exception e) {
  -                log("Caught exception trying to close socket.", e);
  +                log.error("Caught exception trying to close socket.", e);
            }
            serverSocket = null;
        }
  @@ -362,7 +371,7 @@
   
                String msg = sm.getString("endpoint.err.nonfatal",
                                          serverSocket, e);
  -             log(msg, e, Log.ERROR);
  +             log.error(msg, e);
   
                   if (accepted != null) {
                       try {
  @@ -371,7 +380,7 @@
                       } catch(Exception ex) {
                           msg = sm.getString("endpoint.err.nonfatal",
                                              accepted, ex);
  -                        log(msg, ex, Log.INFORMATION);
  +                        log.warn(msg, ex);
                       }
                   }
                   // Restart endpoint when getting an IOException during accept
  @@ -381,7 +390,7 @@
                       } catch(Exception ex) {
                           msg = sm.getString("endpoint.err.nonfatal",
                                              serverSocket, ex);
  -                        log(msg, ex, Log.INFORMATION);
  +                        log.warn(msg, ex);
                       }
                       serverSocket = null;
                       try {
  @@ -396,7 +405,7 @@
                       } catch (Throwable t) {
                           msg = sm.getString("endpoint.err.fatal", 
                                              serverSocket, t);
  -                        log(msg, t, Log.ERROR);
  +                        log.error(msg, t);
                           stopEndpoint();
                       }
                   }
  @@ -408,23 +417,31 @@
        return accepted;
       }
   
  -    public void log(String msg) 
  +    /** @deprecated
  +     */
  +    public void log(String msg)
       {
  -     _log.log(msg, null, Log.INFORMATION);
  +     log.info(msg);
       }
  -    
  -    public void log(String msg, Throwable t) 
  +
  +    /** @deprecated
  +     */
  +    public void log(String msg, Throwable t)
       {
  -     _log.log(msg, t, Log.ERROR);
  +     log.error( msg, t );
       }
   
  -    public void log(String msg, int level) 
  +    /** @deprecated
  +     */
  +    public void log(String msg, int level)
       {
  -     _log.log(msg, null, level);
  +     log.info( msg );
       }
   
  +    /** @deprecated
  +     */
       public void log(String msg, Throwable t, int level) {
  -     _log.log( msg, t, level );
  +     log.error( msg, t );
       }
   
       void setSocketOptions(Socket socket)
  @@ -496,7 +513,7 @@
            try {
                s = endpoint.acceptSocket();
            } catch (Throwable t) {
  -             endpoint.log("Exception in acceptSocket", t);
  +             endpoint.log.error("Exception in acceptSocket", t);
            }
            if(null != s) {
                // Continue accepting on another thread...
  @@ -507,7 +524,7 @@
                           endpoint.getServerSocketFactory().handshake(s);
                    }
                   } catch (Throwable t) {
  -                    endpoint.log("Handshake failed", t, Log.DEBUG);
  +                    endpoint.log.info("Handshake failed", t);
                       // Try to close the socket
                       try {
                           s.close();
  @@ -533,7 +550,7 @@
                    endpoint.setSocketOptions( s );
                    endpoint.getConnectionHandler().processConnection(con, perThrData);
                   } catch (Throwable t) {
  -                    endpoint.log("Unexpected error", t, Log.ERROR);
  +                    endpoint.log.error("Unexpected error", t);
                       // Try to close the socket
                       try {
                           s.close();
  
  
  

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

Reply via email to