james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r811549 - in /james/server/trunk/smtpserver-function/src: main/java/org/apache/james/smtpserver/SMTPHandler.java main/java/org/apache/james/smtpserver/SMTPServer.java test/java/org/apache/james/smtpserver/TarpitHandlerTest.java
Date Fri, 04 Sep 2009 21:01:13 GMT
Author: rdonkin
Date: Fri Sep  4 21:01:13 2009
New Revision: 811549

URL: http://svn.apache.org/viewvc?rev=811549&view=rev
Log:
Inject handler chain

Modified:
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
    james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/TarpitHandlerTest.java

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java?rev=811549&r1=811548&r2=811549&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandler.java
Fri Sep  4 21:01:13 2009
@@ -75,7 +75,7 @@
     /**
      * Connect Handlers
      */
-    private LinkedList<ConnectHandler> connectHandlers;
+    private final LinkedList<ConnectHandler> connectHandlers;
 
 	private SMTPHandlerConfigurationData theConfigData;
 
@@ -83,14 +83,18 @@
 
 	private boolean authSupported;
 
-	private SMTPHandlerChain handlerChain;
+	private final SMTPHandlerChain handlerChain;
 
 	private String authenticatedUser;
 
 	private String smtpID;
 
+	public SMTPHandler(SMTPHandlerChain handlerChain) {
+        this.handlerChain = handlerChain;
+        connectHandlers = handlerChain.getHandlers(ConnectHandler.class);
+        lineHandlers = handlerChain.getHandlers(LineHandler.class);
+	}
 	
-
     /**
      * Set the configuration data for the handler
      *
@@ -230,18 +234,6 @@
         sessionEnded = false;
     }
 
-   /**
-     * Sets the SMTPHandlerChain
-     *
-     * @param handlerChain SMTPHandler object
-     */
-    public void setHandlerChain(SMTPHandlerChain handlerChain) {
-        this.handlerChain = handlerChain;
-        connectHandlers = handlerChain.getHandlers(ConnectHandler.class);
-        lineHandlers = handlerChain.getHandlers(LineHandler.class);
-    }
-
-
     /**
      * @see org.apache.james.smtpserver.SMTPSession#getRemoteHost()
      */

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java?rev=811549&r1=811548&r2=811549&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
(original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
Fri Sep  4 21:01:13 2009
@@ -397,9 +397,7 @@
 
     @Override
     public ProtocolHandler newProtocolHandlerInstance() {
-        SMTPHandler theHandler = new SMTPHandler();
-        //pass the handler chain to every SMTPhandler
-        theHandler.setHandlerChain(handlerChain);
+        final SMTPHandler theHandler = new SMTPHandler(handlerChain);
         return theHandler;
     }
 

Modified: james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/TarpitHandlerTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/TarpitHandlerTest.java?rev=811549&r1=811548&r2=811549&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/TarpitHandlerTest.java
(original)
+++ james/server/trunk/smtpserver-function/src/test/java/org/apache/james/smtpserver/TarpitHandlerTest.java
Fri Sep  4 21:01:13 2009
@@ -40,7 +40,7 @@
             
             public void sleep(long ms) {
                 // use the real code 
-                (new SMTPHandler()).sleep(ms);
+                (new SMTPHandler(new SMTPHandlerChain())).sleep(ms);
             }
 
         };



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