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/10/12 16:10:16 UTC

svn commit: r824345 [2/3] - in /james/server/trunk: ./ avalon-socket-library/ avalon-socket-library/src/main/java/org/apache/james/socket/ avalon-socket-library/src/main/java/org/apache/james/socket/configuration/ imapserver-function/src/main/java/org/...

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShutdownCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShutdownCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShutdownCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/ShutdownCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -45,7 +45,7 @@
         return null;
     }
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnknownCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnknownCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnknownCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnknownCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -52,7 +52,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetAliasCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetAliasCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetAliasCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetAliasCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -95,7 +95,7 @@
     }
     
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetForwardingCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetForwardingCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetForwardingCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UnsetForwardingCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -95,7 +95,7 @@
 
 
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UserCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UserCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UserCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/UserCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -67,7 +67,7 @@
 
 
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/VerifyCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/VerifyCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/VerifyCmdHandler.java (original)
+++ james/server/trunk/remotemanager-function/src/main/java/org/apache/james/remotemanager/core/VerifyCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -90,7 +90,7 @@
 
 
     /**
-     * @see org.apache.james.socket.CommonCommandHandler#getImplCommands()
+     * @see org.apache.james.socket.shared.CommonCommandHandler#getImplCommands()
      */
     public Collection<String> getImplCommands() {
         List<String> commands = new ArrayList<String>();

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/CommandHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/CommandHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/CommandHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/CommandHandler.java Mon Oct 12 14:10:11 2009
@@ -21,7 +21,7 @@
 
 package org.apache.james.smtpserver;
 
-import org.apache.james.socket.CommonCommandHandler;
+import org.apache.james.socket.shared.CommonCommandHandler;
 
 
 /**

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=824345&r1=824344&r2=824345&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 Mon Oct 12 14:10:11 2009
@@ -28,9 +28,9 @@
 import java.util.Map;
 import java.util.Random;
 
-import org.apache.james.socket.AbstractProtocolHandler;
-import org.apache.james.socket.CRLFDelimitedByteBuffer;
-import org.apache.james.socket.ProtocolContext;
+import org.apache.james.socket.shared.AbstractProtocolHandler;
+import org.apache.james.socket.shared.CRLFDelimitedByteBuffer;
+import org.apache.james.socket.shared.ProtocolContext;
 
 /**
  * Provides SMTP functionality by carrying out the server side of the SMTP
@@ -91,7 +91,7 @@
 	}
     
 	/**
-	 * @see org.apache.james.socket.AbstractProtocolHandler#handleProtocolInternal(org.apache.james.socket.ProtocolContext)
+	 * @see org.apache.james.socket.shared.AbstractProtocolHandler#handleProtocolInternal(org.apache.james.socket.shared.ProtocolContext)
 	 */
     public void handleProtocolInternal(ProtocolContext context) throws IOException {
         this.context = context;
@@ -378,7 +378,7 @@
 
  
 	/**
-	 * @see org.apache.james.socket.TLSSupportedSession#isStartTLSSupported()
+	 * @see org.apache.james.socket.shared.TLSSupportedSession#isStartTLSSupported()
 	 */
 	public boolean isStartTLSSupported() {
 		return getConfigurationData().isStartTLSSupported();

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=824345&r1=824344&r2=824345&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 Mon Oct 12 14:10:11 2009
@@ -28,8 +28,8 @@
 import org.apache.james.smtpserver.core.CoreCmdHandlerLoader;
 import org.apache.james.smtpserver.core.CoreMessageHookLoader;
 import org.apache.james.smtpserver.core.DataLineMessageHookHandler;
-import org.apache.james.socket.AbstractHandlerChain;
-import org.apache.james.socket.LogEnabled;
+import org.apache.james.socket.shared.AbstractHandlerChain;
+import org.apache.james.socket.shared.LogEnabled;
 
 /**
   * The SMTPHandlerChain is per service object providing access
@@ -77,14 +77,14 @@
     }
 
     /**
-     * @see org.apache.james.socket.AbstractHandlerChain#getLog()
+     * @see org.apache.james.socket.shared.AbstractHandlerChain#getLog()
      */
     protected Log getLog() {
         return log;
     }
 
     /**
-     * @see org.apache.james.socket.AbstractHandlerChain#getCoreCmdHandlerLoader()
+     * @see org.apache.james.socket.shared.AbstractHandlerChain#getCoreCmdHandlerLoader()
      */
     protected Class<?> getCoreCmdHandlerLoader() {
         return CoreCmdHandlerLoader.class;

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=824345&r1=824344&r2=824345&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 Mon Oct 12 14:10:11 2009
@@ -33,8 +33,8 @@
 import org.apache.james.api.kernel.LoaderService;
 import org.apache.james.services.MailServer;
 import org.apache.james.socket.AbstractProtocolServer;
-import org.apache.james.socket.ProtocolHandler;
 import org.apache.james.socket.configuration.JamesConfiguration;
+import org.apache.james.socket.shared.ProtocolHandler;
 import org.apache.mailet.MailetContext;
 
 /**

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/SMTPSession.java Mon Oct 12 14:10:11 2009
@@ -21,7 +21,7 @@
 
 import java.util.Map;
 
-import org.apache.james.socket.TLSSupportedSession;
+import org.apache.james.socket.shared.TLSSupportedSession;
 
 /**
  * All the handlers access this interface to communicate with

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/AbstractHookableCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -29,7 +29,7 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookResultHook;
 import org.apache.james.smtpserver.hook.HookReturnCode;
-import org.apache.james.socket.ExtensibleHandler;
+import org.apache.james.socket.shared.ExtensibleHandler;
 
 /**
  * Abstract class which Handle hooks.
@@ -178,7 +178,7 @@
     
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     public List<Class<?>> getMarkerInterfaces() {
         List<Class<?>> classes = new ArrayList<Class<?>>(2);
@@ -195,7 +195,7 @@
     protected abstract Class<Hook> getHookInterface();
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#wireExtensions(java.lang.Class,
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class,
      *      java.util.List)
      */
     public void wireExtensions(Class interfaceName, List extension) {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreCmdHandlerLoader.java Mon Oct 12 14:10:11 2009
@@ -25,7 +25,7 @@
 import org.apache.james.smtpserver.core.esmtp.EhloCmdHandler;
 import org.apache.james.smtpserver.core.esmtp.MailSizeEsmtpExtension;
 import org.apache.james.smtpserver.core.esmtp.StartTlsCmdHandler;
-import org.apache.james.socket.HandlersPackage;
+import org.apache.james.socket.shared.HandlersPackage;
 
 import java.util.LinkedList;
 import java.util.List;
@@ -82,7 +82,7 @@
         commands.add(DATALINEMESSAGEHOOKHANDLER);
         commands.add(STARTTLSHANDLER);    }
     /**
-     * @see org.apache.james.socket.HandlersPackage#getHandlers()
+     * @see org.apache.james.socket.shared.HandlersPackage#getHandlers()
      */
     public List<String> getHandlers() {
         return commands;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreMessageHookLoader.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreMessageHookLoader.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreMessageHookLoader.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/CoreMessageHookLoader.java Mon Oct 12 14:10:11 2009
@@ -21,7 +21,7 @@
 
 package org.apache.james.smtpserver.core;
 
-import org.apache.james.socket.HandlersPackage;
+import org.apache.james.socket.shared.HandlersPackage;
 
 import java.util.LinkedList;
 import java.util.List;
@@ -35,7 +35,7 @@
     private final String SENDMAILHANDLER = SendMailHandler.class.getName();
     
     /**
-     * @see org.apache.james.socket.HandlersPackage#getHandlers()
+     * @see org.apache.james.socket.shared.HandlersPackage#getHandlers()
      */
     public List<String> getHandlers() {
         List<String> commands = new LinkedList<String>();

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -40,8 +40,8 @@
 import org.apache.james.smtpserver.SMTPResponse;
 import org.apache.james.smtpserver.SMTPRetCode;
 import org.apache.james.smtpserver.SMTPSession;
-import org.apache.james.socket.ExtensibleHandler;
 import org.apache.james.socket.WiringException;
+import org.apache.james.socket.shared.ExtensibleHandler;
 import org.apache.mailet.base.RFC2822Headers;
 import org.apache.mailet.base.RFC822DateFormat;
 
@@ -303,7 +303,7 @@
 
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     public List getMarkerInterfaces() {
         List classes = new LinkedList();
@@ -313,7 +313,7 @@
 
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
      */
     public void wireExtensions(Class interfaceName, List extension) throws WiringException {
         if (DataLineFilter.class.equals(interfaceName)) {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/DataLineMessageHookHandler.java Mon Oct 12 14:10:11 2009
@@ -44,9 +44,9 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookResultHook;
 import org.apache.james.smtpserver.hook.MessageHook;
-import org.apache.james.socket.ExtensibleHandler;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.WiringException;
+import org.apache.james.socket.shared.ExtensibleHandler;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 
@@ -185,7 +185,7 @@
     }
     
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
      */
     public void wireExtensions(Class interfaceName, List extension) throws WiringException {
         if (MessageHook.class.equals(interfaceName)) {
@@ -203,7 +203,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     public List<Class<?>> getMarkerInterfaces() {
         List<Class<?>> classes = new LinkedList<Class<?>>();

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/SMTPCommandDispatcherLineHandler.java Mon Oct 12 14:10:11 2009
@@ -32,8 +32,8 @@
 import org.apache.james.smtpserver.SMTPResponse;
 import org.apache.james.smtpserver.SMTPRetCode;
 import org.apache.james.smtpserver.SMTPSession;
-import org.apache.james.socket.AbstractCommandDispatcher;
-import org.apache.james.socket.LogEnabled;
+import org.apache.james.socket.shared.AbstractCommandDispatcher;
+import org.apache.james.socket.shared.LogEnabled;
 
 
 public class SMTPCommandDispatcherLineHandler extends AbstractCommandDispatcher<CommandHandler> implements LogEnabled, LineHandler {
@@ -108,7 +108,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     @SuppressWarnings("unchecked")
     public List getMarkerInterfaces() {
@@ -118,7 +118,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.AbstractCommandDispatcher#getLog()
+     * @see org.apache.james.socket.shared.AbstractCommandDispatcher#getLog()
      */
     protected Log getLog() {
         return serviceLog;
@@ -126,28 +126,28 @@
 
 
     /**
-     * @see org.apache.james.socket.AbstractCommandDispatcher#getUnknownCommandHandlerIdentifier()
+     * @see org.apache.james.socket.shared.AbstractCommandDispatcher#getUnknownCommandHandlerIdentifier()
      */
     protected String getUnknownCommandHandlerIdentifier() {
         return UnknownCmdHandler.UNKNOWN_COMMAND;
     }
 
     /**
-     * @see org.apache.james.socket.AbstractCommandDispatcher#getMandatoryCommands()
+     * @see org.apache.james.socket.shared.AbstractCommandDispatcher#getMandatoryCommands()
      */
     protected List<String> getMandatoryCommands() {
         return Arrays.asList(mandatoryCommands);
     }
 
     /**
-     * @see org.apache.james.socket.AbstractCommandDispatcher#getUnknownCommandHandler()
+     * @see org.apache.james.socket.shared.AbstractCommandDispatcher#getUnknownCommandHandler()
      */
     protected CommandHandler getUnknownCommandHandler() {
         return unknownHandler;
     }
 
     /**
-     * @see org.apache.james.socket.LogEnabled#setLog(org.apache.commons.logging.Log)
+     * @see org.apache.james.socket.shared.LogEnabled#setLog(org.apache.commons.logging.Log)
      */
     public void setLog(Log log) {
         this.serviceLog = log;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/AuthCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -40,8 +40,8 @@
 import org.apache.james.smtpserver.hook.HookResultHook;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.MailParametersHook;
-import org.apache.james.socket.ExtensibleHandler;
 import org.apache.james.socket.WiringException;
+import org.apache.james.socket.shared.ExtensibleHandler;
 import org.apache.james.util.codec.Base64;
 
 
@@ -420,7 +420,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     public List<Class<?>> getMarkerInterfaces() {
         List<Class<?>> classes = new ArrayList<Class<?>>(1);
@@ -430,7 +430,7 @@
 
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
      */
     public void wireExtensions(Class interfaceName, List extension) throws WiringException {
         if (AuthHook.class.equals(interfaceName)) {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/esmtp/EhloCmdHandler.java Mon Oct 12 14:10:11 2009
@@ -87,7 +87,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#getMarkerInterfaces()
+     * @see org.apache.james.socket.shared.ExtensibleHandler#getMarkerInterfaces()
      */
     public List<Class<?>> getMarkerInterfaces() {
         List<Class<?>> classes = super.getMarkerInterfaces();
@@ -96,7 +96,7 @@
     }
 
     /**
-     * @see org.apache.james.socket.ExtensibleHandler#wireExtensions(java.lang.Class,
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class,
      *      java.util.List)
      */
     public void wireExtensions(Class interfaceName, List extension) {

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/DNSRBLHandler.java Mon Oct 12 14:10:11 2009
@@ -39,8 +39,8 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.RcptHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.MailAddress;
 
 /**

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=824345&r1=824344&r2=824345&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 Mon Oct 12 14:10:11 2009
@@ -50,8 +50,8 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.RcptHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.james.util.TimeConverter;
 import org.apache.james.util.sql.JDBCUtil;
 import org.apache.james.util.sql.SqlResources;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/SPFHandler.java Mon Oct 12 14:10:11 2009
@@ -38,8 +38,8 @@
 import org.apache.james.smtpserver.hook.MailHook;
 import org.apache.james.smtpserver.hook.MessageHook;
 import org.apache.james.smtpserver.hook.RcptHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.Mail;
 import org.apache.mailet.MailAddress;
 

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/URIRBLHandler.java Mon Oct 12 14:10:11 2009
@@ -46,8 +46,8 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.MessageHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.Mail;
 
 /**

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptHandler.java Mon Oct 12 14:10:11 2009
@@ -43,8 +43,8 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.RcptHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.MailAddress;
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Pattern;

Modified: james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java?rev=824345&r1=824344&r2=824345&view=diff
==============================================================================
--- james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java (original)
+++ james/server/trunk/smtpserver-function/src/main/java/org/apache/james/smtpserver/core/filter/fastfail/ValidRcptMX.java Mon Oct 12 14:10:11 2009
@@ -40,8 +40,8 @@
 import org.apache.james.smtpserver.hook.HookResult;
 import org.apache.james.smtpserver.hook.HookReturnCode;
 import org.apache.james.smtpserver.hook.RcptHook;
-import org.apache.james.socket.LogEnabled;
 import org.apache.james.socket.configuration.Configurable;
+import org.apache.james.socket.shared.LogEnabled;
 import org.apache.mailet.MailAddress;
 
 /**

Added: james/server/trunk/socket-shared-library/LICENSE.txt
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/LICENSE.txt?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/LICENSE.txt (added)
+++ james/server/trunk/socket-shared-library/LICENSE.txt Mon Oct 12 14:10:11 2009
@@ -0,0 +1,218 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+   
+   
+   
+
+   THIS PRODUCT ALSO INCLUDES THIRD PARTY SOFTWARE REDISTRIBUTED UNDER THE
+   FOLLOWING LICENSES:
+   
+   
+   
+   Concurrent, Public Domain (see lib/concurrent.LICENSE)
+   
+   BouncyCastle, MIT License (see lib/BouncyCastle.LICENSE)
+     http://www.bouncycastle.org/licence.html
+     
+   DnsJava, BSD License (see lib/dnsjava.LICENSE)
+     http://www.dnsjava.org/README 
+     
+   JavaBeans Activation Framework, CDDL License
+     http://glassfish.dev.java.net/public/CDDLv1.0.html
+     
+   JavaMail, CDDL License
+     http://glassfish.dev.java.net/public/CDDLv1.0.html
+   
+   QDox, ASL 1.1 License (see tools/lib/qdox.LICENSE)
+     http://qdox.codehaus.org/license.html
+     
+   MX4J, ASL 1.1 License (see phoenix-bin/bin/lib/mx4j.LICENSE)
+   
+   Spice, ASL 1.1 License (see phoenix-bin/bin/lib/spice.LICENSE)
+     http://spice.codehaus.org/license.html
+     
+   Wrapper, MIT License (see phoenix-bin/bin/Wrapper.LICENSE)
+     http://wrapper.tanukisoftware.org/doc/english/license.html
+     
+   ISO-Relax, MIT License (see phoenix-bin/tools/lib/isorelax.LICENSE)
+
+   MSV, BSD License (see phoenix-bin/tools/lib/msv.LICENSE)
+
+   RelaxNG-Datatype, BSD License (see phoenix-bin/tools/lib/relaxngDatatype.LICENSE)
+   
+   XSDLib, BSD License (see phoenix-bin/tools/lib/xsdlib.LICENSE)
+   
\ No newline at end of file

Added: james/server/trunk/socket-shared-library/NOTICE.txt
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/NOTICE.txt?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/NOTICE.txt (added)
+++ james/server/trunk/socket-shared-library/NOTICE.txt Mon Oct 12 14:10:11 2009
@@ -0,0 +1,11 @@
+
+=========================================================================
+==      NOTICE file for use with the Apache License, Version 2.0,      ==
+=========================================================================
+
+Apache JAMES 
+Copyright 2007 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+            
\ No newline at end of file

Added: james/server/trunk/socket-shared-library/build.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/build.xml?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/build.xml (added)
+++ james/server/trunk/socket-shared-library/build.xml Mon Oct 12 14:10:11 2009
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.    
+-->
+<project default="main" name="socket-shared-library">
+  <description>Builds socket-shared-library module. This is an library module.</description>
+  <property name="name.module" value="socket-shared-library" />
+  <import file="../build-tools/library-build.xml" optional="no" />
+</project>
\ No newline at end of file

Added: james/server/trunk/socket-shared-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/pom.xml?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/pom.xml (added)
+++ james/server/trunk/socket-shared-library/pom.xml Mon Oct 12 14:10:11 2009
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.    
+-->
+<project>
+  <parent>
+    <artifactId>james-server</artifactId>
+    <groupId>org.apache.james</groupId>
+    <version>3.0-M1</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.james</groupId>
+  <artifactId>james-server-socket-shared-library</artifactId>
+  <name>Apache JAMES Server Shared Socket Library</name>
+  <dependencies>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-configuration</groupId>
+      <artifactId>commons-configuration</artifactId>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/Configurable.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/Configurable.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/Configurable.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/Configurable.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,40 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james.socket.configuration;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+
+/**
+ * Classes which needs to access the configuration should implement this
+ *
+ */
+public interface Configurable {
+
+	/**
+	 * Configure
+	 * 
+	 * @param config
+	 * @throws ConfigurationException
+	 */
+	public void configure(Configuration config) throws ConfigurationException;
+	
+}

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/JamesConfiguration.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/JamesConfiguration.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/JamesConfiguration.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/configuration/JamesConfiguration.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james.socket.configuration;
+
+import java.io.ByteArrayInputStream;
+import org.apache.avalon.framework.configuration.ConfigurationUtil;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.configuration.tree.xpath.XPathExpressionEngine;
+
+/**
+ * Bridges commons configuration to Avalon.
+ */
+public class JamesConfiguration extends XMLConfiguration {
+
+	private static final long serialVersionUID = 6920719067623856243L;
+
+	public JamesConfiguration(org.apache.avalon.framework.configuration.Configuration avalonConfig) throws ConfigurationException {
+		String config = ConfigurationUtil.toString(avalonConfig);
+		load(new ByteArrayInputStream(config.getBytes()));
+		
+		setExpressionEngine(new XPathExpressionEngine());
+	}
+}

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractCommandDispatcher.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractCommandDispatcher.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractCommandDispatcher.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractCommandDispatcher.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,164 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.socket.shared;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.socket.WiringException;
+
+/**
+ * Abstract base class which CommandDispatcher implementations should extend
+ *
+ * @param <CommandHandler>
+ */
+public abstract class AbstractCommandDispatcher<CommandHandler extends CommonCommandHandler> implements ExtensibleHandler {
+    /**
+     * The list of available command handlers
+     */
+    private HashMap<String, List<CommandHandler>> commandHandlerMap = new HashMap<String, List<CommandHandler>>();
+
+    /**
+     * Add it to map (key as command name, value is an array list of CommandHandlers)
+     *
+     * @param commandName the command name which will be key
+     * @param cmdHandler The CommandHandler object
+     */
+    protected void addToMap(String commandName, CommandHandler cmdHandler) {
+        List<CommandHandler> handlers = commandHandlerMap.get(commandName);
+        if(handlers == null) {
+            handlers = new ArrayList<CommandHandler>();
+            commandHandlerMap.put(commandName, handlers);
+        }
+        handlers.add(cmdHandler);
+    }
+
+
+    /**
+     * Returns all the configured CommandHandlers for the specified command
+     *
+     * @param command the command name which will be key
+     * @param session not null
+     * @return List of CommandHandlers
+     */
+    protected List<CommandHandler> getCommandHandlers(String command, LogEnabledSession session) {
+        if (command == null) {
+            return null;
+        }
+        if (session.getLogger().isDebugEnabled()) {
+            session.getLogger().debug("Lookup command handler for command: " + command);
+        }
+        List<CommandHandler> handlers =  commandHandlerMap.get(command);
+        if(handlers == null) {
+            handlers = commandHandlerMap.get(getUnknownCommandHandlerIdentifier());
+        }
+
+        return handlers;
+    }
+
+    /**
+     * @throws WiringException 
+     * @see org.apache.james.socket.shared.ExtensibleHandler#wireExtensions(java.lang.Class, java.util.List)
+     */
+    @SuppressWarnings("unchecked")
+    public void wireExtensions(Class interfaceName, List extension) throws WiringException {
+        this.commandHandlerMap = new HashMap<String, List<CommandHandler>>();
+
+        for (Iterator it = extension.iterator(); it.hasNext(); ) {
+            CommandHandler handler = (CommandHandler) it.next();
+            Collection implCmds = handler.getImplCommands();
+    
+            for (Iterator i = implCmds.iterator(); i.hasNext(); ) {
+                String commandName = ((String) i.next()).trim().toUpperCase(Locale.US);
+                /*
+                if (getLog().isInfoEnabled()) {
+                    getLog().info(
+                            "Added Commandhandler: " + handler.getClass() + " for command "+commandName);
+                }
+                */
+                addToMap(commandName, (CommandHandler) handler);
+            }
+        }
+
+        addToMap(getUnknownCommandHandlerIdentifier(), getUnknownCommandHandler());
+
+        if (commandHandlerMap.size() < 2) {
+            if (getLog().isErrorEnabled()) {
+                getLog().error("No commandhandlers configured");
+            }
+            throw new WiringException("No commandhandlers configured");
+        } else {
+            boolean found = true;
+            List<String> mandatoryCommands = getMandatoryCommands();
+            for (int i = 0; i < mandatoryCommands.size(); i++) {
+                if (!commandHandlerMap.containsKey(mandatoryCommands.get(i))) {
+                    if (getLog().isErrorEnabled()) {
+                        getLog().error(
+                                "No commandhandlers configured for the command:"
+                                        + mandatoryCommands.get(i));
+                    }
+                    found = false;
+                    break;
+                }
+            }
+
+            if (!found) {
+                throw new WiringException(
+                        "No commandhandlers configured for mandatory commands");
+            }
+
+
+        }
+
+    }
+    
+    /**
+     * Return the Log object to use
+     * 
+     * @return log
+     */
+    protected abstract Log getLog();
+    
+    /**
+     * Return a List which holds all mandatory commands
+     * 
+     * @return mCommands
+     */
+    protected abstract List<String> getMandatoryCommands();
+    
+    /**
+     * Return the identifier to lookup the UnknownCmdHandler in the handler map
+     * 
+     * @return identifier
+     */
+    protected abstract String getUnknownCommandHandlerIdentifier();
+    
+    /**
+     * Return the CommandHandler which should use to handle unknown commands
+     * 
+     * @return unknownCmdHandler
+     */
+    protected abstract CommandHandler getUnknownCommandHandler();
+}

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractHandlerChain.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractHandlerChain.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractHandlerChain.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractHandlerChain.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,234 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james.socket.shared;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.apache.commons.configuration.BaseConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.api.kernel.LoaderService;
+import org.apache.james.socket.WiringException;
+
+/**
+ * Abstract class which HandlerChains should extend
+ * 
+ *
+ */
+public abstract class AbstractHandlerChain {
+    protected final List<Object> handlers = new LinkedList<Object>();
+    
+    /** Loads instances */
+    private LoaderService loader;
+
+    protected HierarchicalConfiguration commonsConf;
+    
+    
+    /**
+     * Gets the current instance loader.
+     * @return the loader
+     */
+    public final LoaderService getLoader() {
+        return loader;
+    }
+
+    /**
+     * Sets the loader to be used for instances.
+     * @param loader the loader to set, not null
+     */
+    @Resource(name="org.apache.james.LoaderService")
+    public final void setLoader(LoaderService loader) {
+        this.loader = loader;
+    }
+    
+    
+    /**
+     * ExtensibleHandler wiring
+     * 
+     * @throws WiringException 
+     */
+    protected void wireExtensibleHandlers() throws WiringException {
+        for (Iterator<?> h = handlers.iterator(); h.hasNext(); ) {
+            Object handler = h.next();
+            if (handler instanceof ExtensibleHandler) {
+                final ExtensibleHandler extensibleHandler = (ExtensibleHandler) handler;
+                final List<Class<?>> markerInterfaces = extensibleHandler.getMarkerInterfaces();
+                for (int i= 0;i < markerInterfaces.size(); i++) {
+                    final Class<?> markerInterface = markerInterfaces.get(i);
+                    final List<?> extensions = getHandlers(markerInterface);
+                    extensibleHandler.wireExtensions(markerInterface,extensions);
+                }
+            }
+        }
+    }
+
+    
+    /**
+     * Load and add the classes to the handler map
+     * 
+     * @param classLoader The classLoader to use
+     * @param className The class name 
+     * @param config The configuration 
+     * @throws ConfigurationException Get thrown on error
+     */
+    protected void loadClass(ClassLoader classLoader, String className,
+            org.apache.commons.configuration.Configuration config) throws Exception {
+        final Class<?> handlerClass = classLoader.loadClass(className);
+        Object handler = loader.load(handlerClass);
+
+        // enable logging
+        if (handler instanceof LogEnabled) {
+            ((LogEnabled) handler).setLog(getLog());
+        }
+
+        // configure the handler
+        if (handler instanceof org.apache.james.socket.configuration.Configurable) {
+            org.apache.james.socket.configuration.Configurable configurableHandler = (org.apache.james.socket.configuration.Configurable) handler;
+            configurableHandler.configure(config);
+        }
+
+        // if it is a commands handler add it to the map with key as command
+        // name
+        if (handler instanceof HandlersPackage) {
+            List<String> c = ((HandlersPackage) handler).getHandlers();
+
+            for (Iterator<String> i = c.iterator(); i.hasNext(); ) {
+                String cName = i.next();
+
+                Configuration cmdConf = addHandler(cName);
+
+                loadClass(classLoader, cName, cmdConf);
+            }
+
+        }
+
+        if (getLog().isInfoEnabled()) {
+            getLog().info("Added Handler: " + className);
+        }
+
+        // fill the big handler table
+        handlers.add(handler);
+    }
+    
+    /**
+     * Return a DefaultConfiguration build on the given command name and classname
+     * 
+     * @param cmdName The command name
+     * @param className The class name
+     * @return DefaultConfiguration
+     * @throws ConfigurationException 
+     */
+    protected Configuration addHandler(String className) throws ConfigurationException {
+        Configuration hConf = new BaseConfiguration();
+        hConf.addProperty("handler/@class", className);
+        return hConf;
+    }
+    
+    
+    /**
+     * Returns a list of handler of the requested type.
+     * @param <T>
+     * 
+     * @param type the type of handler we're interested in
+     * @return a List of handlers
+     */
+    @SuppressWarnings("unchecked")
+    public <T> LinkedList<T> getHandlers(Class<T> type) {
+        LinkedList<T> result = new LinkedList<T>();
+        for (Iterator<?> i = handlers.iterator(); i.hasNext(); ) {
+            Object handler = i.next();
+            if (type.isInstance(handler)) {
+                result.add((T)handler);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * loads the various handlers from the configuration
+     * 
+     * @param configuration
+     *            configuration under handlerchain node
+     */
+    @SuppressWarnings("unchecked")
+    protected void loadHandlers() throws Exception {
+        if (commonsConf != null) {
+            List<org.apache.commons.configuration.Configuration> children = commonsConf.configurationsAt("handler");
+            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+            // load the configured handlers
+            if (children != null && children.isEmpty() == false) {
+
+                String coreCmdName = getCoreCmdHandlerLoader().getName();
+                // load the core handlers
+                loadClass(classLoader, coreCmdName,
+                        addHandler(coreCmdName));
+                
+                for (int i = 0; i < children.size(); i++) {
+                    org.apache.commons.configuration.Configuration hConf = children.get(i);
+                    String className = hConf.getString("@class");
+
+                    if (className != null) {
+                        // ignore base handlers.
+                        if (!className.equals(coreCmdName)) {
+
+                            // load the handler
+                            loadClass(classLoader, className, hConf);
+                        }
+                    }
+                }
+               
+            }
+        }
+    }
+    
+    /**
+     * Configure the chain
+     * 
+     * @param commonsConf
+     * @throws Exception
+     */
+    public void configure(HierarchicalConfiguration commonsConf) throws Exception {
+        this.commonsConf =  commonsConf;
+        loadHandlers();    
+        wireExtensibleHandlers();
+    }
+    
+    /**
+     * Return the Class which lists all core commands
+     * 
+     * @return class
+     */
+    protected abstract Class<?> getCoreCmdHandlerLoader();
+    
+    /**
+     * Return the Log to use
+     * 
+     * @return log
+     */
+    protected abstract Log getLog();
+}

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractProtocolHandler.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractProtocolHandler.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractProtocolHandler.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/AbstractProtocolHandler.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,120 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+
+package org.apache.james.socket.shared;
+
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+
+/**
+ * Abstract base class for ProtocolHandler
+ * 
+ *
+ */
+public abstract class AbstractProtocolHandler implements ProtocolHandler, TLSSupportedSession{
+
+    private ProtocolContext context;
+    private String user;
+
+    /**
+     * @see org.apache.james.socket.shared.ProtocolHandler#resetHandler()
+     */
+    public void resetHandler() {
+        user = null;
+        resetHandlerInternal();
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.ProtocolHandler#handleProtocol(org.apache.james.socket.shared.ProtocolContext)
+     */
+    public void handleProtocol(ProtocolContext context) throws IOException {
+        this.context = context;
+        handleProtocolInternal(context);
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#getRemoteHost()
+     */
+    public String getRemoteHost() {
+        return context.getRemoteHost();
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#getRemoteIPAddress()
+     */
+    public String getRemoteIPAddress() {
+        return context.getRemoteIP();
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#getUser()
+     */
+    public String getUser() {
+        return user;
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#isTLSStarted()
+     */
+    public boolean isTLSStarted() {
+        return context.isSecure();
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#setUser(java.lang.String)
+     */
+    public void setUser(String user) {
+        this.user = user;
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#startTLS()
+     */
+    public void startTLS() throws IOException {
+        context.secure();
+    }
+    
+    
+    /**
+     * @see org.apache.james.socket.shared.TLSSupportedSession#getLogger()
+     */
+    public Log getLogger() {
+        return context.getLogger();
+    }
+
+    /**
+     * @see org.apache.james.socket.shared.ProtocolHandler#fatalFailure(java.lang.RuntimeException, org.apache.james.socket.shared.ProtocolContext)
+     */
+    public void fatalFailure(RuntimeException e, ProtocolContext context) {
+    }
+    
+    /**
+     * @see #handleProtocol(ProtocolContext)
+     */
+    protected abstract void handleProtocolInternal(ProtocolContext context) throws IOException;
+    
+    /**
+     * @see #resetHandler()
+     */
+    protected abstract void resetHandlerInternal();
+
+}

Added: james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFDelimitedByteBuffer.java
URL: http://svn.apache.org/viewvc/james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFDelimitedByteBuffer.java?rev=824345&view=auto
==============================================================================
--- james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFDelimitedByteBuffer.java (added)
+++ james/server/trunk/socket-shared-library/src/java/main/org/apache/james/socket/shared/CRLFDelimitedByteBuffer.java Mon Oct 12 14:10:11 2009
@@ -0,0 +1,336 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+
+package org.apache.james.socket.shared;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * <p>A simple, synchronized, queue of CRLF-delimited lines.</p>
+ * <p>
+ * NOTA BENE: as bytes arrive, they are buffered internally up to a
+ * configured maximum.  The maximum is intended to reflect a line length
+ * limiter, but there is a potential corner case that should be
+ * understood.  If the working buffer is almost full, and a new packet
+ * arrives with enough data to overflow the buffer, the code will
+ * consider that an error and discard the entire working buffer, even
+ * though the beginning of the new packet might have terminated the
+ * currently accumulating line.  And the reported position of the
+ * overflow is based upon the buffer position before scanning for lines,
+ * not an actualy line length (perhaps we need not even report the
+ * position).  Since the purpose for this maximum is to prevent memory
+ * flooding attacks, this does not appear to be a particularly critical
+ * corner case.  We simply need to make sure that the working buffer is
+ * at least twice the size of the maximum desired line length.
+ * </p><p>
+ * After buffering the incoming data, it is scanned for CRLF.  As each
+ * line is found, it is moved to an ArrayList of Line objects.  When all
+ * data has been scanned, any remaining bytes are shifted within the
+ * working buffer to prepare for the next packet.
+ * </p><p>
+ * The code enforces CRLF pairing (RFC 2821 #2.7.1).  The Line object,
+ * which is for internal use only, can hold the bytes for each line or
+ * record an exception (line termination or line length) associated
+ * with processing the data that would otherwise have.  The exceptions
+ * are rethrown during the read operation, rather than during the write
+ * operation, so that the order of responses perserves the order of
+ * input.
+ * </p><p>
+ * This code does not handle dot stuffing.  Dot Stuffing, Message size
+ * limiting, and buffering of the message in a file are all expected to
+ * be performed by the I/O handler associated with the DATA accumulation
+ * state.
+ * </p>
+ */
+
+public class CRLFDelimitedByteBuffer {
+    @SuppressWarnings("serial")
+    static public class TerminationException extends java.io.IOException {
+        private int where;
+        public TerminationException(int where) {
+            super();
+            this.where = where;
+        }
+
+        public TerminationException(String s, int where) {
+            super(s);
+            this.where = where;
+        }
+
+        public int position() {
+            return where;
+        }
+    }
+
+    @SuppressWarnings("serial")
+    static public class LineLengthExceededException extends java.io.IOException {
+        public LineLengthExceededException(String s) {
+            super(s);
+        }
+    }
+
+    private InputStream input;
+
+    public CRLFDelimitedByteBuffer(InputStream input) {
+        this(input, 2048);
+    }
+
+    public CRLFDelimitedByteBuffer(InputStream input, int maxLineLength) {
+        this.input = input; 
+        lines = new java.util.ArrayList<Line>();
+        workLine = new byte[maxLineLength];
+    }
+
+    synchronized public boolean isEmpty() {
+        return lines.isEmpty();
+    }
+
+    synchronized public byte[] read() throws IOException, LineLengthExceededException, TerminationException {
+        byte[] buffer = new byte[1000];
+        int length;
+        while (lines.isEmpty() && isEmpty() && (length = input.read(buffer))!=-1) {
+            write(buffer, length);
+        }
+        return lines.isEmpty() ? null : ((Line) lines.remove(0)).getBytes();
+    }
+
+    synchronized public String readString() throws IOException, LineLengthExceededException, TerminationException {
+        byte[] buffer = new byte[1000];
+        int length;
+        while (lines.isEmpty() && isEmpty() && (length = input.read(buffer))!=-1) {
+            write(buffer, length);
+        }
+        if (lines.isEmpty()) return null;
+        else {
+            byte[] bytes = ((Line) lines.remove(0)).getBytes();
+            try {
+                return new String(bytes, "US-ASCII");
+            } catch (java.io.UnsupportedEncodingException uee) {
+                return new String(bytes);
+            }
+        }
+    }
+
+    synchronized public void write(byte[] data, int length) {
+        if (canFit(length)) {
+            System.arraycopy(data, 0, workLine, writeindex, length);
+            writeindex += length;
+            buildlines();
+        }
+    }
+
+    synchronized public void write(byte data) {
+        if (canFit(1)) {
+            workLine[writeindex++] = data;
+            buildlines();
+        }
+    }
+
+    synchronized public void write(String s) {
+        write(s.getBytes(), s.getBytes().length);
+    }
+
+    private boolean canFit(int length) {
+        if (writeindex + length > workLine.length) {
+            reset();
+            lines.add(new Line(new LineLengthExceededException("Exceeded maximum line length")));
+            return false;
+        } else return true;
+    }
+
+    static private class Line {
+        java.io.IOException e;
+        byte[] bytes;
+
+        @SuppressWarnings("unused")
+        public Line(byte[] data) {
+            bytes = data;
+        }
+
+        @SuppressWarnings("unused")
+        public Line(String data) {
+            bytes = data.getBytes();
+        }
+
+        public Line(java.io.IOException e) {
+            this.e = e;
+        }
+
+        public Line(byte[] data, int offset, int length) {
+            bytes = new byte[length];
+            System.arraycopy(data, offset, bytes, 0, length);
+        }
+
+        public byte[] getBytes() throws LineLengthExceededException, TerminationException {
+            if (e != null) {
+                if (e instanceof LineLengthExceededException) throw (LineLengthExceededException) e;
+                else  throw (TerminationException) e;
+            }
+            return bytes;
+        }
+    }
+
+    private java.util.ArrayList<Line> lines;
+
+    private byte[] workLine;
+    private int writeindex = 0;
+    private int readindex = 0;
+    private int scanindex = 0;      // current index for matching within the working buffer
+
+    private void reset() {
+        writeindex = 0;
+        readindex = 0;
+        scanindex = 0;
+    }
+
+    private void shift() {
+        System.arraycopy(workLine, readindex, workLine, 0, writeindex - readindex);
+        writeindex -= readindex;
+        scanindex -= readindex;
+        readindex = 0;
+    }
+
+    private void buildlines() {
+        for (; scanindex < writeindex; scanindex++) {
+            if (workLine[scanindex] == '\n') {
+                final int pos = scanindex;
+                reset();
+                lines.add(new Line(new TerminationException("\"bare\" LF in data stream.", pos)));
+                break;
+            } else if (workLine[scanindex] == '\r') {
+                if (scanindex+1 == writeindex) break;
+                else if (workLine[++scanindex] == '\n') {
+                    lines.add(new Line(workLine, readindex, scanindex - readindex + 1));
+                    readindex = scanindex + 1;
+                } else {
+                    final int pos = scanindex - 1;
+                    reset();
+                    lines.add(new Line(new TerminationException("\"bare\" CR in data stream.", pos)));
+                    break;
+                }
+            }
+        }
+
+        if (readindex != 0) shift();
+    }
+
+    /*** THE CODE BELOW IS PURELY FOR TESTING ***/
+    /*
+    synchronized private void status() {
+        System.out.println("\n--------------------------------------------------\n");
+        if (lines.isEmpty()) System.out.println("Lines: None");
+        else {
+            System.out.println("Lines:");
+            java.util.Iterator i = lines.iterator();
+            while (i.hasNext()) {
+                Line line = (Line) i.next();
+                try {
+                    System.out.println("\tData[" + line.getBytes().length + "]: " + new String(line.getBytes(), 0, line.getBytes().length, "US-ASCII"));
+                } catch (java.io.UnsupportedEncodingException uee) {
+                } catch (TerminationException te) {
+                    System.out.println("\tSyntax error at character position " + te.position() + ". CR and LF must be CRLF paired.  See RFC 2821 #2.7.1.");
+                } catch (LineLengthExceededException llee) {
+                    System.out.println("\tLine length exceeded. See RFC 2821 #4.5.3.1.");
+                }
+            }
+        }
+
+        System.out.println("Buffer Status:");
+        System.out.println("\tworkline length: " + workLine.length);
+        System.out.println("\tnext read index: " + readindex);
+        System.out.println("\tnext scan index: " + scanindex);
+        System.out.println("\tnext write index: " + writeindex);
+
+        try {
+            System.out.println("\tOld data: " + new String(workLine, 0, readindex, "US-ASCII"));
+            System.out.println("\tData: " + new String(workLine, readindex, writeindex - readindex, "US-ASCII"));
+        } catch (java.io.UnsupportedEncodingException uee) {
+            System.err.println(uee);
+        }
+        System.out.println("\n--------------------------------------------------\n");
+    }
+
+
+    static public void main(String[] args) throws java.io.IOException {
+        CRLFDelimitedByteBuffer dbb = new CRLFDelimitedByteBuffer();
+        dbb.status();
+        dbb.write("Hello"); dbb.status();
+        dbb.write(" "); dbb.status();
+        dbb.write("World."); dbb.status();
+        dbb.write("\r"); dbb.status();
+        dbb.write("\n"); dbb.status();
+        dbb.write("\r\n"); dbb.status();
+        dbb.write("\n"); dbb.status();
+        dbb.write("\r\r"); dbb.status();
+        dbb.write("stuff\n"); dbb.status();
+        dbb.write("morestuff\r\r"); dbb.status();
+        for (int i = 0; i < 2500; i++) dbb.write("\0"); dbb.status();
+
+        while (!dbb.isEmpty()) {
+            try {
+                byte[] line = dbb.read();
+                System.out.println("Read line[" + line.length + "]: " + new String(line, 0, line.length, "US-ASCII"));
+            } catch (java.io.UnsupportedEncodingException uee) {
+            } catch (TerminationException te) {
+                System.out.println("Syntax error at character position " + te.position() + ". CR and LF must be CRLF paired.  See RFC 2821 #2.7.1.");
+            } catch (LineLengthExceededException llee) {
+                System.out.println("Line length exceeded. See RFC 2821 #4.5.3.1.");
+            }
+        }
+        dbb.status();
+
+        dbb.write("This is a test.\015\012.... Three dots\015\012.\015\012");
+        dbb.status();
+
+        while (!dbb.isEmpty()) {
+            try {
+                byte[] line = dbb.read();
+                System.out.println("Read line[" + line.length + "]: " + new String(line, 0, line.length, "US-ASCII"));
+            } catch (java.io.UnsupportedEncodingException uee) {
+            } catch (TerminationException te) {
+                System.out.println("Syntax error at character position " + te.position() + ". CR and LF must be CRLF paired.  See RFC 2821 #2.7.1.");
+            } catch (LineLengthExceededException llee) {
+                System.out.println("Line length exceeded. See RFC 2821 #4.5.3.1.");
+            }
+        }
+        dbb.status();
+
+        dbb.write("This is"); dbb.status();
+        dbb.write(" a tes"); dbb.status();
+        dbb.write("t.\015"); dbb.status();
+        dbb.write("\012..."); dbb.status();
+        dbb.write(". Three dot"); dbb.status();
+        dbb.write("s\015\012.\015\012"); dbb.status();
+
+        while (!dbb.isEmpty()) {
+            try {
+                String text = dbb.readString();
+                System.out.println ("read : " + text);
+                dbb.status();
+            } catch (TerminationException te) {
+                System.out.println("Syntax error at character position " + te.position() + ". CR and LF must be CRLF paired.  See RFC 2821 #2.7.1.");
+            } catch (LineLengthExceededException llee) {
+                System.out.println("Line length exceeded. See RFC 2821 #4.5.3.1.");
+            }
+        }
+    }
+    */
+}



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