directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r326583 [1/2] - in /directory/network: branches/0.7/ branches/0.7/src/examples/org/apache/mina/examples/echoserver/ branches/0.7/src/examples/org/apache/mina/examples/sumup/ branches/0.7/src/java/org/apache/mina/common/ branches/0.7/src/jav...
Date Wed, 19 Oct 2005 15:37:13 GMT
Author: trustin
Date: Wed Oct 19 08:36:22 2005
New Revision: 326583

URL: http://svn.apache.org/viewcvs?rev=326583&view=rev
Log:
* Resolved issue: DIRMINA-103 - Change logging framework to SLF4J
** SLF4J doesn't provide Level interface, so I had to adjust some classes
* Fixed that ThreadPoolFilter doesn't shut down immediately again



Modified:
    directory/network/branches/0.7/project.properties
    directory/network/branches/0.7/project.xml
    directory/network/branches/0.7/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
    directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
    directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
    directory/network/branches/0.7/src/java/org/apache/mina/common/DefaultExceptionMonitor.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/filter/IoLoggingFilter.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLFilter.java
    directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLHandler.java
    directory/network/branches/0.7/src/java/org/apache/mina/protocol/filter/ProtocolLoggingFilter.java
    directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java
    directory/network/branches/0.7/src/java/org/apache/mina/util/SessionLog.java
    directory/network/branches/0.7/xdocs/faq.fml
    directory/network/trunk/project.properties
    directory/network/trunk/project.xml
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
    directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
    directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
    directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
    directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
    directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java
    directory/network/trunk/xdocs/faq.fml

Modified: directory/network/branches/0.7/project.properties
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/project.properties?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/project.properties (original)
+++ directory/network/branches/0.7/project.properties Wed Oct 19 08:36:22 2005
@@ -23,7 +23,7 @@
 maven.junit.fork=no
 #maven.junit.jvmargs=-Xmx160m -verbose -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
 
-maven.javadoc.links = http://java.sun.com/j2se/1.5.0/docs/api/, http://www.junit.org/junit/javadoc/3.8.1/
+maven.javadoc.links = http://java.sun.com/j2se/1.5.0/docs/api/, http://www.junit.org/junit/javadoc/3.8.1/, http://www.slf4j.org/api/
 maven.javadoc.package = false
 
 # Eclipse settings.

Modified: directory/network/branches/0.7/project.xml
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/project.xml?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/project.xml (original)
+++ directory/network/branches/0.7/project.xml Wed Oct 19 08:36:22 2005
@@ -90,6 +90,13 @@
 
   <dependencies>
 
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.0-beta7</version>
+      <url>http://www.slf4j.org/</url>
+    </dependency>
+
     <!-- ========================================================= -->
     <!-- Dependencies required for running test cases and examples -->
     <!-- ========================================================= -->

Modified: directory/network/branches/0.7/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java (original)
+++ directory/network/branches/0.7/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,6 @@
  */
 package org.apache.mina.examples.echoserver;
 
-import java.util.logging.Logger;
-
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.SessionConfig;
@@ -27,6 +25,8 @@
 import org.apache.mina.io.IoHandlerAdapter;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.io.socket.SocketSessionConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link IoHandler} implementation for echo server. 
@@ -36,7 +36,7 @@
  */
 public class EchoProtocolHandler extends IoHandlerAdapter
 {
-    private static final Logger log = Logger.getLogger( EchoProtocolHandler.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( EchoProtocolHandler.class );
 
     public void sessionCreated( IoSession session )
     {

Modified: directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java (original)
+++ directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,6 @@
  */
 package org.apache.mina.examples.sumup;
 
-import java.util.logging.Level;
-
 import org.apache.mina.examples.sumup.message.AddMessage;
 import org.apache.mina.examples.sumup.message.ResultMessage;
 import org.apache.mina.protocol.ProtocolHandler;
@@ -82,7 +80,7 @@
             if( rm.getSequence() == values.length - 1 )
             {
                 // print the sum and disconnect.
-                SessionLog.log( Level.INFO, session, "The sum: " + rm.getValue() );
+                SessionLog.info( session, "The sum: " + rm.getValue() );
                 session.close();
                 finished = true;
             }
@@ -90,7 +88,7 @@
         else
         {
             // seever returned error code because of overflow, etc.
-            SessionLog.log( Level.WARNING, session, "Server error, disconnecting..." );
+            SessionLog.warn( session, "Server error, disconnecting..." );
             session.close();
             finished = true;
         }

Modified: directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java (original)
+++ directory/network/branches/0.7/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,6 @@
  */
 package org.apache.mina.examples.sumup;
 
-import java.util.logging.Level;
-
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.examples.sumup.message.AddMessage;
 import org.apache.mina.examples.sumup.message.ResultMessage;
@@ -99,7 +97,7 @@
 
     public void sessionIdle( ProtocolSession session, IdleStatus status )
     {
-        SessionLog.log( Level.WARNING, session, "Disconnecting the idle." );
+        SessionLog.warn( session, "Disconnecting the idle." );
         // disconnect an idle client
         session.close();
     }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/common/DefaultExceptionMonitor.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/common/DefaultExceptionMonitor.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/common/DefaultExceptionMonitor.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/common/DefaultExceptionMonitor.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,8 @@
  */
 package org.apache.mina.common;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A default {@link ExceptionMonitor} implementation that logs uncaught
@@ -33,10 +33,10 @@
  */
 public class DefaultExceptionMonitor implements ExceptionMonitor
 {
-    private static final Logger log = Logger.getLogger( DefaultExceptionMonitor.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( DefaultExceptionMonitor.class );
 
     public void exceptionCaught( Object source, Throwable cause )
     {
-        log.log( Level.WARNING, "Unexpected exception.", cause );
+        log.warn( "Unexpected exception.", cause );
     }
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/filter/IoLoggingFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/filter/IoLoggingFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/filter/IoLoggingFilter.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/filter/IoLoggingFilter.java Wed Oct 19 08:36:22 2005
@@ -18,14 +18,12 @@
  */
 package org.apache.mina.io.filter;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.io.IoFilter;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.util.SessionLog;
+import org.slf4j.Logger;
 
 /**
  * Logs all MINA I/O events to {@link Logger}.
@@ -48,8 +46,6 @@
      */
     public static final String LOGGER = SessionLog.LOGGER;
     
-    private Level defaultLevel = Level.INFO;
-    
     /**
      * Creates a new instance.
      */
@@ -57,63 +53,45 @@
     {
     }
     
-    /**
-     * Returns the default level of log entry this filter logs. 
-     */
-    public Level getDefaultLevel() {
-        return defaultLevel;
-    }
-    
-    /**
-     * Sets the default level of log entry this filter logs. 
-     */
-    public void setDefaultLevel(Level defaultLevel) {
-        if( defaultLevel == null )
-        {
-            defaultLevel = Level.INFO;
-        }
-        this.defaultLevel = defaultLevel;
-    }
-    
     public void sessionOpened( NextFilter nextFilter, IoSession session )
     {
-        SessionLog.log( defaultLevel, session, "OPENED" );
+        SessionLog.info( session, "OPENED" );
         nextFilter.sessionOpened( session );
     }
 
     public void sessionClosed( NextFilter nextFilter, IoSession session )
     {
-        SessionLog.log( defaultLevel, session, "CLOSED" );
+        SessionLog.info( session, "CLOSED" );
         nextFilter.sessionClosed( session );
     }
 
     public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status )
     {
-        SessionLog.log( defaultLevel, session, "IDLE: " + status );
+        SessionLog.info( session, "IDLE: " + status );
         nextFilter.sessionIdle( session, status );
     }
 
     public void exceptionCaught( NextFilter nextFilter, IoSession session, Throwable cause )
     {
-        SessionLog.log( defaultLevel, session, "EXCEPTION:", cause );
+        SessionLog.error( session, "EXCEPTION: ", cause );
         nextFilter.exceptionCaught( session, cause );
     }
 
     public void dataRead( NextFilter nextFilter, IoSession session, ByteBuffer buf)
     {
-        SessionLog.log( defaultLevel, session, "READ: " + buf.getHexDump() );
+        SessionLog.info( session, "READ: " + buf.getHexDump() );
         nextFilter.dataRead( session, buf );
     }
 
     public void dataWritten( NextFilter nextFilter, IoSession session, Object marker)
     {
-        SessionLog.log( defaultLevel, session, "WRITTEN: " + marker );
+        SessionLog.info( session, "WRITTEN: " + marker );
         nextFilter.dataWritten( session, marker );
     }
 
     public void filterWrite( NextFilter nextFilter, IoSession session, ByteBuffer buf, Object marker)
     {
-        SessionLog.log( defaultLevel, session, "WRITE: " + marker + ", " + buf.getHexDump() );
+        SessionLog.info( session, "WRITE: " + marker + ", " + buf.getHexDump() );
         nextFilter.filterWrite( session, buf, marker );
     }
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLFilter.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLFilter.java Wed Oct 19 08:36:22 2005
@@ -18,9 +18,6 @@
  */
 package org.apache.mina.io.filter;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLException;
@@ -31,6 +28,8 @@
 import org.apache.mina.io.IoFilterAdapter;
 import org.apache.mina.io.IoHandler;
 import org.apache.mina.io.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An SSL filter that encrypts and decrypts the data exchanged in the session.
@@ -38,7 +37,7 @@
  * Java version 5 or above is mandatory to use this filter. And please note that
  * this filter only works for TCP/IP connections.
  * <p>
- * This filter logs debug information in {@link Level#FINEST} using {@link Logger}.
+ * This filter logs debug information using {@link Logger}.
  * 
  * <h2>Implementing StartTLS</h2>
  * <p>
@@ -89,7 +88,7 @@
     
     private static final String SSL_HANDLER = SSLFilter.class.getName() + ".SSLHandler";
 
-    private static final Logger log = Logger.getLogger( SSLFilter.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( SSLFilter.class );
 
     /**
      * A marker which is passed with {@link IoHandler#dataWritten(IoSession, Object)}
@@ -245,9 +244,9 @@
     public void sessionClosed( NextFilter nextFilter, IoSession session ) throws SSLException
     {
         SSLHandler sslHandler = getSSLSessionHandler( session );
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " Closed: " + sslHandler );
+            log.debug( session + " Closed: " + sslHandler );
         }
         if( sslHandler != null )
         {
@@ -281,9 +280,9 @@
         SSLHandler sslHandler = createSSLSessionHandler( nextFilter, session );
         if( sslHandler != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Data Read: " + sslHandler + " (" + buf+ ')' );
+                log.debug( session + " Data Read: " + sslHandler + " (" + buf+ ')' );
             }
             synchronized( sslHandler )
             {
@@ -297,10 +296,9 @@
 
                     if( sslHandler.isClosed() )
                     {
-                        if( log.isLoggable( Level.FINEST ) )
+                        if( log.isDebugEnabled() )
                         {
-                            log.log( Level.FINEST,
-                                     session + " SSL Session closed. Closing connection.." );
+                            log.debug( session + " SSL Session closed. Closing connection.." );
                         }
                         session.close();
                     }
@@ -347,9 +345,9 @@
         
         // Otherwise, encrypt the buffer.
         SSLHandler handler = createSSLSessionHandler( nextFilter, session );
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " Filtered Write: " + handler );
+            log.debug( session + " Filtered Write: " + handler );
         }
 
         synchronized( handler )
@@ -357,9 +355,9 @@
             if( handler.isWritingEncryptedData() )
             {
                 // data already encrypted; simply return buffer
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "   already encrypted: " + buf );
+                    log.debug( session + "   already encrypted: " + buf );
                 }
                 nextFilter.filterWrite( session, buf, marker );
                 return;
@@ -368,17 +366,17 @@
             if( handler.isInitialHandshakeComplete() )
             {
                 // SSL encrypt
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " encrypt: " + buf );
+                    log.debug( session + " encrypt: " + buf );
                 }
                 handler.encrypt( buf.buf() );
                 ByteBuffer encryptedBuffer = copy( handler
                         .getOutNetBuffer() );
 
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " encrypted buf: " + encryptedBuffer);
+                    log.debug( session + " encrypted buf: " + encryptedBuffer);
                 }
                 buf.release();
                 nextFilter.filterWrite( session, encryptedBuffer, marker );
@@ -388,16 +386,16 @@
             {
                 if( !session.isConnected() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " Write request on closed session." );
+                        log.debug( session + " Write request on closed session." );
                     }
                 }
                 else
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " Handshaking is not complete yet. Buffering write request." );
+                        log.debug( session + " Handshaking is not complete yet. Buffering write request." );
                     }
                     handler.scheduleWrite( nextFilter, buf, marker );
                 }
@@ -426,17 +424,17 @@
     private void handleAppDataRead( NextFilter nextFilter, IoSession session,
                                    SSLHandler sslHandler )
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " appBuffer: " + sslHandler.getAppBuffer() );
+            log.debug( session + " appBuffer: " + sslHandler.getAppBuffer() );
         }
         if( sslHandler.getAppBuffer().hasRemaining() )
         {
             // forward read app data
             ByteBuffer readBuffer = copy( sslHandler.getAppBuffer() );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " app data read: " + readBuffer + " (" + readBuffer.getHexDump() + ')' );
+                log.debug( session + " app data read: " + readBuffer + " (" + readBuffer.getHexDump() + ')' );
             }
             nextFilter.dataRead( session, readBuffer );
         }
@@ -463,15 +461,15 @@
 
         try
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " write outNetBuffer: " +
+                log.debug( session + " write outNetBuffer: " +
                                    sslHandler.getOutNetBuffer() );
             }
             ByteBuffer writeBuffer = copy( sslHandler.getOutNetBuffer() );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " session write: " + writeBuffer );
+                log.debug( session + " session write: " + writeBuffer );
             }
             //debug("outNetBuffer (after copy): {0}", sslHandler.getOutNetBuffer());
             filterWrite( nextFilter, session, writeBuffer, SSL_MARKER );
@@ -492,9 +490,9 @@
                 }
                 if( sslHandler.getOutNetBuffer().hasRemaining() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " write outNetBuffer2: " +
+                        log.debug( session + " write outNetBuffer2: " +
                                            sslHandler.getOutNetBuffer() );
                     }
                     ByteBuffer writeBuffer2 = copy( sslHandler

Modified: directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLHandler.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/io/filter/SSLHandler.java Wed Oct 19 08:36:22 2005
@@ -19,8 +19,6 @@
 package org.apache.mina.io.filter;
 
 import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
@@ -31,6 +29,8 @@
 import org.apache.mina.io.IoSession;
 import org.apache.mina.io.IoFilter.NextFilter;
 import org.apache.mina.util.Queue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A helper class using the SSLEngine API to decrypt/encrypt data.
@@ -45,7 +45,7 @@
  */
 class SSLHandler
 {
-    private static final Logger log = Logger.getLogger( SSLFilter.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( SSLFilter.class );
 
     private final SSLFilter parent;
 
@@ -202,9 +202,9 @@
         
         while( ( scheduledBuf = ( org.apache.mina.common.ByteBuffer ) writeBufferQueue.pop() ) != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Flushing buffered write request: " + scheduledBuf );
+                log.debug( session + " Flushing buffered write request: " + scheduledBuf );
             }
             nextFilter = ( NextFilter ) nextFilterQueue.pop();
             scheduledMarker = writeMarkerQueue.pop();
@@ -230,11 +230,11 @@
             appBuffer = SSLByteBufferPool.expandBuffer( appBuffer, inNetBuffer.capacity() * 2);
             appBuffer.position( 0 );
             appBuffer.limit( 0 );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + 
+                log.debug( session + 
                                     " expanded inNetBuffer:" + inNetBuffer );
-                log.log( Level.FINEST, session + 
+                log.debug( session + 
                                     " expanded appBuffer:" + appBuffer );
             }
         }
@@ -258,9 +258,9 @@
      */
     public void continueHandshake( NextFilter nextFilter ) throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " continueHandshake()" );
+            log.debug( session + " continueHandshake()" );
         }
         doHandshake( nextFilter );
     }
@@ -334,8 +334,8 @@
 
         if( appBuffer.hasRemaining() )
         {
-             if ( log.isLoggable( Level.FINEST ) ) {
-                 log.log( Level.FINEST, session + " Error: appBuffer not empty!" );
+             if ( log.isDebugEnabled() ) {
+                 log.debug( session + " Error: appBuffer not empty!" );
              }
             //still app data in buffer!?
             throw new IllegalStateException();
@@ -383,14 +383,14 @@
                 // Note: there is no way to know the exact size required, but enrypted data
                 // shouln't need to be larger than twice the source data size?
                 outNetBuffer = SSLByteBufferPool.expandBuffer( outNetBuffer, src.capacity() * 2 );
-                if ( log.isLoggable( Level.FINEST ) ) {
-                    log.log( Level.FINEST, session + " expanded outNetBuffer:" + outNetBuffer );
+                if ( log.isDebugEnabled() ) {
+                    log.debug( session + " expanded outNetBuffer:" + outNetBuffer );
                 }
             }
 
             result = sslEngine.wrap( src, outNetBuffer );
-            if ( log.isLoggable( Level.FINEST ) ) {
-                log.log( Level.FINEST, session + " Wrap res:" + result );
+            if ( log.isDebugEnabled() ) {
+                log.debug( session + " Wrap res:" + result );
             }
 
             if ( result.getStatus() == SSLEngineResult.Status.OK ) {
@@ -413,9 +413,9 @@
     synchronized void doHandshake( NextFilter nextFilter ) throws SSLException
     {
 
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " doHandshake()" );
+            log.debug( session + " doHandshake()" );
         }
 
         while( !initialHandshakeComplete )
@@ -423,29 +423,29 @@
             if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED )
             {
                 session.setAttribute( SSLFilter.SSL_SESSION, sslEngine.getSession() );
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
                     SSLSession sslSession = sslEngine.getSession();
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=FINISHED" );
-                    log.log( Level.FINEST, session + "  sslSession CipherSuite used " + sslSession.getCipherSuite() );
+                    log.debug( session + "  initialHandshakeStatus=FINISHED" );
+                    log.debug( session + "  sslSession CipherSuite used " + sslSession.getCipherSuite() );
                 }
                 initialHandshakeComplete = true;
                 return;
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_TASK )
             {
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=NEED_TASK" );
+                    log.debug( session + "  initialHandshakeStatus=NEED_TASK" );
                 }
                 initialHandshakeStatus = doTasks();
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_UNWRAP )
             {
                 // we need more data read
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session +
+                    log.debug( session +
                              "  initialHandshakeStatus=NEED_UNWRAP" );
                 }
                 SSLEngineResult.Status status = unwrapHandshake();
@@ -459,25 +459,25 @@
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP )
             {
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=NEED_WRAP" );
+                    log.debug( session + "  initialHandshakeStatus=NEED_WRAP" );
                 }
                 // First make sure that the out buffer is completely empty. Since we
                 // cannot call wrap with data left on the buffer
                 if( outNetBuffer.hasRemaining() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + "  Still data in out buffer!" );
+                        log.debug( session + "  Still data in out buffer!" );
                     }
                     return;
                 }
                 outNetBuffer.clear();
                 SSLEngineResult result = sslEngine.wrap( hsBB, outNetBuffer );
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " Wrap res:" + result );
+                    log.debug( session + " Wrap res:" + result );
                 }
 
                 outNetBuffer.flip();
@@ -496,9 +496,9 @@
 
     SSLEngineResult.Status unwrap() throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " unwrap()" );
+            log.debug( session + " unwrap()" );
         }
         // Prepare the application buffer to receive decrypted data
         appBuffer.clear();
@@ -509,15 +509,15 @@
         SSLEngineResult res;
         do
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+                log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                log.debug( session + "   appBuffer: " + appBuffer );
             }
             res = sslEngine.unwrap( inNetBuffer, appBuffer );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Unwrap res:" + res );
+                log.debug( session + " Unwrap res:" + res );
             }
         }
         while( res.getStatus() == SSLEngineResult.Status.OK );
@@ -546,9 +546,9 @@
 
     private SSLEngineResult.Status unwrapHandshake() throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " unwrapHandshake()" );
+            log.debug( session + " unwrapHandshake()" );
         }
         // Prepare the application buffer to receive decrypted data
         appBuffer.clear();
@@ -559,15 +559,15 @@
         SSLEngineResult res;
         do
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+                log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                log.debug( session + "   appBuffer: " + appBuffer );
             }
             res = sslEngine.unwrap( inNetBuffer, appBuffer );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Unwrap res:" + res );
+                log.debug( session + " Unwrap res:" + res );
             }
 
         }
@@ -583,14 +583,14 @@
 				&& res.getStatus() == SSLEngineResult.Status.OK
 				&& inNetBuffer.hasRemaining()) {
 			do {
-				if (log.isLoggable( Level.FINEST )) {
-					log.log( Level.FINEST, session + "  extra handshake unwrap" );
-                    log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                    log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+				if (log.isDebugEnabled()) {
+					log.debug( session + "  extra handshake unwrap" );
+                    log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                    log.debug( session + "   appBuffer: " + appBuffer );
 				}
 				res = sslEngine.unwrap(inNetBuffer, appBuffer);
-				if (log.isLoggable( Level.FINEST )) {
-                    log.log( Level.FINEST, session + " Unwrap res:" + res );
+				if (log.isDebugEnabled()) {
+                    log.debug( session + " Unwrap res:" + res );
 				}
 			} while (res.getStatus() == SSLEngineResult.Status.OK);
 		}
@@ -624,9 +624,9 @@
      */
     private SSLEngineResult.HandshakeStatus doTasks()
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + "   doTasks()" );
+            log.debug( session + "   doTasks()" );
         }
 
         /*
@@ -636,15 +636,15 @@
         Runnable runnable;
         while( ( runnable = sslEngine.getDelegatedTask() ) != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "    doTask: " + runnable );
+                log.debug( session + "    doTask: " + runnable );
             }
             runnable.run();
         }
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + "   doTasks(): "
+            log.debug( session + "   doTasks(): "
                     + sslEngine.getHandshakeStatus() );
         }
         return sslEngine.getHandshakeStatus();

Modified: directory/network/branches/0.7/src/java/org/apache/mina/protocol/filter/ProtocolLoggingFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/protocol/filter/ProtocolLoggingFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/protocol/filter/ProtocolLoggingFilter.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/protocol/filter/ProtocolLoggingFilter.java Wed Oct 19 08:36:22 2005
@@ -18,13 +18,11 @@
  */
 package org.apache.mina.protocol.filter;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.protocol.ProtocolFilter;
 import org.apache.mina.protocol.ProtocolSession;
 import org.apache.mina.util.SessionLog;
+import org.slf4j.Logger;
 
 /**
  * Logs all MINA protocol events to {@link Logger}.
@@ -47,8 +45,6 @@
      */
     public static final String LOGGER = SessionLog.LOGGER;
     
-    private Level defaultLevel = Level.INFO;
-    
     /**
      * Creates a new instance.
      */
@@ -56,64 +52,45 @@
     {
     }
     
-    
-    /**
-     * Returns the default level of log entry this filter logs. 
-     */
-    public Level getDefaultLevel() {
-        return defaultLevel;
-    }
-    
-    /**
-     * Sets the default level of log entry this filter logs. 
-     */
-    public void setDefaultLevel(Level defaultLevel) {
-        if( defaultLevel == null )
-        {
-            defaultLevel = Level.INFO;
-        }
-        this.defaultLevel = defaultLevel;
-    }
-    
     public void sessionOpened( NextFilter nextFilter, ProtocolSession session )
     {
-        SessionLog.log( defaultLevel, session, "OPENED" );
+        SessionLog.info( session, "OPENED" );
         nextFilter.sessionOpened( session );
     }
 
     public void sessionClosed( NextFilter nextFilter, ProtocolSession session )
     {
-        SessionLog.log( defaultLevel, session, "CLOSED" );
+        SessionLog.info( session, "CLOSED" );
         nextFilter.sessionClosed( session );
     }
 
     public void sessionIdle( NextFilter nextFilter, ProtocolSession session, IdleStatus status )
     {
-        SessionLog.log( defaultLevel, session, "IDLE: " + status );
+        SessionLog.info( session, "IDLE: " + status );
         nextFilter.sessionIdle( session, status );
     }
 
     public void exceptionCaught( NextFilter nextFilter, ProtocolSession session, Throwable cause )
     {
-        SessionLog.log( defaultLevel, session, "EXCEPTION:", cause );
+        SessionLog.error( session, "EXCEPTION:", cause );
         nextFilter.exceptionCaught( session, cause );
     }
 
     public void messageReceived( NextFilter nextFilter, ProtocolSession session, Object message )
     {
-        SessionLog.log( defaultLevel, session, "RECEIVED: " + message );
+        SessionLog.info( session, "RECEIVED: " + message );
         nextFilter.messageReceived( session, message );
     }
 
     public void messageSent( NextFilter nextFilter, ProtocolSession session, Object message )
     {
-        SessionLog.log( defaultLevel, session, "SENT: " + message );
+        SessionLog.info( session, "SENT: " + message );
         nextFilter.messageSent( session, message );
     }
 
     public void filterWrite( NextFilter nextFilter, ProtocolSession session, Object message)
     {
-        SessionLog.log( defaultLevel, session, "WRITE: " + message );
+        SessionLog.info( session, "WRITE: " + message );
         nextFilter.filterWrite( session, message );
     }
 }

Modified: directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/util/BaseThreadPool.java Wed Oct 19 08:36:22 2005
@@ -483,6 +483,10 @@
                     }
                     catch( InterruptedException e )
                     {
+                        if( shuttingDown )
+                        {
+                            break;
+                        }
                     }
 
                     // Update currentTime for the next iteration

Modified: directory/network/branches/0.7/src/java/org/apache/mina/util/SessionLog.java
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/src/java/org/apache/mina/util/SessionLog.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/src/java/org/apache/mina/util/SessionLog.java (original)
+++ directory/network/branches/0.7/src/java/org/apache/mina/util/SessionLog.java Wed Oct 19 08:36:22 2005
@@ -18,19 +18,17 @@
  */
 package org.apache.mina.util;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.Session;
 import org.apache.mina.io.IoSession;
 import org.apache.mina.protocol.ProtocolSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Call {@link #getLogger(Session)}, {@link #log(Level,Session, String)}, and
- * {@link #log(Level,Session, String, Throwable)} to log protocol-specific messages.
+ * Provides utility methods to log protocol-specific messages.
  * <p>
  * Set {@link #PREFIX} and {@link #LOGGER} session attributes
- * to override prefix string, logger, and log level.
+ * to override prefix string and logger.
  *
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @author Trustin Lee (trustin@apache.org)
@@ -50,11 +48,10 @@
     
     public static Logger getLogger( Session session )
     {
-        
         Logger log = (Logger) session.getAttribute( LOGGER );
         if( log == null )
         {
-            log = Logger.getLogger( getClassName( session ) );
+            log = LoggerFactory.getLogger( getClass( session ) );
             String prefix = ( String ) session.getAttribute( PREFIX );
             if( prefix == null )
             {
@@ -68,29 +65,83 @@
         return log;
     }
     
-    private static String getClassName( Session session )
+    private static Class getClass( Session session )
     {
         if( session instanceof IoSession )
-            return ( ( IoSession ) session ).getHandler().getClass().getName();
+            return ( ( IoSession ) session ).getHandler().getClass();
         else
-            return ( ( ProtocolSession ) session ).getHandler().getClass().getName();
+            return ( ( ProtocolSession ) session ).getHandler().getClass();
+    }
+
+    public static void debug( Session session, String message )
+    {
+        Logger log = getLogger( session );
+        if( log.isDebugEnabled() )
+        {
+            log.debug( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void debug( Session session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isDebugEnabled() )
+        {
+            log.debug( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
+    }
+
+    public static void info( Session session, String message )
+    {
+        Logger log = getLogger( session );
+        if( log.isInfoEnabled() )
+        {
+            log.info( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void info( Session session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isInfoEnabled() )
+        {
+            log.info( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
+    }
+
+    public static void warn( Session session, String message )
+    {
+        Logger log = getLogger( session );
+        if( log.isWarnEnabled() )
+        {
+            log.warn( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void warn( Session session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isWarnEnabled() )
+        {
+            log.warn( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
     }
 
-    public static void log( Level level, Session session, String message )
+    public static void error( Session session, String message )
     {
         Logger log = getLogger( session );
-        if( log.isLoggable( level ) )
+        if( log.isErrorEnabled() )
         {
-            log.log( level, String.valueOf( session.getAttribute( PREFIX ) ) + message );
+            log.error( String.valueOf( session.getAttribute( PREFIX ) ) + message );
         }
     }
 
-    public static void log( Level level, Session session, String message, Throwable cause )
+    public static void error( Session session, String message, Throwable cause )
     {
         Logger log = getLogger( session );
-        if( log.isLoggable( level ) )
+        if( log.isErrorEnabled() )
         {
-            log.log( level, String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+            log.error( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
         }
     }
 }

Modified: directory/network/branches/0.7/xdocs/faq.fml
URL: http://svn.apache.org/viewcvs/directory/network/branches/0.7/xdocs/faq.fml?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/branches/0.7/xdocs/faq.fml (original)
+++ directory/network/branches/0.7/xdocs/faq.fml Wed Oct 19 08:36:22 2005
@@ -72,6 +72,17 @@
           SSLEngine.  This means JDK 1.5 or above is required for you to
           use SSL with MINA.
         </p>
+        <p>
+          MINA depends on <a href="http://www.slf4j.org">SLF4J (Simple Logging
+          Facade for Java)</a>, a logging framework from the author of
+          <a href="http://logging.apache.org/log4j/docs/index.html">Log4J</a>.
+          SLF4J is very similar to
+          <a href="http://jakarta.apache.org/commons/logging/">Commons-Logging</a>,
+          but it doesn't cause any class loader issues at all.  SLF4J provides
+          bindings for Log4J, JDK 1.4 logging API, and NLog4J.  Please put an
+          appropriate SLF4J JAR file which corresponds to your favorite logging
+          framework to the classpath as SLF4J documentation explains.
+        </p>
       </answer>
     </faq>
 
@@ -320,6 +331,23 @@
         But you cannot add port-specific filters right now.  You'll have to
         create more than one <tt>IoAcceptor</tt> or <tt>ProtocolAcceptor</tt>
         because each acceptors have one filter chain you can adjust.
+      </answer>
+    </faq>
+
+    <faq id="logging-framework">
+      <quesion>
+        How can I let MINA log messages using my favorite logging framework (i.e. Log4J)?
+      </question>
+      <answer>
+        MINA depends on <a href="http://www.slf4j.org">SLF4J (Simple Logging
+        Facade for Java)</a>, a logging framework from the author of
+        <a href="http://logging.apache.org/log4j/docs/index.html">Log4J</a>.
+        SLF4J is very similar to
+        <a href="http://jakarta.apache.org/commons/logging/">Commons-Logging</a>,
+        but it doesn't cause any class loader issues at all.  SLF4J provides
+        bindings for Log4J, JDK 1.4 logging API, and NLog4J.  Please put an
+        appropriate SLF4J JAR file which corresponds to your favorite logging
+        framework to the classpath as SLF4J documentation explains.
       </answer>
     </faq>
   </part>

Modified: directory/network/trunk/project.properties
URL: http://svn.apache.org/viewcvs/directory/network/trunk/project.properties?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/project.properties (original)
+++ directory/network/trunk/project.properties Wed Oct 19 08:36:22 2005
@@ -23,7 +23,7 @@
 maven.junit.fork=no
 #maven.junit.jvmargs=-Xmx160m -verbose -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
 
-maven.javadoc.links = http://java.sun.com/j2se/1.5.0/docs/api/, http://www.junit.org/junit/javadoc/3.8.1/
+maven.javadoc.links = http://java.sun.com/j2se/1.5.0/docs/api/, http://www.junit.org/junit/javadoc/3.8.1/, http://www.slf4j.org/api/
 maven.javadoc.package = false
 
 # Eclipse settings.

Modified: directory/network/trunk/project.xml
URL: http://svn.apache.org/viewcvs/directory/network/trunk/project.xml?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/project.xml (original)
+++ directory/network/trunk/project.xml Wed Oct 19 08:36:22 2005
@@ -90,6 +90,13 @@
 
   <dependencies>
 
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.0-beta7</version>
+      <url>http://www.slf4j.org/</url>
+    </dependency>
+
     <!-- ========================================================= -->
     <!-- Dependencies required for running test cases and examples -->
     <!-- ========================================================= -->

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/EchoProtocolHandler.java Wed Oct 19 08:36:22 2005
@@ -18,14 +18,14 @@
  */
 package org.apache.mina.examples.echoserver;
 
-import java.util.logging.Logger;
-
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.transport.socket.nio.SocketSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * {@link IoHandler} implementation for echo server. 
@@ -35,7 +35,7 @@
  */
 public class EchoProtocolHandler extends IoHandlerAdapter
 {
-    private static final Logger log = Logger.getLogger( EchoProtocolHandler.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( EchoProtocolHandler.class );
 
     public void sessionCreated( IoSession session )
     {

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ClientSessionHandler.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,6 @@
  */
 package org.apache.mina.examples.sumup;
 
-import java.util.logging.Level;
-
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoHandlerAdapter;
 import org.apache.mina.common.IoSession;
@@ -86,7 +84,7 @@
             if( rm.getSequence() == values.length - 1 )
             {
                 // print the sum and disconnect.
-                SessionLog.log( Level.INFO, session, "The sum: " + rm.getValue() );
+                SessionLog.info( session, "The sum: " + rm.getValue() );
                 session.close();
                 finished = true;
             }
@@ -94,7 +92,7 @@
         else
         {
             // seever returned error code because of overflow, etc.
-            SessionLog.log( Level.WARNING, session, "Server error, disconnecting..." );
+            SessionLog.warn( session, "Server error, disconnecting..." );
             session.close();
             finished = true;
         }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/sumup/ServerSessionHandler.java Wed Oct 19 08:36:22 2005
@@ -18,8 +18,6 @@
  */
 package org.apache.mina.examples.sumup;
 
-import java.util.logging.Level;
-
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoHandler;
 import org.apache.mina.common.IoSession;
@@ -104,7 +102,7 @@
 
     public void sessionIdle( IoSession session, IdleStatus status )
     {
-        SessionLog.log( Level.WARNING, session, "Disconnecting the idle." );
+        SessionLog.info( session, "Disconnecting the idle." );
         // disconnect an idle client
         session.close();
     }

Modified: directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/support/DefaultExceptionMonitor.java Wed Oct 19 08:36:22 2005
@@ -18,11 +18,10 @@
  */
 package org.apache.mina.common.support;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.ExceptionMonitor;
 import org.apache.mina.common.IoSessionManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A default {@link ExceptionMonitor} implementation that logs uncaught
@@ -36,10 +35,10 @@
  */
 public class DefaultExceptionMonitor implements ExceptionMonitor
 {
-    private static final Logger log = Logger.getLogger( DefaultExceptionMonitor.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( DefaultExceptionMonitor.class );
 
     public void exceptionCaught( Object source, Throwable cause )
     {
-        log.log( Level.WARNING, "Unexpected exception.", cause );
+        log.warn( "Unexpected exception.", cause );
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/LoggingFilter.java Wed Oct 19 08:36:22 2005
@@ -18,13 +18,11 @@
  */
 package org.apache.mina.filter;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.IdleStatus;
 import org.apache.mina.common.IoFilter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.util.SessionLog;
+import org.slf4j.Logger;
 
 /**
  * Logs all MINA protocol events to {@link Logger}.
@@ -47,8 +45,6 @@
      */
     public static final String LOGGER = SessionLog.LOGGER;
     
-    private Level defaultLevel = Level.INFO;
-    
     /**
      * Creates a new instance.
      */
@@ -56,25 +52,6 @@
     {
     }
     
-    
-    /**
-     * Returns the default level of log entry this filter logs. 
-     */
-    public Level getDefaultLevel() {
-        return defaultLevel;
-    }
-    
-    /**
-     * Sets the default level of log entry this filter logs. 
-     */
-    public void setDefaultLevel(Level defaultLevel) {
-        if( defaultLevel == null )
-        {
-            defaultLevel = Level.INFO;
-        }
-        this.defaultLevel = defaultLevel;
-    }
-    
     public void init()
     {
     }
@@ -85,51 +62,49 @@
     
     public void sessionOpened( NextFilter nextFilter, IoSession session )
     {
-        SessionLog.log( defaultLevel, session, "OPENED" );
+        SessionLog.info( session, "OPENED" );
         nextFilter.sessionOpened( session );
     }
 
     public void sessionClosed( NextFilter nextFilter, IoSession session )
     {
-        SessionLog.log( defaultLevel, session, "CLOSED" );
+        SessionLog.info( session, "CLOSED" );
         nextFilter.sessionClosed( session );
     }
 
     public void sessionIdle( NextFilter nextFilter, IoSession session, IdleStatus status )
     {
-        SessionLog.log( defaultLevel, session, "IDLE: " + status );
+        SessionLog.info( session, "IDLE: " + status );
         nextFilter.sessionIdle( session, status );
     }
 
     public void exceptionCaught( NextFilter nextFilter, IoSession session, Throwable cause )
     {
-        SessionLog.log( defaultLevel, session, "EXCEPTION:", cause );
+        SessionLog.error( session, "EXCEPTION:", cause );
         nextFilter.exceptionCaught( session, cause );
     }
 
     public void messageReceived( NextFilter nextFilter, IoSession session, Object message )
     {
-        SessionLog.log( defaultLevel, session, "RECEIVED: " + message );
+        SessionLog.info( session, "RECEIVED: " + message );
         nextFilter.messageReceived( session, message );
     }
 
     public void messageSent( NextFilter nextFilter, IoSession session, Object message )
     {
-        SessionLog.log( defaultLevel, session, "SENT: " + message );
+        SessionLog.info( session, "SENT: " + message );
         nextFilter.messageSent( session, message );
     }
 
     public void filterWrite( NextFilter nextFilter, IoSession session, WriteRequest writeRequest )
     {
-        SessionLog.log( defaultLevel, session, "WRITE: " + writeRequest );
+        SessionLog.info( session, "WRITE: " + writeRequest );
         nextFilter.filterWrite( session, writeRequest );
     }
 
-
     public void filterAdded( Object parent ) throws Exception
     {
     }
-
 
     public void filterRemoved( Object parent ) throws Exception
     {

Modified: directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/SSLFilter.java Wed Oct 19 08:36:22 2005
@@ -18,9 +18,6 @@
  */
 package org.apache.mina.filter;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLException;
@@ -32,6 +29,8 @@
 import org.apache.mina.common.IoFilterAdapter;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.filter.support.SSLHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * An SSL filter that encrypts and decrypts the data exchanged in the session.
@@ -39,7 +38,7 @@
  * Java version 5 or above is mandatory to use this filter. And please note that
  * this filter only works for TCP/IP connections.
  * <p>
- * This filter logs debug information in {@link Level#FINEST} using {@link Logger}.
+ * This filter logs debug information using {@link Logger}.
  * 
  * <h2>Implementing StartTLS</h2>
  * <p>
@@ -90,7 +89,7 @@
     
     private static final String SSL_HANDLER = SSLFilter.class.getName() + ".SSLHandler";
 
-    private static final Logger log = Logger.getLogger( SSLFilter.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( SSLFilter.class );
 
     // SSL Context
     private SSLContext sslContext;
@@ -234,9 +233,9 @@
     public void sessionClosed( NextFilter nextFilter, IoSession session ) throws SSLException
     {
         SSLHandler sslHandler = getSSLSessionHandler( session );
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " Closed: " + sslHandler );
+            log.debug( session + " Closed: " + sslHandler );
         }
         if( sslHandler != null )
         {
@@ -271,9 +270,9 @@
         SSLHandler sslHandler = createSSLSessionHandler( nextFilter, session );
         if( sslHandler != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Data Read: " + sslHandler + " (" + buf+ ')' );
+                log.debug( session + " Data Read: " + sslHandler + " (" + buf+ ')' );
             }
             synchronized( sslHandler )
             {
@@ -287,9 +286,9 @@
 
                     if( sslHandler.isClosed() )
                     {
-                        if( log.isLoggable( Level.FINEST ) )
+                        if( log.isDebugEnabled() )
                         {
-                            log.log( Level.FINEST,
+                            log.debug(
                                      session + " SSL Session closed. Closing connection.." );
                         }
                         session.close();
@@ -345,9 +344,9 @@
         ByteBuffer buf = ( ByteBuffer ) writeRequest.getMessage();
 
         SSLHandler handler = createSSLSessionHandler( nextFilter, session );
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " Filtered Write: " + handler );
+            log.debug( session + " Filtered Write: " + handler );
         }
 
         synchronized( handler )
@@ -355,9 +354,9 @@
             if( handler.isWritingEncryptedData() )
             {
                 // data already encrypted; simply return buffer
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "   already encrypted: " + buf );
+                    log.debug( session + "   already encrypted: " + buf );
                 }
                 nextFilter.filterWrite( session, writeRequest );
                 return;
@@ -366,9 +365,9 @@
             if( handler.isInitialHandshakeComplete() )
             {
                 // SSL encrypt
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " encrypt: " + buf );
+                    log.debug( session + " encrypt: " + buf );
                 }
                 
                 int pos = buf.position();
@@ -377,9 +376,9 @@
                 ByteBuffer encryptedBuffer = new EncryptedBuffer(
                         SSLHandler.copy( handler.getOutNetBuffer() ), buf );
 
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " encrypted buf: " + encryptedBuffer);
+                    log.debug( session + " encrypted buf: " + encryptedBuffer);
                 }
                 nextFilter.filterWrite( session, new WriteRequest( encryptedBuffer, writeRequest.getFuture() ) );
                 return;
@@ -388,16 +387,16 @@
             {
                 if( !session.isConnected() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " Write request on closed session." );
+                        log.debug( session + " Write request on closed session." );
                     }
                 }
                 else
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " Handshaking is not complete yet. Buffering write request." );
+                        log.debug( session + " Handshaking is not complete yet. Buffering write request." );
                     }
                     handler.scheduleWrite( nextFilter, writeRequest );
                 }
@@ -426,17 +425,17 @@
     private void handleAppDataRead( NextFilter nextFilter, IoSession session,
                                    SSLHandler sslHandler )
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " appBuffer: " + sslHandler.getAppBuffer() );
+            log.debug( session + " appBuffer: " + sslHandler.getAppBuffer() );
         }
         if( sslHandler.getAppBuffer().hasRemaining() )
         {
             // forward read app data
             ByteBuffer readBuffer = SSLHandler.copy( sslHandler.getAppBuffer() );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " app data read: " + readBuffer + " (" + readBuffer.getHexDump() + ')' );
+                log.debug( session + " app data read: " + readBuffer + " (" + readBuffer.getHexDump() + ')' );
             }
             nextFilter.messageReceived( session, readBuffer );
         }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/ThreadPoolFilter.java Wed Oct 19 08:36:22 2005
@@ -445,6 +445,10 @@
                     }
                     catch( InterruptedException e )
                     {
+                        if( shuttingDown )
+                        {
+                            break;
+                        }
                     }
 
                     // Update currentTime for the next iteration

Modified: directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java Wed Oct 19 08:36:22 2005
@@ -1,7 +1,5 @@
 package org.apache.mina.filter.codec;
 
-import java.util.logging.Logger;
-
 import org.apache.mina.common.ByteBuffer;
 import org.apache.mina.common.ByteBufferProxy;
 import org.apache.mina.common.IoFilterAdapter;
@@ -10,10 +8,12 @@
 import org.apache.mina.filter.codec.support.SimpleProtocolDecoderOutput;
 import org.apache.mina.filter.codec.support.SimpleProtocolEncoderOutput;
 import org.apache.mina.util.Queue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class ProtocolCodecFilter extends IoFilterAdapter
 {
-    private static final Logger log = Logger.getLogger( ProtocolCodecFilter.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( ProtocolCodecFilter.class );
 
     public static final String ENCODER = ProtocolCodecFilter.class.getName() + ".encoder";
     public static final String DECODER = ProtocolCodecFilter.class.getName() + ".decoder";
@@ -206,7 +206,7 @@
         }
         catch( Throwable t )
         {
-            log.warning( "Failed to dispose: " + encoder.getClass().getName() +
+            log.warn( "Failed to dispose: " + encoder.getClass().getName() +
                     " (" + encoder + ')' );
         }
     }
@@ -226,7 +226,7 @@
         }
         catch( Throwable t )
         {
-            log.warning( "Falied to dispose: " + decoder.getClass().getName() +
+            log.warn( "Falied to dispose: " + decoder.getClass().getName() +
                     " (" + decoder + ')' );
         }
     }

Modified: directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/filter/support/SSLHandler.java Wed Oct 19 08:36:22 2005
@@ -19,8 +19,6 @@
 package org.apache.mina.filter.support;
 
 import java.nio.ByteBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
@@ -34,6 +32,8 @@
 import org.apache.mina.common.IoFilter.WriteRequest;
 import org.apache.mina.filter.SSLFilter;
 import org.apache.mina.util.Queue;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * A helper class using the SSLEngine API to decrypt/encrypt data.
@@ -48,7 +48,7 @@
  */
 public class SSLHandler
 {
-    private static final Logger log = Logger.getLogger( SSLFilter.class.getName() );
+    private static final Logger log = LoggerFactory.getLogger( SSLFilter.class );
 
     private final SSLFilter parent;
 
@@ -197,9 +197,9 @@
         
         while( ( scheduledWrite = ( ScheduledWrite ) scheduledWrites.pop() ) != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Flushing buffered write request: " + scheduledWrite.writeRequest );
+                log.debug( session + " Flushing buffered write request: " + scheduledWrite.writeRequest );
             }
             parent.filterWrite( scheduledWrite.nextFilter, session, scheduledWrite.writeRequest );
         }
@@ -223,11 +223,11 @@
             appBuffer = SSLByteBufferPool.expandBuffer( appBuffer, inNetBuffer.capacity() * 2);
             appBuffer.position( 0 );
             appBuffer.limit( 0 );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + 
+                log.debug( session + 
                                     " expanded inNetBuffer:" + inNetBuffer );
-                log.log( Level.FINEST, session + 
+                log.debug( session + 
                                     " expanded appBuffer:" + appBuffer );
             }
         }
@@ -251,9 +251,9 @@
      */
     public void continueHandshake( NextFilter nextFilter ) throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " continueHandshake()" );
+            log.debug( session + " continueHandshake()" );
         }
         doHandshake( nextFilter );
     }
@@ -327,8 +327,8 @@
 
         if( appBuffer.hasRemaining() )
         {
-             if ( log.isLoggable( Level.FINEST ) ) {
-                 log.log( Level.FINEST, session + " Error: appBuffer not empty!" );
+             if ( log.isDebugEnabled() ) {
+                 log.debug( session + " Error: appBuffer not empty!" );
              }
             //still app data in buffer!?
             throw new IllegalStateException();
@@ -376,14 +376,14 @@
                 // Note: there is no way to know the exact size required, but enrypted data
                 // shouln't need to be larger than twice the source data size?
                 outNetBuffer = SSLByteBufferPool.expandBuffer( outNetBuffer, src.capacity() * 2 );
-                if ( log.isLoggable( Level.FINEST ) ) {
-                    log.log( Level.FINEST, session + " expanded outNetBuffer:" + outNetBuffer );
+                if ( log.isDebugEnabled() ) {
+                    log.debug( session + " expanded outNetBuffer:" + outNetBuffer );
                 }
             }
 
             result = sslEngine.wrap( src, outNetBuffer );
-            if ( log.isLoggable( Level.FINEST ) ) {
-                log.log( Level.FINEST, session + " Wrap res:" + result );
+            if ( log.isDebugEnabled() ) {
+                log.debug( session + " Wrap res:" + result );
             }
 
             if ( result.getStatus() == SSLEngineResult.Status.OK ) {
@@ -406,9 +406,9 @@
     public synchronized void doHandshake( NextFilter nextFilter ) throws SSLException
     {
 
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " doHandshake()" );
+            log.debug( session + " doHandshake()" );
         }
 
         while( !initialHandshakeComplete )
@@ -416,29 +416,29 @@
             if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.FINISHED )
             {
                 session.setAttribute( SSLFilter.SSL_SESSION, sslEngine.getSession() );
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
                     SSLSession sslSession = sslEngine.getSession();
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=FINISHED" );
-                    log.log( Level.FINEST, session + "  sslSession CipherSuite used " + sslSession.getCipherSuite() );
+                    log.debug( session + "  initialHandshakeStatus=FINISHED" );
+                    log.debug( session + "  sslSession CipherSuite used " + sslSession.getCipherSuite() );
                 }
                 initialHandshakeComplete = true;
                 return;
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_TASK )
             {
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=NEED_TASK" );
+                    log.debug( session + "  initialHandshakeStatus=NEED_TASK" );
                 }
                 initialHandshakeStatus = doTasks();
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_UNWRAP )
             {
                 // we need more data read
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session +
+                    log.debug( session +
                              "  initialHandshakeStatus=NEED_UNWRAP" );
                 }
                 SSLEngineResult.Status status = unwrapHandshake();
@@ -452,25 +452,25 @@
             }
             else if( initialHandshakeStatus == SSLEngineResult.HandshakeStatus.NEED_WRAP )
             {
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + "  initialHandshakeStatus=NEED_WRAP" );
+                    log.debug( session + "  initialHandshakeStatus=NEED_WRAP" );
                 }
                 // First make sure that the out buffer is completely empty. Since we
                 // cannot call wrap with data left on the buffer
                 if( outNetBuffer.hasRemaining() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + "  Still data in out buffer!" );
+                        log.debug( session + "  Still data in out buffer!" );
                     }
                     return;
                 }
                 outNetBuffer.clear();
                 SSLEngineResult result = sslEngine.wrap( hsBB, outNetBuffer );
-                if( log.isLoggable( Level.FINEST ) )
+                if( log.isDebugEnabled() )
                 {
-                    log.log( Level.FINEST, session + " Wrap res:" + result );
+                    log.debug( session + " Wrap res:" + result );
                 }
 
                 outNetBuffer.flip();
@@ -507,14 +507,14 @@
         
         try
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " write outNetBuffer: " + getOutNetBuffer() );
+                log.debug( session + " write outNetBuffer: " + getOutNetBuffer() );
             }
             org.apache.mina.common.ByteBuffer writeBuffer = copy( getOutNetBuffer() );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " session write: " + writeBuffer );
+                log.debug( session + " session write: " + writeBuffer );
             }
             //debug("outNetBuffer (after copy): {0}", sslHandler.getOutNetBuffer());
             
@@ -536,9 +536,9 @@
                 }
                 if( getOutNetBuffer().hasRemaining() )
                 {
-                    if( log.isLoggable( Level.FINEST ) )
+                    if( log.isDebugEnabled() )
                     {
-                        log.log( Level.FINEST, session + " write outNetBuffer2: " + getOutNetBuffer() );
+                        log.debug( session + " write outNetBuffer2: " + getOutNetBuffer() );
                     }
                     org.apache.mina.common.ByteBuffer writeBuffer2 = copy( getOutNetBuffer() );
                     session.write( writeBuffer2 );
@@ -557,9 +557,9 @@
     
     SSLEngineResult.Status unwrap() throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " unwrap()" );
+            log.debug( session + " unwrap()" );
         }
         // Prepare the application buffer to receive decrypted data
         appBuffer.clear();
@@ -570,15 +570,15 @@
         SSLEngineResult res;
         do
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+                log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                log.debug( session + "   appBuffer: " + appBuffer );
             }
             res = sslEngine.unwrap( inNetBuffer, appBuffer );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Unwrap res:" + res );
+                log.debug( session + " Unwrap res:" + res );
             }
         }
         while( res.getStatus() == SSLEngineResult.Status.OK );
@@ -607,9 +607,9 @@
 
     private SSLEngineResult.Status unwrapHandshake() throws SSLException
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + " unwrapHandshake()" );
+            log.debug( session + " unwrapHandshake()" );
         }
         // Prepare the application buffer to receive decrypted data
         appBuffer.clear();
@@ -620,15 +620,15 @@
         SSLEngineResult res;
         do
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+                log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                log.debug( session + "   appBuffer: " + appBuffer );
             }
             res = sslEngine.unwrap( inNetBuffer, appBuffer );
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + " Unwrap res:" + res );
+                log.debug( session + " Unwrap res:" + res );
             }
 
         }
@@ -644,14 +644,14 @@
 				&& res.getStatus() == SSLEngineResult.Status.OK
 				&& inNetBuffer.hasRemaining()) {
 			do {
-				if (log.isLoggable( Level.FINEST )) {
-					log.log( Level.FINEST, session + "  extra handshake unwrap" );
-                    log.log( Level.FINEST, session + "   inNetBuffer: " + inNetBuffer );
-                    log.log( Level.FINEST, session + "   appBuffer: " + appBuffer );
+				if (log.isDebugEnabled()) {
+					log.debug( session + "  extra handshake unwrap" );
+                    log.debug( session + "   inNetBuffer: " + inNetBuffer );
+                    log.debug( session + "   appBuffer: " + appBuffer );
 				}
 				res = sslEngine.unwrap(inNetBuffer, appBuffer);
-				if (log.isLoggable( Level.FINEST )) {
-                    log.log( Level.FINEST, session + " Unwrap res:" + res );
+				if (log.isDebugEnabled()) {
+                    log.debug( session + " Unwrap res:" + res );
 				}
 			} while (res.getStatus() == SSLEngineResult.Status.OK);
 		}
@@ -685,9 +685,9 @@
      */
     private SSLEngineResult.HandshakeStatus doTasks()
     {
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + "   doTasks()" );
+            log.debug( session + "   doTasks()" );
         }
 
         /*
@@ -697,15 +697,15 @@
         Runnable runnable;
         while( ( runnable = sslEngine.getDelegatedTask() ) != null )
         {
-            if( log.isLoggable( Level.FINEST ) )
+            if( log.isDebugEnabled() )
             {
-                log.log( Level.FINEST, session + "    doTask: " + runnable );
+                log.debug( session + "    doTask: " + runnable );
             }
             runnable.run();
         }
-        if( log.isLoggable( Level.FINEST ) )
+        if( log.isDebugEnabled() )
         {
-            log.log( Level.FINEST, session + "   doTasks(): "
+            log.debug( session + "   doTasks(): "
                     + sslEngine.getHandshakeStatus() );
         }
         return sslEngine.getHandshakeStatus();

Modified: directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java?rev=326583&r1=326582&r2=326583&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/util/SessionLog.java Wed Oct 19 08:36:22 2005
@@ -18,17 +18,15 @@
  */
 package org.apache.mina.util;
 
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
 import org.apache.mina.common.IoSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * Call {@link #getLogger(IoSession)}, {@link #log(Level,IoSession, String)}, and
- * {@link #log(Level,IoSession, String, Throwable)} to log protocol-specific messages.
+ * Provides utility methods to log protocol-specific messages.
  * <p>
  * Set {@link #PREFIX} and {@link #LOGGER} session attributes
- * to override prefix string, logger, and log level.
+ * to override prefix string and logger.
  *
  * @author The Apache Directory Project (dev@directory.apache.org)
  * @author Trustin Lee (trustin@apache.org)
@@ -48,11 +46,10 @@
     
     public static Logger getLogger( IoSession session )
     {
-        
         Logger log = (Logger) session.getAttribute( LOGGER );
         if( log == null )
         {
-            log = Logger.getLogger( getClassName( session ) );
+            log = LoggerFactory.getLogger( getClass( session ) );
             String prefix = ( String ) session.getAttribute( PREFIX );
             if( prefix == null )
             {
@@ -66,26 +63,80 @@
         return log;
     }
     
-    private static String getClassName( IoSession session )
+    private static Class getClass( IoSession session )
+    {
+        return session.getHandler().getClass();
+    }
+
+    public static void debug( IoSession session, String message )
+    {
+        Logger log = getLogger( session );
+        if( log.isDebugEnabled() )
+        {
+            log.debug( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void debug( IoSession session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isDebugEnabled() )
+        {
+            log.debug( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
+    }
+
+    public static void info( IoSession session, String message )
+    {
+        Logger log = getLogger( session );
+        if( log.isInfoEnabled() )
+        {
+            log.info( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void info( IoSession session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isInfoEnabled() )
+        {
+            log.info( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
+    }
+
+    public static void warn( IoSession session, String message )
     {
-        return session.getHandler().getClass().getName();
+        Logger log = getLogger( session );
+        if( log.isWarnEnabled() )
+        {
+            log.warn( String.valueOf( session.getAttribute( PREFIX ) ) + message );
+        }
+    }
+
+    public static void warn( IoSession session, String message, Throwable cause )
+    {
+        Logger log = getLogger( session );
+        if( log.isWarnEnabled() )
+        {
+            log.warn( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+        }
     }
 
-    public static void log( Level level, IoSession session, String message )
+    public static void error( IoSession session, String message )
     {
         Logger log = getLogger( session );
-        if( log.isLoggable( level ) )
+        if( log.isErrorEnabled() )
         {
-            log.log( level, String.valueOf( session.getAttribute( PREFIX ) ) + message );
+            log.error( String.valueOf( session.getAttribute( PREFIX ) ) + message );
         }
     }
 
-    public static void log( Level level, IoSession session, String message, Throwable cause )
+    public static void error( IoSession session, String message, Throwable cause )
     {
         Logger log = getLogger( session );
-        if( log.isLoggable( level ) )
+        if( log.isErrorEnabled() )
         {
-            log.log( level, String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
+            log.error( String.valueOf( session.getAttribute( PREFIX ) ) + message, cause );
         }
     }
 }



Mime
View raw message