james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r759883 - in /james/server/trunk: avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java
Date Mon, 30 Mar 2009 08:51:02 GMT
Author: rdonkin
Date: Mon Mar 30 08:51:01 2009
New Revision: 759883

URL: http://svn.apache.org/viewvc?rev=759883&view=rev
Log:
Use context sensitive logging for session IMAP-75 https://issues.apache.org/jira/browse/IMAP-75

Modified:
    james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java
    james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java

Modified: james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java?rev=759883&r1=759882&r2=759883&view=diff
==============================================================================
--- james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java
(original)
+++ james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/ProtocolHandlerHelper.java
Mon Mar 30 08:51:01 2009
@@ -106,4 +106,10 @@
      */
     public Socket getSocket();
 
+    /**
+     * The name of this handler.
+     * Used for context sensitive logging.
+     * @return the name, not null
+     */
+    public String getName();
 }
\ No newline at end of file

Modified: james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java?rev=759883&r1=759882&r2=759883&view=diff
==============================================================================
--- james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java
(original)
+++ james/server/trunk/imapserver-function/src/main/java/org/apache/james/imapserver/ImapHandler.java
Mon Mar 30 08:51:01 2009
@@ -26,6 +26,7 @@
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.imap.api.process.ImapSession;
+import org.apache.james.imap.main.ContextualLog;
 import org.apache.james.imap.main.ImapRequestHandler;
 import org.apache.james.imap.main.ImapSessionImpl;
 import org.apache.james.imap.main.OutputStreamImapResponseWriter;
@@ -33,6 +34,7 @@
 import org.apache.james.imap.encode.base.ImapResponseComposerImpl;
 import org.apache.james.socket.ProtocolHandler;
 import org.apache.james.socket.ProtocolHandlerHelper;
+import org.apache.commons.logging.impl.AvalonLogger;
 
 /**
  * Handles IMAP connections.
@@ -91,10 +93,8 @@
                  
             response.hello(hello);
 
-            session = new ImapSessionImpl();
+            setUpSession();
             
-            ContainerUtil.enableLogging(session, getLogger());
-
             helper.getWatchdog().start();
             while ( handleRequest() ) {
                 helper.getWatchdog().reset();
@@ -109,6 +109,15 @@
                             + ") closed.");
     }
 
+    /**
+     * Sets up a session.
+     */
+    private void setUpSession() {
+        final ImapSessionImpl session = new ImapSessionImpl();
+        session.setLog(new ContextualLog(helper.getName(), new AvalonLogger(getLogger())));
+        this.session = session;
+    }
+
     private boolean handleRequest() {
         final boolean result = requestHandler.handleRequest( helper.getInputStream(), helper.getOutputStream(),
session );
         return result;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message