james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [6/7] james-project git commit: JAMES-2446 Avoid instanciating several time mapperFactory
Date Tue, 03 Jul 2018 08:51:44 GMT
JAMES-2446 Avoid instanciating several time mapperFactory

It leads to preparing several time Cassandra queries


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8992243e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8992243e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8992243e

Branch: refs/heads/master
Commit: 8992243e9f554e931ca6215d98490ab54683c952
Parents: 5a65aff
Author: benwa <btellier@linagora.com>
Authored: Sat Jun 30 19:52:01 2018 +0700
Committer: benwa <btellier@linagora.com>
Committed: Tue Jul 3 15:50:45 2018 +0700

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMapperProvider.java    | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8992243e/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index f8b772b..968d72d 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -50,12 +50,13 @@ public class CassandraMapperProvider implements MapperProvider {
     private final MessageUidProvider messageUidProvider;
     private final CassandraModSeqProvider cassandraModSeqProvider;
     private final MockMailboxSession mailboxSession = new MockMailboxSession("benwa");
-
+    private CassandraMailboxSessionMapperFactory mapperFactory;
 
     public CassandraMapperProvider(CassandraCluster cassandra) {
         this.cassandra = cassandra;
         messageUidProvider = new MessageUidProvider();
         cassandraModSeqProvider = new CassandraModSeqProvider(this.cassandra.getConf());
+        mapperFactory = createMapperFactory();
     }
 
     @Override
@@ -65,17 +66,17 @@ public class CassandraMapperProvider implements MapperProvider {
     
     @Override
     public MailboxMapper createMailboxMapper() throws MailboxException {
-        return createMapperFactory().getMailboxMapper(mailboxSession);
+        return mapperFactory.getMailboxMapper(mailboxSession);
     }
 
     @Override
     public MessageMapper createMessageMapper() throws MailboxException {
-        return createMapperFactory().getMessageMapper(mailboxSession);
+        return mapperFactory.getMessageMapper(mailboxSession);
     }
 
     @Override
     public MessageIdMapper createMessageIdMapper() throws MailboxException {
-        return createMapperFactory().getMessageIdMapper(mailboxSession);
+        return mapperFactory.getMessageIdMapper(mailboxSession);
     }
 
     private CassandraMailboxSessionMapperFactory createMapperFactory() {
@@ -85,8 +86,8 @@ public class CassandraMapperProvider implements MapperProvider {
     }
 
     @Override
-    public AttachmentMapper createAttachmentMapper() throws MailboxException {
-        return createMapperFactory().createAttachmentMapper(mailboxSession);
+    public AttachmentMapper createAttachmentMapper() {
+        return mapperFactory.createAttachmentMapper(mailboxSession);
     }
 
     @Override
@@ -95,7 +96,7 @@ public class CassandraMapperProvider implements MapperProvider {
     }
 
     @Override
-    public void clearMapper() throws MailboxException {
+    public void clearMapper() {
         cassandra.close();
     }
 
@@ -106,7 +107,7 @@ public class CassandraMapperProvider implements MapperProvider {
 
     @Override
     public AnnotationMapper createAnnotationMapper() throws MailboxException {
-        return createMapperFactory().getAnnotationMapper(mailboxSession);
+        return mapperFactory.getAnnotationMapper(mailboxSession);
     }
 
     @Override


---------------------------------------------------------------------
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