You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/09/23 14:44:57 UTC

svn commit: r818081 - in /james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver: SMTPHandlerChain.java SMTPServer.java core/filter/fastfail/GreylistHandler.java

Author: norman
Date: Wed Sep 23 12:44:57 2009
New Revision: 818081

URL: http://svn.apache.org/viewvc?rev=818081&view=rev
Log:
Remove need of using ContainerUtil on the handlers

Modified:
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPServer.java
    james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java?rev=818081&r1=818080&r2=818081&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPHandlerChain.java Wed Sep 23 12:44:57 2009
@@ -27,7 +27,6 @@
 
 import javax.annotation.Resource;
 
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.commons.configuration.BaseConfiguration;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
@@ -106,12 +105,12 @@
         }
     }
 
-	public void configure(JamesConfiguration commonsConf) {
+	public void configure(JamesConfiguration commonsConf) throws Exception {
 		this.commonsConf =  commonsConf;
-	}
-
-	public String getConfigurationKeyXQuery() {
-		return "smtphandlerchain";
+		
+        loadHandlers();
+        
+        wireExtensibleHandlers();
 	}
 	
     /**
@@ -154,26 +153,7 @@
             }
         }
     }
-    
-    /**
-     * Initializes chain.
-     */
-    public void initialize() throws Exception {
-//        SMTPCommandDispatcherLineHandler commandDispatcherLineHandler = new SMTPCommandDispatcherLineHandler();
-//        commandDispatcherLineHandler.enableLogging(getLogger());
-//        handlers.add(commandDispatcherLineHandler);
-        
-        loadHandlers();
-        
-        Iterator<Object> h = handlers.iterator();
-    
-        while(h.hasNext()) {
-            Object next = h.next();
-            ContainerUtil.initialize(next);
-        }
-        wireExtensibleHandlers();
 
-    }
 
     /**
      * Load and add the classes to the handler map

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=818081&r1=818080&r2=818081&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 Wed Sep 23 12:44:57 2009
@@ -242,7 +242,6 @@
         
         //read from the XML configuration and create and configure each of the handlers
         handlerChain.configure(new JamesConfiguration(handlerConfiguration.getChild("handlerchain")));
-        handlerChain.initialize();
     }
 
     @Override

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java?rev=818081&r1=818080&r2=818081&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/GreylistHandler.java Wed Sep 23 12:44:57 2009
@@ -36,7 +36,6 @@
 
 import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
 import org.apache.avalon.excalibur.datasource.DataSourceComponent;
-import org.apache.avalon.framework.activity.Initializable;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
@@ -61,7 +60,7 @@
 /**
  * GreylistHandler which can be used to activate Greylisting
  */
-public class GreylistHandler implements LogEnabled, RcptHook, Initializable, Configurable {
+public class GreylistHandler implements LogEnabled, RcptHook, Configurable {
 
     /** This log is the fall back shared by all instances */
     private static final Log FALLBACK_LOG = LogFactory.getLog(GreylistHandler.class);
@@ -250,11 +249,7 @@
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize() throws Exception {
-        setDataSource(initDataSource(repositoryPath));
-        initSqlQueries(datasource.getConnection(), sqlFileUrl);
-        
-        // create table if not exist
-        createTable(datasource.getConnection(), "greyListTableName", "createGreyListTable");
+       
     }
     
     /**
@@ -265,6 +260,17 @@
      */
     public void setRepositoryPath(String repositoryPath) {
         this.repositoryPath = repositoryPath;
+        
+        try {
+			setDataSource(initDataSource(repositoryPath));
+			initSqlQueries(datasource.getConnection(), sqlFileUrl);
+		        
+		    // create table if not exist
+		    createTable(datasource.getConnection(), "greyListTableName", "createGreyListTable");
+		} catch (Exception e) {
+			throw new RuntimeException("Unable to init datasource",e);
+		}
+      
     }
 
     /**



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