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 er...@apache.org on 2010/09/21 17:36:00 UTC

svn commit: r999467 - in /james/server/trunk: ./ common-util/ core-api/ core-api/src/main/java/org/apache/james/services/ core-api/src/test/java/org/ core-function/ core-function/src/main/java/org/apache/james/mailrepository/ core-function/src/main/res...

Author: eric
Date: Tue Sep 21 15:35:59 2010
New Revision: 999467

URL: http://svn.apache.org/viewvc?rev=999467&view=rev
Log:
Move 2.3 mail persistence classes to mail/spool projects (JAMES-1048)

Added:
    james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
    james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageWrapper.java
    james/server/trunk/core-library/src/test/java/org/apache/james/services/FakeLoader.java
      - copied unchanged from r999288, james/server/trunk/core-api/src/test/java/org/apache/james/services/FakeLoader.java
    james/server/trunk/core-library/src/test/java/org/resources/
      - copied from r999288, james/server/trunk/core-library/src/test/resources/
    james/server/trunk/management/src/test/java/org/apache/james/management/impl/
    james/server/trunk/management/src/test/java/org/apache/james/management/impl/SpoolManagementTest.java
      - copied unchanged from r999288, james/server/trunk/core-function/src/test/java/org/apache/james/management/impl/SpoolManagementTest.java
    james/server/trunk/spool-api/   (with props)
    james/server/trunk/spool-api/pom.xml
    james/server/trunk/spool-api/src/
    james/server/trunk/spool-api/src/main/
    james/server/trunk/spool-api/src/main/java/
    james/server/trunk/spool-api/src/main/java/org/
    james/server/trunk/spool-api/src/main/java/org/apache/
    james/server/trunk/spool-api/src/main/java/org/apache/james/
    james/server/trunk/spool-api/src/main/java/org/apache/james/services/
    james/server/trunk/spool-api/src/main/java/org/apache/james/services/SpoolManager.java
      - copied unchanged from r999288, james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/spool-api/src/main/java/org/apache/james/services/SpoolRepository.java
      - copied unchanged from r999288, james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolRepository.java
Removed:
    james/server/trunk/core-api/src/main/java/org/apache/james/services/MailRepository.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolManager.java
    james/server/trunk/core-api/src/main/java/org/apache/james/services/SpoolRepository.java
    james/server/trunk/core-api/src/test/java/org/
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/AbstractMailRepository.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/FileMailRepository.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JCRMailRepository.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/JDBCMailRepository.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/MBoxMailRepository.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/MessageInputStream.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/MimeMessageAvalonSource.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/MimeMessageJDBCSource.java
    james/server/trunk/core-function/src/main/java/org/apache/james/mailrepository/package.html
    james/server/trunk/core-function/src/main/resources/
    james/server/trunk/core-function/src/test/java/org/
    james/server/trunk/core-function/src/test/resources/
    james/server/trunk/core-library/src/test/resources/
    james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/AbstractMailStore.java
Modified:
    james/server/trunk/common-util/pom.xml
    james/server/trunk/core-api/pom.xml
    james/server/trunk/core-function/pom.xml
    james/server/trunk/core-library/pom.xml
    james/server/trunk/dnsserver-api/pom.xml
    james/server/trunk/dnsserver/pom.xml
    james/server/trunk/domain-api/pom.xml
    james/server/trunk/domain-function/pom.xml
    james/server/trunk/domain-library/pom.xml
    james/server/trunk/fetchmail/pom.xml
    james/server/trunk/imapserver/pom.xml
    james/server/trunk/lmtpserver/pom.xml
    james/server/trunk/mailbox-adapter/pom.xml
    james/server/trunk/mailets/pom.xml
    james/server/trunk/management/pom.xml
    james/server/trunk/netty-socket/pom.xml
    james/server/trunk/pom.xml
    james/server/trunk/pop3server/pom.xml
    james/server/trunk/queue-activemq/pom.xml
    james/server/trunk/queue-api/pom.xml
    james/server/trunk/remotemanager/pom.xml
    james/server/trunk/smtpserver/pom.xml
    james/server/trunk/spoolmanager/pom.xml
    james/server/trunk/spring-common/pom.xml
    james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/SpringMailStore.java
    james/server/trunk/spring-deployment/pom.xml
    james/server/trunk/user-api/pom.xml
    james/server/trunk/user-function/pom.xml
    james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JpaUsersRepositoryTest.java
    james/server/trunk/user-library/pom.xml

Modified: james/server/trunk/common-util/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/common-util/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/common-util/pom.xml (original)
+++ james/server/trunk/common-util/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-common-util</artifactId>
-  <name>Apache JAMES Server Common Utilities</name>
+  <name>Apache James Server Common Utilities</name>
  <build>
     <plugins>
       <plugin>

Modified: james/server/trunk/core-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-api/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/core-api/pom.xml (original)
+++ james/server/trunk/core-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-core-api</artifactId>
-  <name>Apache JAMES Server Core API</name>
+  <name>Apache James Server Core API</name>
 
  <build>
     <plugins>

Modified: james/server/trunk/core-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-function/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/core-function/pom.xml (original)
+++ james/server/trunk/core-function/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-core-function</artifactId>
-  <name>Apache JAMES Server Core function</name>
+  <name>Apache James Server Core function</name>
   <dependencies>
   
     <dependency>
@@ -45,6 +45,10 @@
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-library</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-spool-api</artifactId>
+    </dependency>
 
     <dependency>
       <groupId>${javax.mail.groupId}</groupId>
@@ -105,12 +109,6 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>apache-mailet-base</artifactId>
-      <classifier>tests</classifier>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <groupId>org.apache.openjpa</groupId>
       <artifactId>openjpa</artifactId>
       <scope>test</scope>

Modified: james/server/trunk/core-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/core-library/pom.xml (original)
+++ james/server/trunk/core-library/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-core-library</artifactId>
-  <name>Apache JAMES Server Core Library</name>
+  <name>Apache James Server Core Library</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -36,15 +36,25 @@
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-common-util</artifactId>
     </dependency>   
+     <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-spool-api</artifactId>
+    </dependency>   
     
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>apache-mailet</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>apache-mailet-base</artifactId>
     </dependency>
+    
     <dependency>
       <groupId>commons-configuration</groupId>
       <artifactId>commons-configuration</artifactId>

Added: james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java?rev=999467&view=auto
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java (added)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageCopyOnWriteProxy.java Tue Sep 21 15:35:59 2010
@@ -0,0 +1,759 @@
+/****************************************************************
+ * 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.core;
+
+import javax.activation.DataHandler;
+import javax.mail.Address;
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Session;
+import javax.mail.Flags.Flag;
+import javax.mail.internet.MimeMessage;
+import javax.mail.search.SearchTerm;
+
+import org.apache.james.lifecycle.Disposable;
+import org.apache.james.lifecycle.LifecycleUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Enumeration;
+
+/**
+ * This object wraps a "possibly shared" MimeMessage tracking copies and
+ * automatically cloning it (if shared) when a write operation is invoked.
+ */
+public class MimeMessageCopyOnWriteProxy extends MimeMessage implements
+        Disposable {
+
+    /**
+     * Used internally to track the reference count
+     * It is important that this is static otherwise it will keep a reference to
+     * the parent object.
+     */
+    protected static class MessageReferenceTracker {
+
+        /**
+         * reference counter
+         */
+        private int referenceCount = 1;
+        
+        /**
+         * The mime message in memory
+         */
+        private MimeMessage wrapped = null;
+        
+        public MessageReferenceTracker(MimeMessage ref) {
+            wrapped = ref;
+        }
+
+        protected synchronized void incrementReferenceCount() {
+            /* Used to track references while debugging
+            try {
+                throw new Exception("incrementReferenceCount: "+(wrapped != null ? System.identityHashCode(wrapped)+"" : "null")+" ["+referenceCount+"]");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            */
+            referenceCount++;
+        }
+
+        protected synchronized void decrementReferenceCount() {
+            /* Used to track references while debugging
+            try {
+                throw new Exception("decrementReferenceCount: "+(wrapped != null ? System.identityHashCode(wrapped)+"" : "null")+" ["+referenceCount+"]");
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+            */
+            referenceCount--;
+            if (referenceCount<=0) {
+                LifecycleUtil.dispose(wrapped);
+                wrapped = null;
+            }
+        }
+
+        protected synchronized int getReferenceCount() {
+            return referenceCount;
+        }
+
+        public MimeMessage getWrapped() {
+            return wrapped;
+        }
+
+    }
+
+    protected MessageReferenceTracker refCount;
+
+    /**
+     * @param original
+     *            MimeMessageWrapper
+     * @throws MessagingException
+     */
+    public MimeMessageCopyOnWriteProxy(MimeMessage original)
+            throws MessagingException {
+        this(original, false);
+    }
+
+    /**
+     * @param original
+     *            MimeMessageSource
+     * @throws MessagingException
+     */
+    public MimeMessageCopyOnWriteProxy(MimeMessageSource original)
+            throws MessagingException {
+        this(new MimeMessageWrapper(original), true);
+    }
+
+    /**
+     * Private constructor providing an external reference counter.
+     * 
+     * @param original
+     * @param writeable
+     * @throws MessagingException
+     */
+    private MimeMessageCopyOnWriteProxy(MimeMessage original,
+            boolean writeable)
+            throws MessagingException {
+        super(Session.getDefaultInstance(System.getProperties(), null));
+
+        if (original instanceof MimeMessageCopyOnWriteProxy) {
+            refCount = ((MimeMessageCopyOnWriteProxy) original).refCount;
+        } else {
+            refCount = new MessageReferenceTracker(original);
+        }
+        
+        if (!writeable) {
+            refCount.incrementReferenceCount();
+        }
+    }
+
+    /**
+     * Check the number of references over the MimeMessage and clone it if
+     * needed before returning the reference
+     * 
+     * @throws MessagingException
+     *             exception
+     */
+    protected MimeMessage getWrappedMessageForWriting() throws MessagingException {
+        synchronized (refCount) {
+            if (refCount.getReferenceCount() > 1) {
+                refCount.decrementReferenceCount();
+                refCount = new MessageReferenceTracker(new MimeMessageWrapper(refCount.getWrapped()));
+            }
+        }
+        return refCount.getWrapped();
+    }
+    
+    /**
+     * Return wrapped mimeMessage
+     * 
+     * @return wrapped return the wrapped mimeMessage
+     */
+    public MimeMessage getWrappedMessage() {
+        return refCount.getWrapped();
+    }
+
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public synchronized void dispose() {
+        if (refCount != null) {
+            refCount.decrementReferenceCount();
+            refCount = null;
+        }
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    public void writeTo(OutputStream os) throws IOException, MessagingException {
+        getWrappedMessage().writeTo(os);
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    public void writeTo(OutputStream os, String[] ignoreList)
+            throws IOException, MessagingException {
+        getWrappedMessage().writeTo(os, ignoreList);
+    }
+
+    /**
+     * Various reader methods
+     */
+    
+    /**
+     * @see javax.mail.Message#getFrom()
+     */
+    public Address[] getFrom() throws MessagingException {
+        return getWrappedMessage().getFrom();
+    }
+
+    /**
+     * @see javax.mail.Message#getRecipients(javax.mail.Message.RecipientType)
+     */
+    public Address[] getRecipients(Message.RecipientType type)
+            throws MessagingException {
+        return getWrappedMessage().getRecipients(type);
+    }
+
+    /**
+     * @see javax.mail.Message#getAllRecipients()
+     */
+    public Address[] getAllRecipients() throws MessagingException {
+        return getWrappedMessage().getAllRecipients();
+    }
+
+    /**
+     * @see javax.mail.Message#getReplyTo()
+     */
+    public Address[] getReplyTo() throws MessagingException {
+        return getWrappedMessage().getReplyTo();
+    }
+
+    /**
+     * @see javax.mail.Message#getSubject()
+     */
+    public String getSubject() throws MessagingException {
+        return getWrappedMessage().getSubject();
+    }
+
+    /**
+     * @see javax.mail.Message#getSentDate()
+     */
+    public Date getSentDate() throws MessagingException {
+        return getWrappedMessage().getSentDate();
+    }
+
+    /**
+     * @see javax.mail.Message#getReceivedDate()
+     */
+    public Date getReceivedDate() throws MessagingException {
+        return getWrappedMessage().getReceivedDate();
+    }
+
+    /**
+     * @see javax.mail.Part#getSize()
+     */
+    public int getSize() throws MessagingException {
+        return getWrappedMessage().getSize();
+    }
+
+    /**
+     * @see javax.mail.Part#getLineCount()
+     */
+    public int getLineCount() throws MessagingException {
+        return getWrappedMessage().getLineCount();
+    }
+
+    /**
+     * @see javax.mail.Part#getContentType()
+     */
+    public String getContentType() throws MessagingException {
+        return getWrappedMessage().getContentType();
+    }
+
+    /**
+     * @see javax.mail.Part#isMimeType(java.lang.String)
+     */
+    public boolean isMimeType(String mimeType) throws MessagingException {
+        return getWrappedMessage().isMimeType(mimeType);
+    }
+
+    /**
+     * @see javax.mail.Part#getDisposition()
+     */
+    public String getDisposition() throws MessagingException {
+        return getWrappedMessage().getDisposition();
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getEncoding()
+     */
+    public String getEncoding() throws MessagingException {
+        return getWrappedMessage().getEncoding();
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getContentID()
+     */
+    public String getContentID() throws MessagingException {
+        return getWrappedMessage().getContentID();
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getContentMD5()
+     */
+    public String getContentMD5() throws MessagingException {
+        return getWrappedMessage().getContentMD5();
+    }
+
+    /**
+     * @see javax.mail.Part#getDescription()
+     */
+    public String getDescription() throws MessagingException {
+        return getWrappedMessage().getDescription();
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getContentLanguage()
+     */
+    public String[] getContentLanguage() throws MessagingException {
+        return getWrappedMessage().getContentLanguage();
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getMessageID()
+     */
+    public String getMessageID() throws MessagingException {
+        return getWrappedMessage().getMessageID();
+    }
+
+    /**
+     * @see javax.mail.Part#getFileName()
+     */
+    public String getFileName() throws MessagingException {
+        return getWrappedMessage().getFileName();
+    }
+
+    /**
+     * @see javax.mail.Part#getInputStream()
+     */
+    public InputStream getInputStream() throws IOException, MessagingException {
+        return getWrappedMessage().getInputStream();
+    }
+
+    /**
+     * @see javax.mail.Part#getDataHandler()
+     */
+    public DataHandler getDataHandler() throws MessagingException {
+        return getWrappedMessage().getDataHandler();
+    }
+
+    /**
+     * @see javax.mail.Part#getContent()
+     */
+    public Object getContent() throws IOException, MessagingException {
+        return getWrappedMessage().getContent();
+    }
+
+    /**
+     * @see javax.mail.Part#getHeader(java.lang.String)
+     */
+    public String[] getHeader(String name) throws MessagingException {
+        return getWrappedMessage().getHeader(name);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getHeader(java.lang.String, java.lang.String)
+     */
+    public String getHeader(String name, String delimiter)
+            throws MessagingException {
+        return getWrappedMessage().getHeader(name, delimiter);
+    }
+
+    /**
+     * @see javax.mail.Part#getAllHeaders()
+     */
+    public Enumeration getAllHeaders() throws MessagingException {
+        return getWrappedMessage().getAllHeaders();
+    }
+
+    /**
+     * @see javax.mail.Part#getMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getMatchingHeaders(String[] names)
+            throws MessagingException {
+        return getWrappedMessage().getMatchingHeaders(names);
+    }
+
+    /**
+     * @see javax.mail.Part#getNonMatchingHeaders(java.lang.String[])
+     */
+    public Enumeration getNonMatchingHeaders(String[] names)
+            throws MessagingException {
+        return getWrappedMessage().getNonMatchingHeaders(names);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getAllHeaderLines()
+     */
+    public Enumeration getAllHeaderLines() throws MessagingException {
+        return getWrappedMessage().getAllHeaderLines();
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getMatchingHeaderLines(java.lang.String[])
+     */
+    public Enumeration getMatchingHeaderLines(String[] names)
+            throws MessagingException {
+        return getWrappedMessage().getMatchingHeaderLines(names);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#getNonMatchingHeaderLines(java.lang.String[])
+     */
+    public Enumeration getNonMatchingHeaderLines(String[] names)
+            throws MessagingException {
+        return getWrappedMessage().getNonMatchingHeaderLines(names);
+    }
+
+    /**
+     * @see javax.mail.Message#getFlags()
+     */
+    public Flags getFlags() throws MessagingException {
+        return getWrappedMessage().getFlags();
+    }
+
+    /**
+     * @see javax.mail.Message#isSet(javax.mail.Flags.Flag)
+     */
+    public boolean isSet(Flags.Flag flag) throws MessagingException {
+        return getWrappedMessage().isSet(flag);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getSender()
+     */
+    public Address getSender() throws MessagingException {
+        return getWrappedMessage().getSender();
+    }
+
+    /**
+     * @see javax.mail.Message#match(javax.mail.search.SearchTerm)
+     */
+    public boolean match(SearchTerm arg0) throws MessagingException {
+        return getWrappedMessage().match(arg0);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getRawInputStream()
+     */
+    public InputStream getRawInputStream() throws MessagingException {
+        return getWrappedMessage().getRawInputStream();
+    }
+
+    /**
+     * @see javax.mail.Message#getFolder()
+     */
+    public Folder getFolder() {
+        return getWrappedMessage().getFolder();
+    }
+
+    /**
+     * @see javax.mail.Message#getMessageNumber()
+     */
+    public int getMessageNumber() {
+        return getWrappedMessage().getMessageNumber();
+    }
+
+    /**
+     * @see javax.mail.Message#isExpunged()
+     */
+    public boolean isExpunged() {
+        return getWrappedMessage().isExpunged();
+    }
+
+    /**
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object arg0) {
+        return getWrappedMessage().equals(arg0);
+    }
+
+    /**
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode() {
+        return getWrappedMessage().hashCode();
+    }
+
+    /**
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        return getWrappedMessage().toString();
+    }
+
+    /*
+     * Various writer methods
+     */
+
+    /**
+     * @see javax.mail.Message#setFrom(javax.mail.Address)
+     */
+    public void setFrom(Address address) throws MessagingException {
+        getWrappedMessageForWriting().setFrom(address);
+    }
+
+    /**
+     * @see javax.mail.Message#setFrom()
+     */
+    public void setFrom() throws MessagingException {
+        getWrappedMessageForWriting().setFrom();
+    }
+
+    /**
+     * @see javax.mail.Message#addFrom(javax.mail.Address[])
+     */
+    public void addFrom(Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().addFrom(addresses);
+    }
+
+    /**
+     * @see javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
+     */
+    public void setRecipients(Message.RecipientType type, Address[] addresses)
+            throws MessagingException {
+        getWrappedMessageForWriting().setRecipients(type, addresses);
+    }
+
+    /**
+     * @see javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])
+     */
+    public void addRecipients(Message.RecipientType type, Address[] addresses)
+            throws MessagingException {
+        getWrappedMessageForWriting().addRecipients(type, addresses);
+    }
+
+    /**
+     * @see javax.mail.Message#setReplyTo(javax.mail.Address[])
+     */
+    public void setReplyTo(Address[] addresses) throws MessagingException {
+        getWrappedMessageForWriting().setReplyTo(addresses);
+    }
+
+    /**
+     * @see javax.mail.Message#setSubject(java.lang.String)
+     */
+    public void setSubject(String subject) throws MessagingException {
+        getWrappedMessageForWriting().setSubject(subject);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#setSubject(java.lang.String, java.lang.String)
+     */
+    public void setSubject(String subject, String charset)
+            throws MessagingException {
+        getWrappedMessageForWriting().setSubject(subject, charset);
+    }
+
+    /**
+     * @see javax.mail.Message#setSentDate(java.util.Date)
+     */
+    public void setSentDate(Date d) throws MessagingException {
+        getWrappedMessageForWriting().setSentDate(d);
+    }
+
+    /**
+     * @see javax.mail.Part#setDisposition(java.lang.String)
+     */
+    public void setDisposition(String disposition) throws MessagingException {
+        getWrappedMessageForWriting().setDisposition(disposition);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#setContentID(java.lang.String)
+     */
+    public void setContentID(String cid) throws MessagingException {
+        getWrappedMessageForWriting().setContentID(cid);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#setContentMD5(java.lang.String)
+     */
+    public void setContentMD5(String md5) throws MessagingException {
+        getWrappedMessageForWriting().setContentMD5(md5);
+    }
+
+    /**
+     * @see javax.mail.Part#setDescription(java.lang.String)
+     */
+    public void setDescription(String description) throws MessagingException {
+        getWrappedMessageForWriting().setDescription(description);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#setDescription(java.lang.String, java.lang.String)
+     */
+    public void setDescription(String description, String charset)
+            throws MessagingException {
+        getWrappedMessageForWriting().setDescription(description, charset);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#setContentLanguage(java.lang.String[])
+     */
+    public void setContentLanguage(String[] languages)
+            throws MessagingException {
+        getWrappedMessageForWriting().setContentLanguage(languages);
+    }
+
+    /**
+     * @see javax.mail.Part#setFileName(java.lang.String)
+     */
+    public void setFileName(String filename) throws MessagingException {
+        getWrappedMessageForWriting().setFileName(filename);
+    }
+
+    /**
+     * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
+     */
+    public void setDataHandler(DataHandler dh) throws MessagingException {
+        getWrappedMessageForWriting().setDataHandler(dh);
+    }
+
+    /**
+     * @see javax.mail.Part#setContent(java.lang.Object, java.lang.String)
+     */
+    public void setContent(Object o, String type) throws MessagingException {
+        getWrappedMessageForWriting().setContent(o, type);
+    }
+
+    /**
+     * @see javax.mail.Part#setText(java.lang.String)
+     */
+    public void setText(String text) throws MessagingException {
+        getWrappedMessageForWriting().setText(text);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#setText(java.lang.String, java.lang.String)
+     */
+    public void setText(String text, String charset) throws MessagingException {
+        getWrappedMessageForWriting().setText(text, charset);
+    }
+
+    /**
+     * @see javax.mail.Part#setContent(javax.mail.Multipart)
+     */
+    public void setContent(Multipart mp) throws MessagingException {
+        getWrappedMessageForWriting().setContent(mp);
+    }
+
+    /**
+     * This does not need a writable message
+     * @see javax.mail.Message#reply(boolean)
+     */
+    public Message reply(boolean replyToAll) throws MessagingException {
+        return getWrappedMessage().reply(replyToAll);
+    }
+
+    /**
+     * @see javax.mail.Part#setHeader(java.lang.String, java.lang.String)
+     */
+    public void setHeader(String name, String value) throws MessagingException {
+        getWrappedMessageForWriting().setHeader(name, value);
+    }
+
+    /**
+     * @see javax.mail.Part#addHeader(java.lang.String, java.lang.String)
+     */
+    public void addHeader(String name, String value) throws MessagingException {
+        getWrappedMessageForWriting().addHeader(name, value);
+    }
+
+    /**
+     * @see javax.mail.Part#removeHeader(java.lang.String)
+     */
+    public void removeHeader(String name) throws MessagingException {
+        getWrappedMessageForWriting().removeHeader(name);
+    }
+
+    /**
+     * @see javax.mail.internet.MimePart#addHeaderLine(java.lang.String)
+     */
+    public void addHeaderLine(String line) throws MessagingException {
+        getWrappedMessageForWriting().addHeaderLine(line);
+    }
+
+    /**
+     * @see javax.mail.Message#setFlags(javax.mail.Flags, boolean)
+     */
+    public void setFlags(Flags flag, boolean set) throws MessagingException {
+        getWrappedMessageForWriting().setFlags(flag, set);
+    }
+
+    /**
+     * @see javax.mail.Message#saveChanges()
+     */
+    public void saveChanges() throws MessagingException {
+        getWrappedMessageForWriting().saveChanges();
+    }
+
+    /*
+     * Since JavaMail 1.2
+     */
+
+    /**
+     * @see javax.mail.internet.MimeMessage#addRecipients(javax.mail.Message.RecipientType, java.lang.String)
+     */
+    public void addRecipients(Message.RecipientType type, String addresses)
+            throws MessagingException {
+        getWrappedMessageForWriting().addRecipients(type, addresses);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#setRecipients(javax.mail.Message.RecipientType, java.lang.String)
+     */
+    public void setRecipients(Message.RecipientType type, String addresses)
+            throws MessagingException {
+        getWrappedMessageForWriting().setRecipients(type, addresses);
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#setSender(javax.mail.Address)
+     */
+    public void setSender(Address arg0) throws MessagingException {
+        getWrappedMessageForWriting().setSender(arg0);
+    }
+
+    /**
+     * @see javax.mail.Message#addRecipient(javax.mail.Message.RecipientType, javax.mail.Address)
+     */
+    public void addRecipient(RecipientType arg0, Address arg1)
+            throws MessagingException {
+        getWrappedMessageForWriting().addRecipient(arg0, arg1);
+    }
+
+    /**
+     * @see javax.mail.Message#setFlag(javax.mail.Flags.Flag, boolean)
+     */
+    public void setFlag(Flag arg0, boolean arg1) throws MessagingException {
+        getWrappedMessageForWriting().setFlag(arg0, arg1);
+    }
+
+    /**
+     * @return the message size
+     * @throws MessagingException 
+     */
+    public long getMessageSize() throws MessagingException {
+        return MimeMessageUtil.getMessageSize(getWrappedMessage());
+    }
+
+}

Added: james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageWrapper.java
URL: http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageWrapper.java?rev=999467&view=auto
==============================================================================
--- james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageWrapper.java (added)
+++ james/server/trunk/core-library/src/main/java/org/apache/james/core/MimeMessageWrapper.java Tue Sep 21 15:35:59 2010
@@ -0,0 +1,551 @@
+/****************************************************************
+ * 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.core;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.james.lifecycle.Disposable;
+import org.apache.james.lifecycle.LifecycleUtil;
+import org.apache.james.util.InternetPrintWriter;
+
+import javax.activation.DataHandler;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.internet.InternetHeaders;
+import javax.mail.internet.MimeMessage;
+import javax.mail.util.SharedByteArrayInputStream;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Enumeration;
+
+/**
+ * This object wraps a MimeMessage, only loading the underlying MimeMessage
+ * object when needed.  Also tracks if changes were made to reduce
+ * unnecessary saves.
+ */
+public class MimeMessageWrapper
+    extends MimeMessage
+    implements Disposable {
+
+    /**
+     * Can provide an input stream to the data
+     */
+    protected MimeMessageSource source = null;
+    
+    /**
+     * This is false until we parse the message 
+     */
+    protected boolean messageParsed = false;
+    
+    /**
+     * This is false until we parse the message 
+     */
+    protected boolean headersModified = false;
+    
+    /**
+     * This is false until we parse the message 
+     */
+    protected boolean bodyModified = false;
+
+    /**
+     * Keep a reference to the sourceIn so we can close it
+     * only when we dispose the message.
+     */
+    private InputStream sourceIn;
+
+    private MimeMessageWrapper(Session session) throws MessagingException {
+        super(session);
+        this.headers = null;
+        this.modified = false;
+        this.headersModified = false;
+        this.bodyModified = false;
+    }
+    
+    /**
+     * A constructor that instantiates a MimeMessageWrapper based on
+     * a MimeMessageSource
+     *
+     * @param source the MimeMessageSource
+     * @throws MessagingException 
+     */
+    public MimeMessageWrapper(Session session, MimeMessageSource source) throws MessagingException {
+        this(session);
+        this.source = source;
+    }
+
+    /**
+     * A constructor that instantiates a MimeMessageWrapper based on
+     * a MimeMessageSource
+     *
+     * @param source the MimeMessageSource
+     * @throws MessagingException 
+     * @throws MessagingException 
+     */
+    public MimeMessageWrapper(MimeMessageSource source) throws MessagingException {
+        this(Session.getDefaultInstance(System.getProperties()),source);
+    }
+
+    public MimeMessageWrapper(MimeMessage original) throws MessagingException {
+        this(Session.getDefaultInstance(System.getProperties()));
+        flags = original.getFlags();
+        
+        // if the original is an unmodified MimeMessageWrapped we clone the headers and
+        // take its source.
+        /* Temporary commented out because of JAMES-474
+        if (original instanceof MimeMessageWrapper && !((MimeMessageWrapper) original).bodyModified) {
+            source = ((MimeMessageWrapper) original).source;
+            // this probably speed up things
+            if (((MimeMessageWrapper) original).headers != null) {
+                ByteArrayOutputStream temp = new ByteArrayOutputStream();
+                InternetHeaders ih = ((MimeMessageWrapper) original).headers;
+                MimeMessageUtil.writeHeadersTo(ih.getAllHeaderLines(),temp);
+                headers = createInternetHeaders(new ByteArrayInputStream(temp.toByteArray()));
+                headersModified = ((MimeMessageWrapper) original).headersModified;
+            }
+        }
+        */
+        
+        if (source == null) {
+            ByteArrayOutputStream bos;
+            int size = original.getSize();
+            if (size > 0)
+                bos = new ByteArrayOutputStream(size);
+            else
+                bos = new ByteArrayOutputStream();
+            try {
+                original.writeTo(bos);
+                bos.close();
+                SharedByteArrayInputStream bis =
+                        new SharedByteArrayInputStream(bos.toByteArray());
+                parse(bis);
+                bis.close();
+                saved = true;
+            } catch (IOException ex) {
+                // should never happen, but just in case...
+                throw new MessagingException("IOException while copying message",
+                                ex);
+            }
+        }
+    }
+    
+    /**
+     * Returns the source ID of the MimeMessageSource that is supplying this
+     * with data.
+     * @see MimeMessageSource
+     */
+    public synchronized String getSourceId() {
+        return source != null ? source.getSourceId() : null;
+    }
+
+    /**
+     * Load the message headers from the internal source.
+     *
+     * @throws MessagingException if an error is encountered while
+     *                            loading the headers
+     */
+    protected synchronized void loadHeaders() throws MessagingException {
+        if (headers != null) {
+            //Another thread has already loaded these headers
+            return;
+        } else if (source != null) { 
+            try {
+                InputStream in = source.getInputStream();
+                try {
+                    headers = createInternetHeaders(in);
+                } finally {
+                    IOUtils.closeQuietly(in);
+                }
+            } catch (IOException ioe) {
+                throw new MessagingException("Unable to parse headers from stream: " + ioe.getMessage(), ioe);
+            }
+        } else {
+            throw new MessagingException("loadHeaders called for a message with no source, contentStream or stream");
+        }
+    }
+
+    /**
+     * Load the complete MimeMessage from the internal source.
+     *
+     * @throws MessagingException if an error is encountered while
+     *                            loading the message
+     */
+    protected synchronized void loadMessage() throws MessagingException {
+        if (messageParsed) {
+            //Another thread has already loaded this message
+            return;
+        } else if (source != null) {
+            sourceIn = null;
+            try {
+                sourceIn = source.getInputStream();
+    
+                parse(sourceIn);
+                // TODO is it ok?
+                saved = true;
+                
+            } catch (IOException ioe) {
+                IOUtils.closeQuietly(sourceIn);
+                sourceIn = null;
+                throw new MessagingException("Unable to parse stream: " + ioe.getMessage(), ioe);
+            }
+        } else {
+            throw new MessagingException("loadHeaders called for an unparsed message with no source");
+        }
+    }
+
+    /**
+     * Get whether the message has been modified.
+     *
+     * @return whether the message has been modified
+     */
+    public synchronized boolean isModified() {
+        return headersModified || bodyModified || modified;
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    public synchronized void writeTo(OutputStream os) throws IOException, MessagingException {
+        if (source != null && !isModified()) {
+            // We do not want to instantiate the message... just read from source
+            // and write to this outputstream
+            InputStream in = source.getInputStream();
+            try {
+                IOUtils.copy(in, os);
+            } finally {
+                IOUtils.closeQuietly(in);
+            }
+        } else {
+            writeTo(os, os);
+        }
+    }
+
+    /**
+     * Rewritten for optimization purposes
+     */
+    public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException {
+        writeTo(os, os, ignoreList);
+    }
+
+    /**
+     * Write
+     */
+    public void writeTo(OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException {
+        writeTo(headerOs, bodyOs, new String[0]);
+    }
+
+    public synchronized void writeTo(OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException {
+        if (source != null && !isModified()) {
+            //We do not want to instantiate the message... just read from source
+            //  and write to this outputstream
+
+            //First handle the headers
+            InputStream in = source.getInputStream();
+            try {
+                InternetHeaders headers = new InternetHeaders(in);
+                PrintWriter pos = new InternetPrintWriter(new BufferedWriter(new OutputStreamWriter(headerOs), 512), true);
+                for (Enumeration e = headers.getNonMatchingHeaderLines(ignoreList); e.hasMoreElements(); ) {
+                    String header = (String)e.nextElement();
+                    pos.println(header);
+                }
+                pos.println();
+                pos.flush();
+                IOUtils.copy(in, bodyOs);
+            } finally {
+                IOUtils.closeQuietly(in);
+            }
+        } else {
+            MimeMessageUtil.writeToInternal(this, headerOs, bodyOs, ignoreList);
+        }
+    }
+
+    /**
+     * This is the MimeMessage implementation - this should return ONLY the
+     * body, not the entire message (should not count headers).  Will have
+     * to parse the message.
+     */
+    public int getSize() throws MessagingException {
+        if (!messageParsed) {
+            loadMessage();
+        }
+        return super.getSize();
+    }
+
+    /**
+     * Corrects JavaMail 1.1 version which always returns -1.
+     * Only corrected for content less than 5000 bytes,
+     * to avoid memory hogging.
+     */
+    public int getLineCount() throws MessagingException {
+            InputStream in=null;
+        try{
+            in = getContentStream();
+        }catch(Exception e){
+            return -1;
+        }
+        if (in == null) {
+            return -1;
+        }
+        //Wrap input stream in LineNumberReader
+        //Not sure what encoding to use really...
+        try {
+            LineNumberReader counter;
+            if (getEncoding() != null) {
+                counter = new LineNumberReader(new InputStreamReader(in, getEncoding()));
+            } else {
+                counter = new LineNumberReader(new InputStreamReader(in));
+            }
+            //Read through all the data
+            char[] block = new char[4096];
+            while (counter.read(block) > -1) {
+                //Just keep reading
+            }
+            return counter.getLineNumber();
+        } catch (IOException ioe) {
+            return -1;
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
+    }
+
+    /**
+     * Returns size of message, ie headers and content
+     */
+    public long getMessageSize() throws MessagingException {
+        if (source != null && !isModified()) {
+            try {
+                return source.getMessageSize();
+            } catch (IOException ioe) {
+                throw new MessagingException("Error retrieving message size", ioe);
+            }
+        } else {
+            return MimeMessageUtil.calculateMessageSize(this);
+        }
+    }
+    
+    /**
+     * We override all the "headers" access methods to be sure that we
+     * loaded the headers 
+     */
+    
+    public String[] getHeader(String name) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getHeader(name);
+    }
+
+    public String getHeader(String name, String delimiter) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getHeader(name, delimiter);
+    }
+
+    public Enumeration getAllHeaders() throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getAllHeaders();
+    }
+
+    public Enumeration getMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getMatchingHeaders(names);
+    }
+
+    public Enumeration getNonMatchingHeaders(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getNonMatchingHeaders(names);
+    }
+
+    public Enumeration getAllHeaderLines() throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getAllHeaderLines();
+    }
+
+    public Enumeration getMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getMatchingHeaderLines(names);
+    }
+
+    public Enumeration getNonMatchingHeaderLines(String[] names) throws MessagingException {
+        if (headers == null) {
+            loadHeaders();
+        }
+        return headers.getNonMatchingHeaderLines(names);
+    }
+
+
+    private synchronized void checkModifyHeaders() throws MessagingException {
+        // Disable only-header loading optimizations for JAMES-559
+        if (!messageParsed) {
+            loadMessage();
+        }
+        // End JAMES-559
+        if (headers == null) {
+            loadHeaders();
+        }
+        modified = true;
+        saved = false;
+        headersModified = true;
+    }
+
+    public void setHeader(String name, String value) throws MessagingException {
+        checkModifyHeaders();
+        super.setHeader(name, value);
+    }
+
+    public void addHeader(String name, String value) throws MessagingException {
+        checkModifyHeaders();
+        super.addHeader(name, value);
+    }
+
+    public void removeHeader(String name) throws MessagingException {
+        checkModifyHeaders();
+        super.removeHeader(name);
+    }
+
+    public void addHeaderLine(String line) throws MessagingException {
+        checkModifyHeaders();
+        super.addHeaderLine(line);
+    }
+
+
+    /**
+     * The message is changed when working with headers and when altering the content.
+     * Every method that alter the content will fallback to this one.
+     * 
+     * @see javax.mail.Part#setDataHandler(javax.activation.DataHandler)
+     */
+    public synchronized void setDataHandler(DataHandler arg0) throws MessagingException {
+        modified = true;
+        saved = false;
+        bodyModified = true;
+        super.setDataHandler(arg0);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if (sourceIn != null) {
+            IOUtils.closeQuietly(sourceIn);
+        }
+        if (source != null) {
+            LifecycleUtil.dispose(source);
+        }
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#parse(java.io.InputStream)
+     */
+    protected synchronized void parse(InputStream is) throws MessagingException {
+        // the super implementation calls
+        // headers = createInternetHeaders(is);
+        super.parse(is);
+        messageParsed = true;
+    }
+
+    /**
+     * If we already parsed the headers then we simply return the updated ones.
+     * Otherwise we parse
+     * 
+     * @see javax.mail.internet.MimeMessage#createInternetHeaders(java.io.InputStream)
+     */
+    protected synchronized InternetHeaders createInternetHeaders(InputStream is) throws MessagingException {
+        /* This code is no more needed: see JAMES-570 and new tests
+           
+         * InternetHeaders can be a bit awkward to work with due to
+         * its own internal handling of header order.  This hack may
+         * not always be necessary, but for now we are trying to
+         * ensure that there is a Return-Path header, even if just a
+         * placeholder, so that later, e.g., in LocalDelivery, when we
+         * call setHeader, it will remove any other Return-Path
+         * headers, and ensure that ours is on the top. addHeader
+         * handles header order, but not setHeader. This may change in
+         * future JavaMail.  But if there are other Return-Path header
+         * values, let's drop our placeholder.
+
+        MailHeaders newHeaders = new MailHeaders(new ByteArrayInputStream((RFC2822Headers.RETURN_PATH + ": placeholder").getBytes()));
+        newHeaders.setHeader(RFC2822Headers.RETURN_PATH, null);
+        newHeaders.load(is);
+        String[] returnPathHeaders = newHeaders.getHeader(RFC2822Headers.RETURN_PATH);
+        if (returnPathHeaders.length > 1) newHeaders.setHeader(RFC2822Headers.RETURN_PATH, returnPathHeaders[1]);
+        */
+        
+        // Keep this: skip the headers from the stream
+        // we could put that code in the else and simple write an "header" skipping
+        // reader for the others.
+        MailHeaders newHeaders = new MailHeaders(is);
+        
+        if (headers != null) {
+            return headers;
+        } else {
+            return newHeaders;
+        }
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getContentStream()
+     */
+    protected InputStream getContentStream() throws MessagingException {
+        if (!messageParsed) {
+            loadMessage();
+        }
+        return super.getContentStream();
+    }
+
+    /**
+     * @see javax.mail.internet.MimeMessage#getRawInputStream()
+     */
+    public InputStream getRawInputStream() throws MessagingException {
+        if (!messageParsed && !isModified() && source != null) {
+            InputStream is;
+            try {
+                is = source.getInputStream();
+                // skip the headers.
+                new MailHeaders(is);
+                return is;
+            } catch (IOException e) {
+                throw new MessagingException("Unable to read the stream: " + e.getMessage(), e);
+            }
+        } else return super.getRawInputStream();
+    }
+
+    
+    
+}

Modified: james/server/trunk/dnsserver-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsserver-api/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/dnsserver-api/pom.xml (original)
+++ james/server/trunk/dnsserver-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-dnsserver-api</artifactId>
-  <name>Apache JAMES Server DNS Server API</name>
+  <name>Apache James Server DNS Server API</name>
   
    <build>
     <plugins>

Modified: james/server/trunk/dnsserver/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/dnsserver/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/dnsserver/pom.xml (original)
+++ james/server/trunk/dnsserver/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-dnsserver</artifactId>
-  <name>Apache JAMES Server DNSService Implementation</name>
+  <name>Apache James Server DNSService Implementation</name>
   <build>
     <plugins>
       <plugin>

Modified: james/server/trunk/domain-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-api/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/domain-api/pom.xml (original)
+++ james/server/trunk/domain-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-domain-api</artifactId>
-  <name>Apache JAMES Server Domain API</name>
+  <name>Apache James Server Domain API</name>
   
    <build>
     <plugins>

Modified: james/server/trunk/domain-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-function/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/domain-function/pom.xml (original)
+++ james/server/trunk/domain-function/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-domain-function</artifactId>
-  <name>Apache JAMES Server Domain Function</name>
+  <name>Apache James Server Domain Function</name>
   <dependencies>
   
     <dependency>

Modified: james/server/trunk/domain-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/domain-library/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/domain-library/pom.xml (original)
+++ james/server/trunk/domain-library/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-domain-library</artifactId>
-  <name>Apache JAMES Domain Library</name>
+  <name>Apache James Server Domain Library</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/fetchmail/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/fetchmail/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/fetchmail/pom.xml (original)
+++ james/server/trunk/fetchmail/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-fetchmail</artifactId>
-  <name>Apache JAMES Server FetchMail</name>
+  <name>Apache James Server FetchMail</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/imapserver/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/imapserver/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/imapserver/pom.xml (original)
+++ james/server/trunk/imapserver/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-imapserver</artifactId>
-  <name>Apache JAMES Server IMAP</name>
+  <name>Apache James Server IMAP</name>
   <dependencies>
    <dependency>
       <groupId>org.apache.james</groupId>
@@ -56,10 +56,5 @@
       <groupId>org.jboss.netty</groupId>
       <artifactId>netty</artifactId>
     </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
   </dependencies>
 </project>

Modified: james/server/trunk/lmtpserver/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/lmtpserver/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/lmtpserver/pom.xml (original)
+++ james/server/trunk/lmtpserver/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-lmtpserver</artifactId>
-  <name>Apache JAMES Server LMTP</name>
+  <name>Apache James Server LMTP</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/mailbox-adapter/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailbox-adapter/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/mailbox-adapter/pom.xml (original)
+++ james/server/trunk/mailbox-adapter/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-mailbox-adapter</artifactId>
-  <name>Apache JAMES Server Mailbox Adapter</name>
+  <name>Apache James Server Mailbox Adapter</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/mailets/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/mailets/pom.xml (original)
+++ james/server/trunk/mailets/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-mailets</artifactId>
-  <name>Apache JAMES Server Mailets</name>
+  <name>Apache James Server Mailets</name>
   <packaging>jar</packaging>
   <build>
     <plugins>

Modified: james/server/trunk/management/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/management/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/management/pom.xml (original)
+++ james/server/trunk/management/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-management</artifactId>
-  <name>Apache JAMES Server Management</name>
+  <name>Apache James Server Management</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -42,6 +42,10 @@
     </dependency> 
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-spool-api</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>apache-mailet</artifactId>
     </dependency>
     <dependency>
@@ -64,5 +68,36 @@
       <groupId>com.thoughtworks.xstream</groupId>
       <artifactId>xstream</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-store</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-mailet</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency> 
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-mailet-base</artifactId>
+      <classifier>tests</classifier>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>

Modified: james/server/trunk/netty-socket/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/netty-socket/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/netty-socket/pom.xml (original)
+++ james/server/trunk/netty-socket/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-netty-socket</artifactId>
-  <name>Apache JAMES Server Netty Socket</name>
+  <name>Apache James Server Netty Socket</name>
    <build>
     <plugins>
       <plugin>

Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server</artifactId>
-  <name>Apache JAMES Server</name>
+  <name>Apache James Server</name>
   <version>3.0-SNAPSHOT</version>
   <description>The Apache Java Enterprise Mail Server (a.k.a. JAMES Server)</description>
   <url>http://james.apache.org/server/head/</url>
@@ -50,6 +50,7 @@
     <module>smtpserver</module>
     <module>lmtpserver</module>
     <module>pop3server</module>
+    <module>spool-api</module>
     <module>spoolmanager</module>
     <module>remotemanager</module>
     <module>mailets</module>
@@ -312,6 +313,23 @@
         </exclusion>
       </exclusions>
     </dependency>
+
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-api</artifactId>
+      <version>${protocols.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-impl</artifactId>
+      <version>${protocols.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james.protocols</groupId>
+      <artifactId>protocols-smtp</artifactId>
+      <version>${protocols.version}</version>
+    </dependency>
+    
     <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-mailbox-adapter</artifactId>
@@ -347,24 +365,6 @@
       <version>${project.version}</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.james.protocols</groupId>
-      <artifactId>protocols-api</artifactId>
-      <version>${protocols.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.james.protocols</groupId>
-      <artifactId>protocols-impl</artifactId>
-      <version>${protocols.version}</version>
-    </dependency>
-    
-    <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-api</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-domain-api</artifactId>
       <version>${project.version}</version>
@@ -400,11 +400,23 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-management</artifactId>
       <version>${project.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-spool-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-user-library</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -419,11 +431,6 @@
       <groupId>org.apache.james.protocols</groupId>
       <artifactId>protocols-smtp</artifactId>
       <version>${protocols.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.james.protocols</groupId>
-      <artifactId>protocols-smtp</artifactId>
-      <version>${protocols.version}</version>
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
@@ -517,6 +524,16 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-file</artifactId>
+      <version>${imap.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-jdbc</artifactId>
+      <version>${imap.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>apache-james-mailbox-store</artifactId>
       <version>${imap.version}</version>
       <exclusions>
@@ -564,13 +581,6 @@
       <artifactId>apache-james-memory</artifactId>
       <version>${imap.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-library</artifactId>
-      <version>${project.version}</version>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
 
     <dependency>
         <groupId>com.h2database</groupId>
@@ -1065,7 +1075,7 @@
     <camel.version>2.4.0</camel.version>
     <activemq.version>5.4.0</activemq.version>
     <spring.version>3.0.2.RELEASE</spring.version>
-    <imap.version>0.1-M2-SNAPSHOT</imap.version>
+    <imap.version>0.2-SNAPSHOT</imap.version>
     <protocols.version>1.2-SNAPSHOT</protocols.version>
     <jsieve.version>0.4</jsieve.version>
     <jackrabbit.version>2.1.0</jackrabbit.version>

Modified: james/server/trunk/pop3server/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pop3server/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/pop3server/pom.xml (original)
+++ james/server/trunk/pop3server/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-pop3server</artifactId>
-  <name>Apache JAMES Server POP3</name>
+  <name>Apache James Server POP3</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -98,12 +98,6 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-api</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>    
-    <dependency>
-      <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-library</artifactId>
       <type>test-jar</type>
       <scope>test</scope>

Modified: james/server/trunk/queue-activemq/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-activemq/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/queue-activemq/pom.xml (original)
+++ james/server/trunk/queue-activemq/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-queue-activemq</artifactId>
-  <name>Apache JAMES Server ActiveMQ Queue</name>
+  <name>Apache James Server ActiveMQ Queue</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/queue-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/queue-api/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/queue-api/pom.xml (original)
+++ james/server/trunk/queue-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-queue-api</artifactId>
-  <name>Apache JAMES Server Queue API</name>
+  <name>Apache James Server Queue API</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/remotemanager/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/remotemanager/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/remotemanager/pom.xml (original)
+++ james/server/trunk/remotemanager/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-remotemanager</artifactId>
-  <name>Apache JAMES Server RemoteManager</name>
+  <name>Apache James Server RemoteManager</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -91,12 +91,6 @@
     <!-- Test dependencies -->
     <dependency>
       <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-api</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.james</groupId>
       <artifactId>james-server-core-library</artifactId>
       <type>test-jar</type>
       <scope>test</scope>

Modified: james/server/trunk/smtpserver/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/smtpserver/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/smtpserver/pom.xml (original)
+++ james/server/trunk/smtpserver/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-smtpserver</artifactId>
-  <name>Apache JAMES Server SMTP</name>
+  <name>Apache James Server SMTP</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -101,12 +101,6 @@
 
     <!-- Test dependencies -->
     <dependency>
-      <groupId>org.apache.james</groupId>
-      <artifactId>james-server-core-api</artifactId>
-      <type>test-jar</type>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
       <artifactId>dnsjava</artifactId>
       <groupId>dnsjava</groupId>
       <scope>runtime</scope>
@@ -153,6 +147,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+      <scope>test</scope>
+      <type>test-jar</type>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-domain-api</artifactId>
       <scope>test</scope>
       <type>test-jar</type>

Propchange: james/server/trunk/spool-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Sep 21 15:35:59 2010
@@ -0,0 +1,2 @@
+.*
+target

Added: james/server/trunk/spool-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spool-api/pom.xml?rev=999467&view=auto
==============================================================================
--- james/server/trunk/spool-api/pom.xml (added)
+++ james/server/trunk/spool-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -0,0 +1,36 @@
+<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <artifactId>james-server</artifactId>
+    <groupId>org.apache.james</groupId>
+    <version>3.0-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.james</groupId>
+  <artifactId>james-server-spool-api</artifactId>
+  <name>Apache James Server Spool API</name>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-api</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Modified: james/server/trunk/spoolmanager/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spoolmanager/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/spoolmanager/pom.xml (original)
+++ james/server/trunk/spoolmanager/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-spoolmanager</artifactId>
-  <name>Apache JAMES Server SpoolManager</name>
+  <name>Apache James Server SpoolManager</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>

Modified: james/server/trunk/spring-common/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-common/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/spring-common/pom.xml (original)
+++ james/server/trunk/spring-common/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-spring-common</artifactId>
-  <name>Apache JAMES Server Spring Common</name>
+  <name>Apache James Server Spring Common</name>
   <build>
     <plugins>
       <plugin>
@@ -89,6 +89,10 @@
       <artifactId>protocols-api</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-store</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-beans</artifactId>
     </dependency>

Modified: james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/SpringMailStore.java
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/SpringMailStore.java?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/SpringMailStore.java (original)
+++ james/server/trunk/spring-common/src/main/java/org/apache/james/container/spring/SpringMailStore.java Tue Sep 21 15:35:59 2010
@@ -38,6 +38,7 @@ import org.springframework.beans.factory
 public class SpringMailStore extends AbstractMailStore implements BeanFactoryAware{
 
     private Registry<HierarchicalConfiguration> confRegistry;
+    
     private Registry<Log> logRegistry;
     
     @Resource(name="configurationRegistry")

Modified: james/server/trunk/spring-deployment/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/spring-deployment/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/spring-deployment/pom.xml (original)
+++ james/server/trunk/spring-deployment/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-spring-deployment</artifactId>
-  <name>Apache JAMES Server Spring Deployment</name>
+  <name>Apache James Server Spring Deployment</name>
   <build>
   
     <plugins>
@@ -492,6 +492,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>james-server-spool-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>james-server-spoolmanager</artifactId>
     </dependency>
     <dependency>
@@ -537,6 +541,16 @@
     </dependency>
     <dependency>
       <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-file</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
+      <artifactId>apache-james-mailbox-jdbc</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.james</groupId>
       <artifactId>apache-james-imap-processor</artifactId>
       <scope>runtime</scope>
     </dependency>

Modified: james/server/trunk/user-api/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/user-api/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/user-api/pom.xml (original)
+++ james/server/trunk/user-api/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-user-api</artifactId>
-  <name>Apache JAMES Server User API</name>
+  <name>Apache James Server User API</name>
   <build>
     <plugins>
       <plugin>

Modified: james/server/trunk/user-function/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/user-function/pom.xml (original)
+++ james/server/trunk/user-function/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-user-function</artifactId>
-  <name>Apache JAMES Server User function</name>
+  <name>Apache James Server User function</name>
   
   <build>
     <plugins>
@@ -128,6 +128,11 @@
 
     <!-- Test dependencies -->
     <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.james</groupId>
       <artifactId>james-server-user-library</artifactId>
       <type>test-jar</type>
@@ -175,8 +180,9 @@
       <scope>runtime</scope>
     </dependency>
     <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
+      <groupId>org.apache.james</groupId>
+      <artifactId>james-server-core-library</artifactId>
+      <type>test-jar</type>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JpaUsersRepositoryTest.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JpaUsersRepositoryTest.java?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JpaUsersRepositoryTest.java (original)
+++ james/server/trunk/user-function/src/test/java/org/apache/james/userrepository/JpaUsersRepositoryTest.java Tue Sep 21 15:35:59 2010
@@ -21,12 +21,8 @@ package org.apache.james.userrepository;
 
 import java.util.HashMap;
 
-import javax.persistence.PersistenceException;
-
 import org.apache.commons.logging.impl.SimpleLog;
 import org.apache.james.api.user.UsersRepository;
-import org.apache.james.userrepository.JPAUsersRepository;
-import org.apache.james.userrepository.MockUsersRepositoryTest;
 import org.apache.james.userrepository.model.JPAUser;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
@@ -61,12 +57,11 @@ public class JpaUsersRepositoryTest exte
     private void deleteAll() {
         OpenJPAEntityManager manager = factory.createEntityManager();
         final OpenJPAEntityTransaction transaction = manager.getTransaction();
-        try
-        {
+        try {
             transaction.begin();
             manager.createQuery("DELETE FROM JamesUser user").executeUpdate();
             transaction.commit();
-        } catch (PersistenceException e) {
+        } catch (Exception e) {
             e.printStackTrace();
             if (transaction.isActive()) {
                 transaction.rollback();
@@ -77,8 +72,7 @@ public class JpaUsersRepositoryTest exte
     }
 
     @Override
-    protected UsersRepository getUsersRepository() throws Exception 
-    {
+    protected UsersRepository getUsersRepository() throws Exception  {
         factory = OpenJPAPersistence.getEntityManagerFactory(properties);
         JPAUsersRepository repos =  new JPAUsersRepository();
         repos.setLog(new SimpleLog("JPA"));

Modified: james/server/trunk/user-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/pom.xml?rev=999467&r1=999466&r2=999467&view=diff
==============================================================================
--- james/server/trunk/user-library/pom.xml (original)
+++ james/server/trunk/user-library/pom.xml Tue Sep 21 15:35:59 2010
@@ -26,7 +26,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-user-library</artifactId>
-  <name>Apache JAMES Server User Library</name>
+  <name>Apache James Server User Library</name>
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>



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