james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andr...@apache.org
Subject svn commit: r1478947 - in /james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching: ./ guava/
Date Fri, 03 May 2013 19:35:14 GMT
Author: andrzej
Date: Fri May  3 19:34:57 2013
New Revision: 1478947

URL: http://svn.apache.org/r1478947
Log:
[IMAP-373] small fixes and some comments

Modified:
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CacheInvalidatingMailboxListener.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxMapper.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxSessionMapperFactory.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMessageMapper.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxByPathCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxMetadataCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxByPathCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxMetadataCache.java

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CacheInvalidatingMailboxListener.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CacheInvalidatingMailboxListener.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CacheInvalidatingMailboxListener.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CacheInvalidatingMailboxListener.java
Fri May  3 19:34:57 2013
@@ -3,7 +3,11 @@ package org.apache.mailbox.caching;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxListenerSupport;
 import org.apache.james.mailbox.exception.MailboxException;
-
+/**
+ * A MailboxListener that invalidates the configured caches in response to Events
+ * 
+ * @param <Id>
+ */
 public class CacheInvalidatingMailboxListener<Id> implements MailboxListener {
 
 	private MailboxByPathCache<Id> mailboxCacheByPath;
@@ -14,6 +18,13 @@ public class CacheInvalidatingMailboxLis
 		this.mailboxMetadataCache = mailboxMetadataCache;
 	}
 	
+	/**
+	 * Used to register the CacheInvalidatingMailboxListener as a global listener 
+	 * into the main MailboxListener
+	 * 
+	 * @param listener
+	 * @throws MailboxException
+	 */
 	public void register(MailboxListenerSupport listener) throws MailboxException {
 		listener.addGlobalListener(this, null);
 	}

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxMapper.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxMapper.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxMapper.java
Fri May  3 19:34:57 2013
@@ -7,6 +7,12 @@ import org.apache.james.mailbox.model.Ma
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+/**
+ * A MailboxMapper implementation that uses a MailboxByPathCache to cache the information
+ * from the underlying MailboxMapper
+ * 
+ * @param <Id>
+ */
 
 public class CachingMailboxMapper<Id> implements MailboxMapper<Id> {
 
@@ -36,7 +42,7 @@ public class CachingMailboxMapper<Id> im
 
 	@Override
 	public void delete(Mailbox<Id> mailbox) throws MailboxException {
-		cache.invalidate(mailbox);
+		invalidate(mailbox);
 		underlying.delete(mailbox);
 	}
 
@@ -62,7 +68,7 @@ public class CachingMailboxMapper<Id> im
 	public boolean hasChildren(Mailbox<Id> mailbox, char delimiter)
 			throws MailboxException, MailboxNotFoundException {
 		// TODO possible to meaningfully cache it?
-		return hasChildren(mailbox, delimiter);
+		return underlying.hasChildren(mailbox, delimiter);
 	}
 
 	@Override

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxSessionMapperFactory.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxSessionMapperFactory.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMailboxSessionMapperFactory.java
Fri May  3 19:34:57 2013
@@ -8,6 +8,13 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
+/**
+ * A MailboxSessionMapperFactory that uses the underlying MailboxSessionMapperFactory to
provide
+ * caching variants of MessageMapper and MailboxMapper built around the MessageMapper and
MailboxMapper
+ * provided by it
+ * 
+ * @param <Id>
+ */
 public class CachingMailboxSessionMapperFactory<Id> extends
 		MailboxSessionMapperFactory<Id> {
 
@@ -24,14 +31,13 @@ public class CachingMailboxSessionMapper
 	@Override
 	public MessageMapper<Id> createMessageMapper(MailboxSession session)
 			throws MailboxException {
-		return new CachingMessageMapper<Id>(underlying.createMessageMapper(session), mailboxByPathCache);
+		return new CachingMessageMapper<Id>(underlying.createMessageMapper(session), mailboxMetadataCache);
 	}
 
 	@Override
 	public MailboxMapper<Id> createMailboxMapper(MailboxSession session)
 			throws MailboxException {
-	    //TODO(eric) this cast will not work!!! Temporary adding it to compile the project...
-		return (MailboxMapper<Id>) new CachingMessageMapper<Id>(underlying.createMailboxMapper(session),
mailboxMetadataCache);
+		return new CachingMailboxMapper<Id>(underlying.createMailboxMapper(session), mailboxByPathCache);
 	}
 
 	@Override

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMessageMapper.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMessageMapper.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/CachingMessageMapper.java
Fri May  3 19:34:57 2013
@@ -9,12 +9,18 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.UpdatedFlags;
-import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.Message;
 
+/**
+ * A MessageMapper implementation that uses a MailboxMetadataCache to cache the information
+ * from the underlying MessageMapper
+ * 
+ * @param <Id>
+ */
 public class CachingMessageMapper<Id> implements MessageMapper<Id> {
+
 	
 	private MessageMapper<Id> underlying;
 	private MailboxMetadataCache<Id> cache;
@@ -24,15 +30,7 @@ public class CachingMessageMapper<Id> im
 		this.cache = cache;
 	}
 	
-    public CachingMessageMapper(MessageMapper<Id> createMessageMapper, MailboxByPathCache<Id>
mailboxByPathCache) {
-        // TODO(eric) Auto-generated constructor stub
-    }
-
-    public CachingMessageMapper(MailboxMapper<Id> mailboxMapper, MailboxMetadataCache<Id>
mailboxMetadataCache) {
-        // TODO(eric) Auto-generated constructor stub
-    }
-
-    @Override
+	@Override
 	public void endRequest() {
 		underlying.endRequest();
 	}

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxByPathCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxByPathCache.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxByPathCache.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxByPathCache.java
Fri May  3 19:34:57 2013
@@ -6,6 +6,11 @@ import org.apache.james.mailbox.model.Ma
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+/**
+ * Caches the MailboxPath -> Mailbox mapping
+ * 
+ * @param <Id>
+ */
 public interface MailboxByPathCache<Id> {
 
 	public abstract Mailbox<Id> findMailboxByPath(MailboxPath mailboxName,

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxMetadataCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxMetadataCache.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxMetadataCache.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/MailboxMetadataCache.java
Fri May  3 19:34:57 2013
@@ -4,6 +4,12 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
+/**
+ * Caches the simple yet possibly expensive to compute metadata info 
+ * about a Mailbox like all/unseen messages count and similar
+ * 
+ * @param <Id>
+ */
 public interface MailboxMetadataCache<Id> {
 
 	public abstract long countMessagesInMailbox(Mailbox<Id> mailbox,

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxByPathCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxByPathCache.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxByPathCache.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxByPathCache.java
Fri May  3 19:34:57 2013
@@ -9,12 +9,20 @@ import org.apache.mailbox.caching.Mailbo
 
 import com.google.common.cache.Cache;
 
+/**
+ * Guava-based implementation of MailboxByPathCache.
+ * Note: for efficiency/simplicity reasons the cache key is MailboxPath.toString()
+ * That may help also make it compatible with other cache backends in the future.
+ *
+ * @param <Id>
+ */
 public class GuavaMailboxByPathCache<Id> extends AbstractGuavaCache implements MailboxByPathCache<Id>
{
 	
 	private final Cache<String, Mailbox<Id>> findMailboxByPathCache = BUILDER.build();
 
 	private final MailboxByPathCacheWrapper wrapper;
 
+	
 	public GuavaMailboxByPathCache() {
 		this.wrapper = new MailboxByPathCacheWrapper(findMailboxByPathCache);
 	}

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxMetadataCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxMetadataCache.java?rev=1478947&r1=1478946&r2=1478947&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxMetadataCache.java
(original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/mailbox/caching/guava/GuavaMailboxMetadataCache.java
Fri May  3 19:34:57 2013
@@ -6,6 +6,12 @@ import org.apache.james.mailbox.store.ma
 import org.apache.mailbox.caching.MailboxMetadataCache;
 
 import com.google.common.cache.Cache;
+/**
+ * Guava-based implementation of MailboxMetadataCache.
+ * Note: for efficiency/simplicity reasons the cache key is Mailbox.getMailboxId()
+ *
+ * @param <Id>
+ */
 
 public class GuavaMailboxMetadataCache<Id> extends AbstractGuavaCache implements MailboxMetadataCache<Id>
{
 



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


Mime
View raw message