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 2011/10/05 15:32:45 UTC
svn commit: r1179217 - in
/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store:
AbstractMailboxSessionIdGenerator.java RandomMailboxSessionIdGenerator.java
Author: norman
Date: Wed Oct 5 13:32:45 2011
New Revision: 1179217
URL: http://svn.apache.org/viewvc?rev=1179217&view=rev
Log:
Add new MailboxSessionIdGenerator interface and an implementation which use Random under the hood. This allows to have a distributed id generator if needed. This also fixes the problem with generated MailboxSession ids that returned 0L before. See MAILBOX-149
Added:
james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java (with props)
Modified:
james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/RandomMailboxSessionIdGenerator.java
Added: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java?rev=1179217&view=auto
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java (added)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java Wed Oct 5 13:32:45 2011
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox.store;
+
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxSessionIdGenerator;
+
+public abstract class AbstractMailboxSessionIdGenerator implements MailboxSessionIdGenerator {
+
+ @Override
+ public long nextId() {
+ long id;
+ while ((id = generateNextId()) == MailboxSession.SYSTEM_SESSION_ID) {
+ // loop till the id is not 0L
+ //
+ // See also MAILBOX-149
+ }
+ return id;
+ }
+
+
+ protected abstract long generateNextId();
+
+
+}
Propchange: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/AbstractMailboxSessionIdGenerator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/RandomMailboxSessionIdGenerator.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/RandomMailboxSessionIdGenerator.java?rev=1179217&r1=1179216&r2=1179217&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/RandomMailboxSessionIdGenerator.java (original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/RandomMailboxSessionIdGenerator.java Wed Oct 5 13:32:45 2011
@@ -21,7 +21,6 @@ package org.apache.james.mailbox.store;
import java.util.Random;
-import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSessionIdGenerator;
@@ -30,18 +29,12 @@ import org.apache.james.mailbox.MailboxS
*
*
*/
-public class RandomMailboxSessionIdGenerator implements MailboxSessionIdGenerator {
+public class RandomMailboxSessionIdGenerator extends AbstractMailboxSessionIdGenerator {
private final static Random RANDOM = new Random();
@Override
- public long nextId() {
- long id;
- while ((id = RANDOM.nextLong()) == MailboxSession.SYSTEM_SESSION_ID) {
- // loop till the id is not 0L
- //
- // See also MAILBOX-149
- }
- return id;
+ protected long generateNextId() {
+ return RANDOM.nextLong();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org