Author: norman
Date: Wed Aug 4 12:12:34 2010
New Revision: 982230
URL: http://svn.apache.org/viewvc?rev=982230&view=rev
Log:
Remove unneeded synchronized statements and some cleanup
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/UidToMsnConverter.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
Modified:
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/UidToMsnConverter.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/UidToMsnConverter.java?rev=982230&r1=982229&r2=982230&view=diff
==============================================================================
---
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/UidToMsnConverter.java
(original)
+++
james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/base/UidToMsnConverter.java
Wed Aug 4 12:12:34 2010
@@ -51,19 +51,20 @@ public class UidToMsnConverter implement
highestUid = uid.longValue();
highestMsn = msn;
- final Integer msnInteger = new Integer(msn);
- msnToUid.put(msnInteger, uid);
- uidToMsn.put(uid, msnInteger);
+ msnToUid.put(msn, uid);
+ uidToMsn.put(uid, msn);
+
msn++;
}
+
}
}
- public synchronized long getUid(int msn) {
+ public long getUid(int msn) {
if (msn == -1) {
return -1;
}
- Long uid = msnToUid.get(new Integer(msn));
+ Long uid = msnToUid.get(msn);
if (uid != null) {
return uid.longValue();
} else {
@@ -75,8 +76,8 @@ public class UidToMsnConverter implement
}
}
- public synchronized int getMsn(long uid) {
- Integer msn = (Integer) uidToMsn.get(new Long(uid));
+ public int getMsn(long uid) {
+ Integer msn = uidToMsn.get(uid);
if (msn != null) {
return msn.intValue();
} else {
@@ -85,17 +86,15 @@ public class UidToMsnConverter implement
}
- private synchronized void add(int msn, long uid) {
+ private void add(int msn, long uid) {
if (uid > highestUid) {
highestUid = uid;
}
- final Integer msnInteger = new Integer(msn);
- final Long uidLong = new Long(uid);
- msnToUid.put(msnInteger, uidLong);
- uidToMsn.put(uidLong, msnInteger);
+ msnToUid.put(msn, uid);
+ uidToMsn.put(uid, msn);
}
- public synchronized void expunge(final long uid) {
+ public void expunge(final long uid) {
final int msn = getMsn(uid);
remove(msn, uid);
final List<Integer> renumberMsns = new ArrayList<Integer>(msnToUid
@@ -110,11 +109,11 @@ public class UidToMsnConverter implement
}
private void remove(int msn, long uid) {
- uidToMsn.remove(new Long(uid));
- msnToUid.remove(new Integer(msn));
+ uidToMsn.remove(uid);
+ msnToUid.remove(msn);
}
- public synchronized void add(long uid) {
+ public void add(long uid) {
if (!uidToMsn.containsKey(new Long(uid))) {
highestMsn++;
add(highestMsn, uid);
Modified:
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java?rev=982230&r1=982229&r2=982230&view=diff
==============================================================================
---
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
(original)
+++
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
Wed Aug 4 12:12:34 2010
@@ -94,18 +94,7 @@ public abstract class StoreMailboxManage
*/
public org.apache.james.imap.mailbox.Mailbox getMailbox(MailboxPath
mailboxPath, MailboxSession session)
throws MailboxException {
- return doGetMailbox(mailboxPath, session);
- }
-
- /**
- * Get the Mailbox for the given name. If none is found a MailboxException
will get thrown
- *
- * @param mailboxPath the name of the mailbox to return
- * @return mailbox the mailbox for the given name
- * @throws MailboxException get thrown if no Mailbox could be found for
the given name
- */
- private StoreMessageManager<Id> doGetMailbox(MailboxPath mailboxPath,
MailboxSession session) throws MailboxException {
- final MailboxMapper<Id> mapper =
mailboxSessionMapperFactory.getMailboxMapper(session);
+ final MailboxMapper<Id> mapper =
mailboxSessionMapperFactory.getMailboxMapper(session);
Mailbox<Id> mailboxRow = mapper.findMailboxByPath(mailboxPath);
if (mailboxRow == null) {
@@ -240,9 +229,10 @@ public abstract class StoreMailboxManage
* (non-Javadoc)
* @see
org.apache.james.imap.mailbox.MailboxManager#copyMessages(org.apache.james.imap.mailbox.MessageRange,
org.apache.james.imap.api.MailboxPath, org.apache.james.imap.api.MailboxPath,
org.apache.james.imap.mailbox.MailboxSession)
*/
- public void copyMessages(MessageRange set, MailboxPath from, MailboxPath
to, MailboxSession session) throws MailboxException {
- StoreMessageManager<Id> toMailbox = doGetMailbox(to, session);
- StoreMessageManager<Id> fromMailbox = doGetMailbox(from, session);
+ @SuppressWarnings("unchecked")
+ public void copyMessages(MessageRange set, MailboxPath from,
MailboxPath to, MailboxSession session) throws MailboxException {
+ StoreMessageManager<Id> toMailbox = (StoreMessageManager<Id>)
getMailbox(to, session);
+ StoreMessageManager<Id> fromMailbox = (StoreMessageManager<Id>)
getMailbox(from, session);
fromMailbox.copyTo(set, toMailbox, session);
}
Modified:
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java?rev=982230&r1=982229&r2=982230&view=diff
==============================================================================
---
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
(original)
+++
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMessageManager.java
Wed Aug 4 12:12:34 2010
@@ -361,7 +361,7 @@ public abstract class StoreMessageManage
public Iterator<MessageResult> getMessages(final MessageRange set,
FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
final List<MailboxMembership<Id>> rows =
messageMapper.findInMailbox(mailbox, set);
- return new ResultIterator<Id>(rows, fetchGroup);
+ return new ResultIterator<Id>(rows.iterator(), fetchGroup);
}
@@ -425,13 +425,8 @@ public abstract class StoreMessageManage
* (non-Javadoc)
* @see
org.apache.james.imap.mailbox.Mailbox#expunge(org.apache.james.imap.mailbox.MessageRange,
org.apache.james.imap.mailbox.MailboxSession)
*/
- public Iterator<Long> expunge(MessageRange set, MailboxSession
mailboxSession) throws MailboxException {
- return doExpunge(set, mailboxSession);
- }
-
- private Iterator<Long> doExpunge(final MessageRange set, MailboxSession
mailboxSession)
- throws MailboxException {
- final Collection<Long> uids = new TreeSet<Long>();
+ public Iterator<Long> expunge(final MessageRange set, MailboxSession
mailboxSession) throws MailboxException {
+ final Collection<Long> uids = new TreeSet<Long>();
messageMapper.execute(new TransactionalMapper.Transaction() {
@@ -449,21 +444,16 @@ public abstract class StoreMessageManage
while(uidIt.hasNext()) {
dispatcher.expunged(uidIt.next(), mailboxSession.getSessionId(),
new StoreMailboxPath<Id>(getMailboxEntity()));
}
- return uids.iterator();
+ return uids.iterator();
}
/*
* (non-Javadoc)
* @see org.apache.james.imap.mailbox.Mailbox#setFlags(javax.mail.Flags,
boolean, boolean, org.apache.james.imap.mailbox.MessageRange,
org.apache.james.imap.mailbox.MailboxSession)
*/
- public Map<Long, Flags> setFlags(Flags flags, boolean value, boolean
replace,
- MessageRange set, MailboxSession mailboxSession) throws
MailboxException {
- return doSetFlags(flags, value, replace, set, mailboxSession);
- }
-
- private Map<Long, Flags> doSetFlags(final Flags flags, final boolean
value, final boolean replace,
- final MessageRange set, final MailboxSession mailboxSession)
throws MailboxException {
- final SortedMap<Long, Flags> newFlagsByUid = new TreeMap<Long,
Flags>();
+ public Map<Long, Flags> setFlags(final Flags flags, final boolean value,
final boolean replace,
+ final MessageRange set, MailboxSession mailboxSession) throws
MailboxException {
+ final SortedMap<Long, Flags> newFlagsByUid = new TreeMap<Long, Flags>();
final Map<Long, Flags> originalFlagsByUid = new HashMap<Long,
Flags>(INITIAL_SIZE_FLAGS);
messageMapper.execute(new TransactionalMapper.Transaction(){
@@ -498,6 +488,7 @@ public abstract class StoreMessageManage
return newFlagsByUid;
}
+
public void addListener(MailboxListener listener) throws MailboxException {
dispatcher.addMailboxListener(listener);
}
@@ -532,10 +523,7 @@ public abstract class StoreMessageManage
uids.add(member.getUid());
}
} catch (MailboxException e) {
- mailboxSession.getLog()
- .info(
- "Cannot test message against search criteria. Will
continue to test other messages.",
- e);
+ mailboxSession.getLog().info("Cannot test message against
search criteria. Will continue to test other messages.", e);
if (mailboxSession.getLog().isDebugEnabled())
mailboxSession.getLog().debug("UID: " + member.getUid());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]