You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/12/02 16:12:54 UTC

svn commit: r1041402 [2/2] - in /james/imap/trunk: jcr/src/main/java/org/apache/james/mailbox/jcr/ jcr/src/main/java/org/apache/james/mailbox/jcr/mail/ jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/ jcr/src/test/java/org/apache/james/mailbo...

Modified: james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java?rev=1041402&r1=1041401&r2=1041402&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java Thu Dec  2 15:12:51 2010
@@ -31,7 +31,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 import java.util.TreeMap;
-import java.util.concurrent.atomic.AtomicLong;
 
 import javax.mail.Flags;
 import javax.mail.MessagingException;
@@ -68,12 +67,12 @@ public abstract class StoreMessageManage
     
     private final MailboxEventDispatcher dispatcher;    
     
-    private final AtomicLong lastUid;
+    protected final UidProvider<Id> uidProvider;
     
-    public StoreMessageManager(final AtomicLong lastUid, final MailboxEventDispatcher dispatcher, final Mailbox<Id> mailbox) throws MailboxException {
+    public StoreMessageManager(final UidProvider<Id> uidProvider, final MailboxEventDispatcher dispatcher, final Mailbox<Id> mailbox) throws MailboxException {
         this.mailbox = mailbox;
         this.dispatcher = dispatcher;
-        this.lastUid = lastUid;
+        this.uidProvider = uidProvider;
     }
     
     
@@ -373,7 +372,7 @@ public abstract class StoreMessageManage
         final List<Long> recent = recent(resetRecent, mailboxSession);
         final Flags permanentFlags = getPermanentFlags();
         final long uidValidity = getMailboxEntity().getUidValidity();
-        final long uidNext = lastUid.get() +1;
+        final long uidNext = uidProvider.lastUid(mailboxSession, mailbox) +1;
         final long messageCount = getMessageCount(mailboxSession);
         final long unseenCount;
         final Long firstUnseen;

Added: james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/UidProvider.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/UidProvider.java?rev=1041402&view=auto
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/UidProvider.java (added)
+++ james/imap/trunk/store/src/main/java/org/apache/james/mailbox/store/UidProvider.java Thu Dec  2 15:12:51 2010
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.mailbox.store;
+
+import org.apache.james.mailbox.MailboxException;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+
+/**
+ * Take care of provide uids for a given {@link Mailbox}
+ * 
+ *
+ * @param <Id>
+ */
+public interface UidProvider<Id> {
+
+    /**
+     * Return the next uid which can be used while append a Message to the {@link Mailbox}.
+     * Its important that the returned uid is higher then the last used and that the next call of this method does not return the same uid. 
+     * 
+     * @param session
+     * @param mailbox
+     * @return nextUid
+     * @throws MailboxException
+     */
+    public long nextUid(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException;
+    
+    /**
+     * Return the last uid which were used for storing a Message in the {@link Mailbox}
+     * 
+     * @param session
+     * @param mailbox
+     * @return lastUid
+     * @throws MailboxException
+     */
+    public long lastUid(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException;
+}



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