james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r515230 [2/4] - in /james/server/sandbox/seda-imap/src: java/org/apache/james/imapserver/ java/org/apache/james/imapserver/commands/ java/org/apache/james/imapserver/decode/ java/org/apache/james/imapserver/encode/ java/org/apache/james/ima...
Date Tue, 06 Mar 2007 17:59:12 GMT
Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/AuthenticateCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/AuthenticateCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/AuthenticateCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/AuthenticateCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/AuthenticateCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,21 +16,35 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class AuthenticateCommandParser extends AbstractImapCommandParser {
+class AuthenticateCommandParser extends AbstractImapCommandParser implements InitialisableCommandFactory {
 
     public AuthenticateCommandParser() {
-        super(new AuthenticateCommand());
     }
+    
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getAuthenticate();
+        setCommand(command);
+    }
+
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         String authType = astring( request );
         endLine( request );        
-        final AuthenticateCommandMessage result = new AuthenticateCommandMessage(command, authType, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createAuthenticateMessage(command, authType, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CapabilityCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CapabilityCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CapabilityCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CapabilityCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CapabilityCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class CapabilityCommandParser extends AbstractImapCommandParser {
+class CapabilityCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public CapabilityCommandParser() {
-        super(new CapabilityCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getCapability();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final CapabilityCommandMessage result = new CapabilityCommandMessage(command, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createCapabilityMessage(command, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CheckCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CheckCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CheckCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CheckCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CheckCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,31 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class CheckCommandParser extends AbstractImapCommandParser {
+class CheckCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public CheckCommandParser() {
-        super(new CheckCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getCheck();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final CompleteCommandMessage result = new CompleteCommandMessage(command, false, tag);
+        final ImapCommandMessage result = getMessageFactory().createCompleteMessage(command, false, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CloseCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CloseCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CloseCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CloseCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CloseCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class CloseCommandParser extends AbstractImapCommandParser {
+class CloseCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public CloseCommandParser() {
-        super(new CloseCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getClose();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final CloseCommandMessage result = new CloseCommandMessage(command, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createCloseMessage(command, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CopyCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CopyCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CopyCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CopyCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CopyCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,24 +16,35 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.IdRange;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class CopyCommandParser extends AbstractUidCommandParser {
+class CopyCommandParser extends AbstractUidCommandParser  implements InitialisableCommandFactory {
 
     public CopyCommandParser() {
-        super(new CopyCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, 
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getCopy();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, 
             ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         IdRange[] idSet = parseIdRange( request );
         String mailboxName = mailbox( request );
         endLine( request );
-        final CopyCommandMessage result = 
-            new CopyCommandMessage(command, idSet, mailboxName, useUids, tag);
+        final ImapCommandMessage result = getMessageFactory().createCopyMessage(command, idSet, mailboxName, useUids, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CreateCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CreateCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CreateCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/CreateCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/CreateCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,21 +16,35 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class CreateCommandParser extends AbstractImapCommandParser {
+class CreateCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public CreateCommandParser() {
-        super(new CreateCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getCreate();
+        setCommand(command);
+    }
+    
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         String mailboxName = mailbox( request );
         endLine( request );
-        final CreateCommandMessage result = new CreateCommandMessage(command, mailboxName, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createCreateMessage(command, mailboxName, tag);
         return result;
     }
     

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DelegatingImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DelegatingImapCommandParser.java?view=auto&rev=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DelegatingImapCommandParser.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DelegatingImapCommandParser.java Tue Mar  6 09:59:02 2007
@@ -0,0 +1,28 @@
+/****************************************************************
+ * 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.imapserver.decode;
+
+interface DelegatingImapCommandParser {
+
+    public abstract ImapCommandParserFactory getParserFactory();
+
+    public abstract void setParserFactory(
+            ImapCommandParserFactory imapCommandFactory);
+
+}

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DeleteCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DeleteCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DeleteCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/DeleteCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/DeleteCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,22 +16,34 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class DeleteCommandParser extends AbstractImapCommandParser {
+class DeleteCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public DeleteCommandParser() {
-        super(new DeleteCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getDelete();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         String mailboxName = mailbox( request );
         endLine( request );
-        final DeleteCommandMessage result = 
-            new DeleteCommandMessage( command, mailboxName, tag );
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createDeleteMessage( command, mailboxName, tag );
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExamineCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExamineCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExamineCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExamineCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExamineCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,21 +16,32 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class ExamineCommandParser extends AbstractImapCommandParser {
+class ExamineCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
     
     public ExamineCommandParser() {
-        super(new ExamineCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getExamine();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String mailboxName = mailbox( request );
         endLine( request );
-        final SelectCommandMessage result = new SelectCommandMessage(command, mailboxName, true, tag);
+        final ImapCommandMessage result = getMessageFactory().createExamineMessage(command, mailboxName, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExpungeCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExpungeCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExpungeCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ExpungeCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ExpungeCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class ExpungeCommandParser extends AbstractImapCommandParser {
+class ExpungeCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public ExpungeCommandParser() {
-        super(new ExpungeCommand());
+    }
+    
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getExpunge();
+        setCommand(command);
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final ExpungeCommandMessage result = new ExpungeCommandMessage(command, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createExpungeMessage(command, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/FetchCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/FetchCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/FetchCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/FetchCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/FetchCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,17 +16,32 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.BodyFetchElement;
+import org.apache.james.imapserver.message.FetchRequest;
+import org.apache.james.imapserver.message.IdRange;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
-class FetchCommandParser extends AbstractUidCommandParser
+class FetchCommandParser extends AbstractUidCommandParser  implements InitialisableCommandFactory
 {
     public FetchCommandParser() {
-        super(new FetchCommand());
     }
 
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getFetch();
+        setCommand(command);
+    }
+    
     public FetchRequest fetchRequest( ImapRequestLineReader request )
             throws ProtocolException
     {
@@ -69,34 +84,34 @@
             //if ( next == ' ' || next == ')'  || next == '\n' || next == '\r') {
             if (next != '[') {
                 if ( "FAST".equalsIgnoreCase( name ) ) {
-                    fetch.flags = true;
-                    fetch.internalDate = true;
-                    fetch.size = true;
+                    fetch.setFlags(true);
+                    fetch.setInternalDate(true);
+                    fetch.setSize(true);
                 } else if ("FULL".equalsIgnoreCase(name)) {
-                    fetch.flags = true;
-                    fetch.internalDate = true;
-                    fetch.size = true;
-                    fetch.envelope = true;
-                    fetch.body = true;
+                    fetch.setFlags(true);
+                    fetch.setInternalDate(true);
+                    fetch.setSize(true);
+                    fetch.setEnvelope(true);
+                    fetch.setBody(true);
                 } else if ("ALL".equalsIgnoreCase(name)) {
-                    fetch.flags = true;
-                    fetch.internalDate = true;
-                    fetch.size = true;
-                    fetch.envelope = true;
+                    fetch.setFlags(true);
+                    fetch.setInternalDate(true);
+                    fetch.setSize(true);
+                    fetch.setEnvelope(true);
                 } else if ("FLAGS".equalsIgnoreCase(name)) {
-                    fetch.flags = true;
+                    fetch.setFlags(true);
                 } else if ("RFC822.SIZE".equalsIgnoreCase(name)) {
-                    fetch.size = true;
+                    fetch.setSize(true);
                 } else if ("ENVELOPE".equalsIgnoreCase(name)) {
-                    fetch.envelope = true;
+                    fetch.setEnvelope(true);
                 } else if ("INTERNALDATE".equalsIgnoreCase(name)) {
-                    fetch.internalDate = true;
+                    fetch.setInternalDate(true);
                 } else if ("BODY".equalsIgnoreCase(name)) {
-                    fetch.body = true;
+                    fetch.setBody(true);
                 } else if ("BODYSTRUCTURE".equalsIgnoreCase(name)) {
-                    fetch.bodyStructure = true;
+                    fetch.setBodyStructure(true);
                 } else if ("UID".equalsIgnoreCase(name)) {
-                    fetch.uid = true;
+                    fetch.setUid(true);
                 } else if ("RFC822".equalsIgnoreCase(name)) {
                     fetch.add(new BodyFetchElement("RFC822", ""), false);
                 } else if ("RFC822.HEADER".equalsIgnoreCase(name)) {
@@ -156,13 +171,13 @@
         return next;
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         IdRange[] idSet = parseIdRange( request );
         FetchRequest fetch = fetchRequest( request );
         endLine( request );
         
-        final FetchCommandMessage result 
-            = new FetchCommandMessage(command, useUids, idSet, fetch, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result  = factory.createFetchMessage(command, useUids, idSet, fetch, tag);
         return result;
     }
 

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParser.java (from r514100, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java&r1=514100&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParser.java Tue Mar  6 09:59:02 2007
@@ -17,9 +17,10 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
 /**
  * <p>

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParserFactory.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParserFactory.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParserFactory.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ImapCommandParserFactory.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ImapCommandParserFactory.java Tue Mar  6 09:59:02 2007
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -25,6 +25,9 @@
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
+import org.apache.james.imapserver.ImapConstants;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
 /**
  * A factory for ImapCommand instances, provided based on the command name.
@@ -32,39 +35,42 @@
  *
  * @version $Revision: 109034 $
  */
-public class ImapCommandParserFactory
-        extends AbstractLogEnabled
+class ImapCommandParserFactory extends AbstractLogEnabled
 {
     private Map _imapCommands;
-
-    public ImapCommandParserFactory()
+    private final ImapMessageFactory messageFactory;
+    private final ImapCommandFactory commandFactory;
+    
+    public ImapCommandParserFactory(final ImapMessageFactory messageFactory, final ImapCommandFactory commandFactory)
     {
+        this.messageFactory = messageFactory;
+        this.commandFactory = commandFactory;
         _imapCommands = new HashMap();
 
         // Commands valid in any state
         // CAPABILITY, NOOP, and LOGOUT
-        _imapCommands.put( CapabilityCommand.NAME, CapabilityCommandParser.class );
-        _imapCommands.put( NoopCommand.NAME, NoopCommandParser.class );
-        _imapCommands.put( LogoutCommand.NAME, LogoutCommandParser.class );
+        _imapCommands.put( ImapConstants.CAPABILITY_COMMAND_NAME, CapabilityCommandParser.class );
+        _imapCommands.put( ImapConstants.NOOP_COMMAND_NAME, NoopCommandParser.class );
+        _imapCommands.put( ImapConstants.LOGOUT_COMMAND_NAME, LogoutCommandParser.class );
 
         // Commands valid in NON_AUTHENTICATED state.
         // AUTHENTICATE and LOGIN
-        _imapCommands.put( AuthenticateCommand.NAME, AuthenticateCommandParser.class );
-        _imapCommands.put( LoginCommand.NAME, LoginCommandParser.class );
+        _imapCommands.put( ImapConstants.AUTHENTICATE_COMMAND_NAME, AuthenticateCommandParser.class );
+        _imapCommands.put( ImapConstants.LOGIN_COMMAND_NAME, LoginCommandParser.class );
 
         // Commands valid in AUTHENTICATED or SELECTED state.
         // RFC2060: SELECT, EXAMINE, CREATE, DELETE, RENAME, SUBSCRIBE, UNSUBSCRIBE, LIST, LSUB, STATUS, and APPEND
-        _imapCommands.put( SelectCommand.NAME, SelectCommandParser.class );
-        _imapCommands.put( ExamineCommand.NAME, ExamineCommandParser.class );
-        _imapCommands.put( CreateCommand.NAME, CreateCommandParser.class );
-        _imapCommands.put( DeleteCommand.NAME, DeleteCommandParser.class );
-        _imapCommands.put( RenameCommand.NAME, RenameCommandParser.class );
-        _imapCommands.put( SubscribeCommand.NAME, SubscribeCommandParser.class );
-        _imapCommands.put( UnsubscribeCommand.NAME, UnsubscribeCommandParser.class );
-        _imapCommands.put( ListCommand.NAME, ListCommandParser.class );
-        _imapCommands.put( LsubCommand.NAME, LsubCommandParser.class );
-        _imapCommands.put( StatusCommand.NAME, StatusCommandParser.class );
-        _imapCommands.put( AppendCommand.NAME, AppendCommandParser.class );
+        _imapCommands.put( ImapConstants.SELECT_COMMAND_NAME, SelectCommandParser.class );
+        _imapCommands.put( ImapConstants.EXAMINE_COMMAND_NAME, ExamineCommandParser.class );
+        _imapCommands.put( ImapConstants.CREATE_COMMAND_NAME, CreateCommandParser.class );
+        _imapCommands.put( ImapConstants.DELETE_COMMAND_NAME, DeleteCommandParser.class );
+        _imapCommands.put( ImapConstants.RENAME_COMMAND_NAME, RenameCommandParser.class );
+        _imapCommands.put( ImapConstants.SUBSCRIBE_COMMAND_NAME, SubscribeCommandParser.class );
+        _imapCommands.put( ImapConstants.UNSUBSCRIBE_COMMAND_NAME, UnsubscribeCommandParser.class );
+        _imapCommands.put( ImapConstants.LIST_COMMAND_NAME, ListCommandParser.class );
+        _imapCommands.put( ImapConstants.LSUB_COMMAND_NAME, LsubCommandParser.class );
+        _imapCommands.put( ImapConstants.STATUS_COMMAND_NAME, StatusCommandParser.class );
+        _imapCommands.put( ImapConstants.APPEND_COMMAND_NAME, AppendCommandParser.class );
 
 //        // RFC2342 NAMESPACE
 //        _imapCommands.put( "NAMESPACE", NamespaceCommand.class );
@@ -79,14 +85,14 @@
 
         // Commands only valid in SELECTED state.
         // CHECK, CLOSE, EXPUNGE, SEARCH, FETCH, STORE, COPY, and UID
-        _imapCommands.put( CheckCommand.NAME, CheckCommandParser.class );
-        _imapCommands.put( CloseCommand.NAME, CloseCommandParser.class );
-        _imapCommands.put( ExpungeCommand.NAME, ExpungeCommandParser.class );
-        _imapCommands.put( CopyCommand.NAME, CopyCommandParser.class );
-        _imapCommands.put( SearchCommand.NAME, SearchCommandParser.class );
-        _imapCommands.put( FetchCommand.NAME, FetchCommandParser.class );
-        _imapCommands.put( StoreCommand.NAME, StoreCommandParser.class );
-        _imapCommands.put( UidCommand.NAME, UidCommandParser.class );
+        _imapCommands.put( ImapConstants.CHECK_COMMAND_NAME, CheckCommandParser.class );
+        _imapCommands.put( ImapConstants.CLOSE_COMMAND_NAME, CloseCommandParser.class );
+        _imapCommands.put( ImapConstants.EXPUNGE_COMMAND_NAME, ExpungeCommandParser.class );
+        _imapCommands.put( ImapConstants.COPY_COMMAND_NAME, CopyCommandParser.class );
+        _imapCommands.put( ImapConstants.SEARCH_COMMAND_NAME, SearchCommandParser.class );
+        _imapCommands.put( ImapConstants.FETCH_COMMAND_NAME, FetchCommandParser.class );
+        _imapCommands.put( ImapConstants.STORE_COMMAND_NAME, StoreCommandParser.class );
+        _imapCommands.put( ImapConstants.UID_COMMAND_NAME, UidCommandParser.class );
     }
 
     public ImapCommandParser getParser( String commandName )
@@ -106,21 +112,35 @@
         final Logger logger = getLogger(); 
         try {
             ImapCommandParser cmd = ( ImapCommandParser ) commandClass.newInstance();
-            setupLogger(cmd);
-            if (logger.isDebugEnabled()) {
-                logger.debug("Created command " + commandClass); 
-            }
-            // TODO: introduce interface
-            if ( cmd instanceof UidCommandParser ) {
-                ( ( UidCommandParser) cmd ).setCommandFactory( this );
-            }
+            initialiseParser(commandClass, logger, cmd);
             return cmd;
         }
         catch ( Exception e ) {
             if (logger.isWarnEnabled()) {
                 logger.warn("Create command instance failed: ", e);
             }
+            // TODO: would probably be better to manage this in protocol
+            // TODO: this runtime will produce a nasty disconnect for the client
             throw new CascadingRuntimeException( "Could not create command instance: " + commandClass.getName(), e );
+        }
+    }
+
+    protected void initialiseParser(Class commandClass, final Logger logger, ImapCommandParser cmd) {
+        setupLogger(cmd);
+        if (logger.isDebugEnabled()) {
+            logger.debug("Created command " + commandClass); 
+        }
+        
+        if ( cmd instanceof DelegatingImapCommandParser ) {
+            ( ( DelegatingImapCommandParser) cmd ).setParserFactory( this );
+        }
+        
+        if (cmd instanceof MessagingImapCommandParser) {
+            ((MessagingImapCommandParser) cmd).setMessageFactory(messageFactory);
+        }
+        
+        if (cmd instanceof InitialisableCommandFactory) {
+            ((InitialisableCommandFactory) cmd).init(commandFactory);
         }
     }
 

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/InitialisableCommandFactory.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/InitialisableCommandFactory.java?view=auto&rev=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/InitialisableCommandFactory.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/InitialisableCommandFactory.java Tue Mar  6 09:59:02 2007
@@ -0,0 +1,27 @@
+/****************************************************************
+ * 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.imapserver.decode;
+
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+
+interface InitialisableCommandFactory {
+
+    public abstract void init(ImapCommandFactory factory);
+
+}

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ListCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ListCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ListCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/ListCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/ListCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,28 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
-class ListCommandParser extends AbstractUidCommandParser
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
+class ListCommandParser extends AbstractUidCommandParser  implements InitialisableCommandFactory
 {
     public ListCommandParser() {
-        super(new ListCommand());
     }
 
-    ListCommandParser(ImapCommand command) {
-        super(command);
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getList();
+        setCommand(command);
     }
-
+    
     /**
      * Reads an argument of type "list_mailbox" from the request, which is
      * the second argument for a LIST or LSUB command. Valid values are a "string"
@@ -60,17 +68,18 @@
         }
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         String referenceName = mailbox( request );
         String mailboxPattern = listMailbox( request );
         endLine( request );
-        final ListCommandMessage result = createMessage(command, referenceName, mailboxPattern, tag);
+        final ImapCommandMessage result = createMessage(command, referenceName, mailboxPattern, tag);
         return result;
     }
     
-    protected ListCommandMessage createMessage(ImapCommand command, final String referenceName, final String mailboxPattern, final String tag) 
+    protected ImapCommandMessage createMessage(ImapCommand command, final String referenceName, final String mailboxPattern, final String tag) 
     {
-        final ListCommandMessage result = new ListCommandMessage(command, referenceName, mailboxPattern, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createListMessage(command, referenceName, mailboxPattern, tag);
         return result;
     }
 }

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LoginCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LoginCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LoginCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LoginCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LoginCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,22 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class LoginCommandParser extends AbstractImapCommandParser {
+class LoginCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public LoginCommandParser() {
-        super(new LoginCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getLogin();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String userid = astring( request );
         final String password = astring( request );
         endLine( request );
-        final LoginCommandMessage result = new LoginCommandMessage(command, userid, password, tag);
+        final ImapCommandMessage result = getMessageFactory().createLoginMessage(command, userid, password, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LogoutCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LogoutCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LogoutCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LogoutCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LogoutCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,31 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class LogoutCommandParser extends AbstractImapCommandParser {
+class LogoutCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public LogoutCommandParser() {
-        super(new LogoutCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getLogout();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final LogoutCommandMessage result = new LogoutCommandMessage(command, tag);
+        final ImapCommandMessage result = getMessageFactory().createLogoutMessage(command, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LsubCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LsubCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LsubCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/LsubCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/LsubCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,16 +16,28 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
-class LsubCommandParser extends ListCommandParser {
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+
+class LsubCommandParser extends ListCommandParser  implements InitialisableCommandFactory {
 
     public LsubCommandParser() {
-        super(new LsubCommand());
     }
 
-    protected ListCommandMessage createMessage(ImapCommand command, String referenceName, String mailboxPattern, String tag) {
-        final LsubListCommandMessage result = new LsubListCommandMessage(command, referenceName, mailboxPattern, tag);
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getLsub();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage createMessage(ImapCommand command, String referenceName, String mailboxPattern, String tag) {
+        final ImapCommandMessage result = getMessageFactory().createLsubMessage(command, referenceName, mailboxPattern, tag);
         return result;
     }
 }

Added: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/MessagingImapCommandParser.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/MessagingImapCommandParser.java?view=auto&rev=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/MessagingImapCommandParser.java (added)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/MessagingImapCommandParser.java Tue Mar  6 09:59:02 2007
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.imapserver.decode;
+
+import org.apache.james.imapserver.message.ImapMessageFactory;
+
+interface MessagingImapCommandParser {
+
+    public abstract ImapMessageFactory getMessageFactory();
+
+    public abstract void setMessageFactory(ImapMessageFactory messageFactory);
+
+}

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/NoopCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/NoopCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/NoopCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/NoopCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/NoopCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,20 +16,31 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class NoopCommandParser extends AbstractImapCommandParser {
+class NoopCommandParser extends AbstractImapCommandParser  implements InitialisableCommandFactory {
 
     public NoopCommandParser() {
-        super(new NoopCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getNoop();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         endLine( request );
-        final CompleteCommandMessage result = new CompleteCommandMessage(command, false, tag);
+        final ImapCommandMessage result = getMessageFactory().createCompleteMessage(command, false, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/RenameCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/RenameCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/RenameCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/RenameCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/RenameCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,22 +16,34 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class RenameCommandParser extends AbstractImapCommandParser {
+class RenameCommandParser extends AbstractImapCommandParser implements InitialisableCommandFactory {
 
     public RenameCommandParser() {
-        super(new RenameCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getRename();
+        setCommand(command);
+    }
+    
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String existingName = mailbox( request );
         final String newName = mailbox( request );
         endLine( request );
-        final RenameCommandMessage result = new RenameCommandMessage(command, existingName, newName, tag);
+        final ImapCommandMessage result = getMessageFactory().createRenameMessage(command, existingName, newName, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SearchCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SearchCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SearchCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SearchCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SearchCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,21 +16,32 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import javax.mail.Message;
 import javax.mail.search.SearchTerm;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class SearchCommandParser extends AbstractUidCommandParser
+class SearchCommandParser extends AbstractUidCommandParser implements InitialisableCommandFactory
 {
     public SearchCommandParser() {
-        super(new SearchCommand());
     }
 
     /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getSearch();
+        setCommand(command);
+    }
+    
+    /**
      * Parses the request argument into a valid search term.
      * Not yet implemented - all searches will return everything for now.
      * TODO implement search
@@ -58,12 +69,11 @@
         };
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         // Parse the search term from the request
         final SearchTerm searchTerm = searchTerm( request );
         endLine( request );
-        final SearchImapCommand result 
-            = new SearchImapCommand(command, searchTerm, useUids, tag);
+        final ImapCommandMessage result = getMessageFactory().createSearchImapMessage(command, searchTerm, useUids, tag);
         return result;
     }
 

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SelectCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SelectCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SelectCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SelectCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SelectCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,21 +16,32 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class SelectCommandParser extends AbstractImapCommandParser {
+class SelectCommandParser extends AbstractImapCommandParser implements InitialisableCommandFactory {
     
     public SelectCommandParser() {
-        super(new SelectCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getSelect();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String mailboxName = mailbox( request );
         endLine( request );
-        final SelectCommandMessage result = new SelectCommandMessage(command, mailboxName, false, tag);
+        final ImapCommandMessage result = getMessageFactory().createSelectMessage(command, mailboxName, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StandardImapDecoder.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StandardImapDecoder.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StandardImapDecoder.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StandardImapDecoder.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StandardImapDecoder.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StandardImapDecoder.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StandardImapDecoder.java Tue Mar  6 09:59:02 2007
@@ -16,19 +16,26 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/ 
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.james.imapserver.ImapDecoder;
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.commands.StandardImapCommandFactory;
+import org.apache.james.imapserver.message.BaseImapMessageFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
 
 public class StandardImapDecoder extends AbstractLogEnabled implements ImapDecoder {
 
     private static final String INVALID_COMMAND = "Invalid command.";
     // TODO: inject dependency
-    private final ImapCommandParserFactory imapCommands = new ImapCommandParserFactory();
+    private final ImapMessageFactory messageFactory = new BaseImapMessageFactory();
+    private final ImapCommandFactory commandFactory = new StandardImapCommandFactory();
+    private final ImapCommandParserFactory imapCommands = new ImapCommandParserFactory(messageFactory, commandFactory);
     private static final String REQUEST_SYNTAX = "Protocol Error: Was expecting <tag SPACE command [arguments]>";
 
     /**
@@ -49,7 +56,7 @@
         }
         catch ( ProtocolException e ) {
             logger.debug("error parsing request", e);
-            message = new BadResponseMessage( REQUEST_SYNTAX );
+            message = messageFactory.createBadRequestMessage( REQUEST_SYNTAX );
         }
         return message;
     }
@@ -65,7 +72,7 @@
         }
         catch ( ProtocolException e ) {
             logger.debug("Error during initial request parsing", e);            
-            message = new ErrorResponseMessage(REQUEST_SYNTAX , tag);
+            message = messageFactory.createErrorMessage(REQUEST_SYNTAX , tag);
         }
         return message;
     }
@@ -79,7 +86,7 @@
         final ImapCommandParser command = imapCommands.getParser( commandName );
         if ( command == null ) {
             logger.info("Missing command implementation.");
-            message = new ErrorResponseMessage(INVALID_COMMAND, tag);
+            message = messageFactory.createErrorMessage(INVALID_COMMAND, tag);
         } else {
             message = command.parse( request, tag );
         }

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StatusCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StatusCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StatusCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StatusCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StatusCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,17 +16,31 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
+import org.apache.james.imapserver.ImapConstants;
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.ImapMessageFactory;
+import org.apache.james.imapserver.message.StatusDataItems;
 
-class StatusCommandParser extends AbstractImapCommandParser
+class StatusCommandParser extends AbstractImapCommandParser implements InitialisableCommandFactory
 {
     public StatusCommandParser() {
-        super(new StatusCommand());
     }
 
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getStatus();
+        setCommand(command);
+    }
+    
     StatusDataItems statusDataItems( ImapRequestLineReader request )
             throws ProtocolException
     {
@@ -51,32 +65,32 @@
     private void addItem( String nextWord, StatusDataItems items )
             throws ProtocolException
     {
-        if ( nextWord.equals( StatusCommand.MESSAGES ) ) {
-            items.messages = true;
+        if ( nextWord.equals( ImapConstants.STATUS_MESSAGES ) ) {
+            items.setMessages(true);
         }
-        else if ( nextWord.equals( StatusCommand.RECENT ) ) {
-            items.recent = true;
+        else if ( nextWord.equals( ImapConstants.STATUS_RECENT ) ) {
+            items.setRecent(true);
         }
-        else if ( nextWord.equals( StatusCommand.UIDNEXT ) ) {
-            items.uidNext = true;
+        else if ( nextWord.equals( ImapConstants.STATUS_UIDNEXT ) ) {
+            items.setUidNext(true);
         }
-        else if ( nextWord.equals( StatusCommand.UIDVALIDITY ) ) {
-            items.uidValidity = true;
+        else if ( nextWord.equals( ImapConstants.STATUS_UIDVALIDITY ) ) {
+            items.setUidValidity(true);
         }
-        else if ( nextWord.equals( StatusCommand.UNSEEN ) ) {
-            items.unseen = true;
+        else if ( nextWord.equals( ImapConstants.STATUS_UNSEEN ) ) {
+            items.setUnseen(true);
         }
         else {
             throw new ProtocolException( "Unknown status item: '" + nextWord + "'" );
         }
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String mailboxName = mailbox( request );
         final StatusDataItems statusDataItems = statusDataItems( request );
         endLine( request );
-        final StatusCommandMessage result = 
-            new StatusCommandMessage(command, mailboxName, statusDataItems, tag);
+        final ImapMessageFactory factory = getMessageFactory();
+        final ImapCommandMessage result = factory.createStatusMessage(command, mailboxName, statusDataItems, tag);
         return result;
     }
 }

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StoreCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StoreCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StoreCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/StoreCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/StoreCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,19 +16,32 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import javax.mail.Flags;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.IdRange;
+import org.apache.james.imapserver.message.ImapCommandMessage;
+import org.apache.james.imapserver.message.StoreDirective;
 
-class StoreCommandParser extends AbstractUidCommandParser
+class StoreCommandParser extends AbstractUidCommandParser implements InitialisableCommandFactory
 {
     public StoreCommandParser() {
-        super(new StoreCommand());
     }
 
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getStore();
+        setCommand(command);
+    }
+    
     StoreDirective storeDirective( ImapRequestLineReader request ) throws ProtocolException
     {
         int sign = 0;
@@ -60,13 +73,12 @@
         return new StoreDirective( sign, silent );
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag, boolean useUids) throws ProtocolException {
         final IdRange[] idSet = parseIdRange( request );
         final StoreDirective directive = storeDirective( request );
         final Flags flags = flagList( request );
         endLine( request );
-        final StoreCommandMessage result = 
-            new StoreCommandMessage(command, idSet, directive, flags, useUids, tag);
+        final ImapCommandMessage result = getMessageFactory().createStoreMessage(command, idSet, directive, flags, useUids, tag);
         return result;
     }
 }

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SubscribeCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SubscribeCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SubscribeCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/SubscribeCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/SubscribeCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,23 +16,33 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class SubscribeCommandParser extends AbstractImapCommandParser {
+class SubscribeCommandParser extends AbstractImapCommandParser implements InitialisableCommandFactory {
 
     public SubscribeCommandParser() {
-        super(new SubscribeCommand());
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
+    {
+        final ImapCommand command = factory.getSubscribe();
+        setCommand(command);
+    }
+    
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         final String mailboxName = mailbox( request );
         endLine( request );
         
-        final SubscribeCommandMessage result = 
-            new SubscribeCommandMessage(command, mailboxName, tag);
+        final ImapCommandMessage result = getMessageFactory().createSubscribeMessage(command, mailboxName, tag);
         return result;
     }
     

Copied: james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/UidCommandParser.java (from r514102, james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidCommandParser.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/UidCommandParser.java?view=diff&rev=515230&p1=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidCommandParser.java&r1=514102&p2=james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/UidCommandParser.java&r2=515230
==============================================================================
--- james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/commands/UidCommandParser.java (original)
+++ james/server/sandbox/seda-imap/src/java/org/apache/james/imapserver/decode/UidCommandParser.java Tue Mar  6 09:59:02 2007
@@ -16,38 +16,59 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.imapserver.commands;
+package org.apache.james.imapserver.decode;
 
 import org.apache.james.imapserver.ImapRequestLineReader;
 import org.apache.james.imapserver.ProtocolException;
+import org.apache.james.imapserver.commands.ImapCommand;
+import org.apache.james.imapserver.commands.ImapCommandFactory;
+import org.apache.james.imapserver.message.ImapCommandMessage;
 
-class UidCommandParser extends AbstractImapCommandParser {
-    private ImapCommandParserFactory commandFactory;
+class UidCommandParser extends AbstractImapCommandParser implements DelegatingImapCommandParser,InitialisableCommandFactory {
+    private ImapCommandParserFactory parserFactory;
 
     public UidCommandParser() {
-        super(new UidCommand());
     }
     
-    public void setCommandFactory( ImapCommandParserFactory imapCommandFactory )
+    /**
+     * @see org.apache.james.imapserver.decode.InitialisableCommandFactory#init(org.apache.james.imapserver.commands.ImapCommandFactory)
+     */
+    public void init(ImapCommandFactory factory)
     {
-        this.commandFactory = imapCommandFactory;
+        final ImapCommand command = factory.getUid();
+        setCommand(command);
+    }
+    
+    /**
+     * @see org.apache.james.imapserver.decode.DelegatingImapCommandParser#getParserFactory()
+     */
+    public ImapCommandParserFactory getParserFactory() {
+        return parserFactory;
+    }
+
+    /**
+     * @see org.apache.james.imapserver.decode.DelegatingImapCommandParser#setParserFactory(org.apache.james.imapserver.decode.ImapCommandParserFactory)
+     */
+    public void setParserFactory( ImapCommandParserFactory imapCommandFactory )
+    {
+        this.parserFactory = imapCommandFactory;
     }
 
-    protected AbstractImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
+    protected ImapCommandMessage decode(ImapCommand command, ImapRequestLineReader request, String tag) throws ProtocolException {
         // TODO: check the logic against the specification:
         // TODO: suspect that it is now bust
         // TODO: the command written may be wrong
         // TODO: this will be easier to fix a little later
         // TODO: also not sure whether the old implementation shares this flaw 
         String commandName = atom( request );
-        ImapCommandParser helperCommand = commandFactory.getParser( commandName );
+        ImapCommandParser helperCommand = parserFactory.getParser( commandName );
         // TODO: replace abstract class with interface
         if ( helperCommand == null ||
              ! (helperCommand instanceof AbstractUidCommandParser ) ) {
             throw new ProtocolException("Invalid UID command: '" + commandName + "'" );
         }
         final AbstractUidCommandParser uidEnabled = (AbstractUidCommandParser) helperCommand;
-        final AbstractImapCommandMessage result = uidEnabled.decode( request, tag, true );
+        final ImapCommandMessage result = uidEnabled.decode( request, tag, true );
         return result;
     }
     



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


Mime
View raw message