JAMES-2537 Guice bindings for CassandraMailQueueViewConfiguration

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

Branch: refs/heads/master
Commit: 0ec5ccccaf826d5a08f7f4d1af3879246b529df5
Parents: 8f9a990
Author: Benoit Tellier <[email protected]>
Authored: Thu Nov 22 11:28:49 2018 +0700
Committer: Benoit Tellier <[email protected]>
Committed: Thu Nov 22 11:28:49 2018 +0700

----------------------------------------------------------------------
 .../james/modules/rabbitmq/RabbitMQModule.java  | 26 ++++++++++++--------
 1 file changed, 16 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0ec5cccc/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java
 
b/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java
index 9f45f19..5d42930 100644
--- 
a/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java
+++ 
b/server/container/guice/rabbitmq/src/main/java/org/apache/james/modules/rabbitmq/RabbitMQModule.java
@@ -20,9 +20,9 @@ package org.apache.james.modules.rabbitmq;
 
 import java.io.FileNotFoundException;
 import java.time.Clock;
-import java.time.Duration;
 import java.util.concurrent.ThreadLocalRandom;
 
+import javax.inject.Named;
 import javax.inject.Singleton;
 
 import org.apache.commons.configuration.Configuration;
@@ -65,12 +65,6 @@ public class RabbitMQModule extends AbstractModule {
     protected void configure() {
         bind(Clock.class).toInstance(Clock.systemUTC());
         bind(ThreadLocalRandom.class).toInstance(ThreadLocalRandom.current());
-        
bind(CassandraMailQueueViewConfiguration.class).toInstance(CassandraMailQueueViewConfiguration
-                .builder()
-                .bucketCount(1)
-                .updateBrowseStartPace(1000)
-                .sliceWindow(Duration.ofHours(1))
-                .build());
 
         bind(EnqueuedMailsDAO.class).in(Scopes.SINGLETON);
         bind(DeletedMailsDAO.class).in(Scopes.SINGLETON);
@@ -104,14 +98,26 @@ public class RabbitMQModule extends AbstractModule {
     }
 
     @Provides
+    @Named(RABBITMQ_CONFIGURATION_NAME)
     @Singleton
-    private RabbitMQConfiguration getMailQueueConfiguration(PropertiesProvider 
propertiesProvider) throws ConfigurationException {
+    private Configuration getConfiguration(PropertiesProvider 
propertiesProvider) throws ConfigurationException {
         try {
-            Configuration configuration = 
propertiesProvider.getConfiguration(RABBITMQ_CONFIGURATION_NAME);
-            return RabbitMQConfiguration.from(configuration);
+            return 
propertiesProvider.getConfiguration(RABBITMQ_CONFIGURATION_NAME);
         } catch (FileNotFoundException e) {
             LOGGER.error("Could not find " + RABBITMQ_CONFIGURATION_NAME + " 
configuration file.");
             throw new RuntimeException(e);
         }
     }
+
+    @Provides
+    @Singleton
+    private RabbitMQConfiguration 
getMailQueueConfiguration(@Named(RABBITMQ_CONFIGURATION_NAME) Configuration 
configuration) {
+        return RabbitMQConfiguration.from(configuration);
+    }
+
+    @Provides
+    @Singleton
+    private CassandraMailQueueViewConfiguration 
getMailQueueViewConfiguration(@Named(RABBITMQ_CONFIGURATION_NAME) Configuration 
configuration) {
+        return CassandraMailQueueViewConfiguration.from(configuration);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to