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 ba...@apache.org on 2006/05/23 21:57:40 UTC

svn commit: r408994 - /james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java

Author: bago
Date: Tue May 23 12:57:39 2006
New Revision: 408994

URL: http://svn.apache.org/viewvc?rev=408994&view=rev
Log:
Added a default handlerChain for SMTPHandler, so that default SMTPHandler works even without handlerchain configuration (JAMES-496)

Modified:
    james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java

Modified: james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java
URL: http://svn.apache.org/viewvc/james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java?rev=408994&r1=408993&r2=408994&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java (original)
+++ james/server/trunk/src/java/org/apache/james/smtpserver/SMTPHandlerChain.java Tue May 23 12:57:39 2006
@@ -20,6 +20,7 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
@@ -27,9 +28,11 @@
 import org.apache.avalon.framework.service.Serviceable;
 
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Properties;
 
 /**
   * The SMTPHandlerChain is per service object providing access
@@ -57,6 +60,32 @@
      */
     public void configure(Configuration configuration) throws  ConfigurationException {
         addToMap(UnknownCmdHandler.UNKNOWN_COMMAND, unknownHandler);
+        if(configuration == null || configuration.getChildren("handler") == null || configuration.getChildren("handler").length == 0) {
+            configuration = new DefaultConfiguration("handlerchain");
+            Properties cmds = new Properties();
+            cmds.setProperty("AUTH",AuthCmdHandler.class.getName());
+            cmds.setProperty("DATA",DataCmdHandler.class.getName());
+            cmds.setProperty("EHLO",EhloCmdHandler.class.getName());
+            cmds.setProperty("EXPN",ExpnCmdHandler.class.getName());
+            cmds.setProperty("HELO",HeloCmdHandler.class.getName());
+            cmds.setProperty("HELP",HelpCmdHandler.class.getName());
+            cmds.setProperty("MAIL",MailCmdHandler.class.getName());
+            cmds.setProperty("NOOP",NoopCmdHandler.class.getName());
+            cmds.setProperty("QUIT",QuitCmdHandler.class.getName());
+            cmds.setProperty("RCPT" ,RcptCmdHandler.class.getName());
+            cmds.setProperty("RSET",RsetCmdHandler.class.getName());
+            cmds.setProperty("VRFY",VrfyCmdHandler.class.getName());
+            cmds.setProperty("Default SendMailHandler",SendMailHandler.class.getName());
+            Enumeration e = cmds.keys();
+            while (e.hasMoreElements()) {
+                String cmdName = (String) e.nextElement();
+                String className = cmds.getProperty(cmdName);
+                DefaultConfiguration cmdConf = new DefaultConfiguration("handler");
+                cmdConf.setAttribute("command",cmdName);
+                cmdConf.setAttribute("class",className);
+                ((DefaultConfiguration) configuration).addChild(cmdConf);
+            }
+        }
         if(configuration != null) {
             Configuration[] children = configuration.getChildren("handler");
             if ( children != null ) {



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