james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r756424 - /james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java
Date Fri, 20 Mar 2009 11:54:53 GMT
Author: rdonkin
Date: Fri Mar 20 11:54:53 2009
New Revision: 756424

URL: http://svn.apache.org/viewvc?rev=756424&view=rev
Log:
Added name for use in contextual logging JAMES-896 and included name in TCP-DUMP file name
JAMES-897 https://issues.apache.org/jira/browse/JAMES-896

Modified:
    james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java

Modified: james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java?rev=756424&r1=756423&r2=756424&view=diff
==============================================================================
--- james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java
(original)
+++ james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AbstractJamesHandler.java
Fri Mar 20 11:54:53 2009
@@ -56,6 +56,9 @@
 
     private static final int DEFAULT_INPUT_BUFFER_SIZE = 1024;
 
+    /** Name used by default */
+    private static final String DEFAULT_NAME = "Handler-ANON";
+
     /**
      * The thread executing this handler
      */
@@ -125,13 +128,19 @@
      * Used for debug: if not null enable tcp stream dump.
      */
     private String tcplogprefix = null;
+
+    /**
+     * Names the handler.
+     * This name is used for contextual logging.
+     */
+    private String name = DEFAULT_NAME;
     
 
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
-    public void service(ServiceManager manager) throws ServiceException {
-        setDnsServer((DNSService) manager.lookup(DNSService.ROLE));
+    public void service(ServiceManager arg0) throws ServiceException {
+        setDnsServer((DNSService) arg0.lookup(DNSService.ROLE));
     }
 
     /**
@@ -451,7 +460,7 @@
     public void setStreamDumpDir(String streamDumpDir) {
         if (streamDumpDir != null) {
             String streamdumpDir=streamDumpDir;
-            this.tcplogprefix = streamdumpDir+"/TCP-DUMP."+System.currentTimeMillis()+".";
+            this.tcplogprefix = streamdumpDir+"/" + getName() + "_TCP-DUMP."+System.currentTimeMillis()+".";
             File logdir = new File(streamdumpDir);
             if (!logdir.exists()) {
                 logdir.mkdir();
@@ -465,4 +474,35 @@
         this.dnsServer = dnsServer;
     }
 
+    /**
+     * The name of this handler.
+     * Used for context sensitive logging.
+     * @return the name, not null
+     */
+    public final String getName() {
+        return name;
+    }
+
+    /**
+     * The name of this handler.
+     * Note that this name should be file-system safe.
+     * Used for context sensitive logging.
+     * @param name the name to set
+     */
+    public final void setName(final String name) {
+        if (name == null) {
+            this.name = DEFAULT_NAME;
+        } else {
+            this.name = name;
+        }
+    }
+
+    /**
+     * Use for context sensitive logging.
+     * @return the name of the handler
+     */
+    @Override
+    public String toString() {
+        return name;
+    }
 }



---------------------------------------------------------------------
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