JAMES-1961 Binding quota implementation with Guice

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

Branch: refs/heads/master
Commit: fce7b92ba9e30377bea297deb6618ccf7d17bb28
Parents: 3fe5b70
Author: benwa <btell...@linagora.com>
Authored: Thu Mar 16 14:02:18 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Tue Mar 21 10:00:42 2017 +0700

----------------------------------------------------------------------
 .../apache/james/CassandraJamesServerMain.java  |  2 -
 .../modules/mailbox/CassandraMailboxModule.java | 17 +++++-
 .../modules/mailbox/CassandraQuotaModule.java   | 55 ++++++++++++++++++++
 .../modules/mailbox/DefaultQuotaModule.java     | 45 ++++++++++++++++
 .../james/modules/server/QuotaModule.java       | 38 --------------
 .../org/apache/james/JPAJamesServerMain.java    |  2 -
 .../james/modules/mailbox/JPAMailboxModule.java |  2 +
 .../org/apache/james/MemoryJamesServerMain.java |  2 -
 .../modules/mailbox/MemoryMailboxModule.java    | 10 +++-
 .../modules/mailbox/MemoryQuotaModule.java      | 50 ++++++++++++++++++
 10 files changed, 177 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index 3282fe5..289106b 100644
--- 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -38,7 +38,6 @@ import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
 import org.apache.james.modules.server.ESMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
-import org.apache.james.modules.server.QuotaModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -65,7 +64,6 @@ public class CassandraJamesServerMain {
         new CassandraMailboxModule(),
         new CassandraSessionModule(),
         new ElasticSearchMailboxModule(),
-        new QuotaModule(),
         new ActiveMQQueueModule(),
         new ESMetricReporterModule(),
         new MailboxModule());

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 1ba4213..310704c 100644
--- 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -39,9 +39,16 @@ import 
org.apache.james.mailbox.cassandra.mail.CassandraMessageIdDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdToImapUidDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
+import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
+import 
org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
+import org.apache.james.mailbox.cassandra.table.CassandraCurrentQuota;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.quota.CurrentQuotaManager;
+import org.apache.james.mailbox.quota.MaxQuotaManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
@@ -54,6 +61,9 @@ import 
org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.UidProvider;
+import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
+import org.apache.james.mailbox.store.quota.StoreQuotaManager;
 import org.apache.james.modules.Names;
 import org.apache.james.utils.MailboxManagerDefinition;
 
@@ -69,6 +79,7 @@ public class CassandraMailboxModule extends AbstractModule {
     @Override
     protected void configure() {
         install(new DefaultEventModule());
+        install(new CassandraQuotaModule());
 
         bind(Integer.class)
             
.annotatedWith(com.google.inject.name.Names.named(CassandraMailboxDAO.MAX_ACL_RETRY))
@@ -130,7 +141,11 @@ public class CassandraMailboxModule extends AbstractModule 
{
     }
 
     @Provides @Named(Names.MAILBOXMANAGER_NAME) @Singleton
-    public MailboxManager provideMailboxManager(CassandraMailboxManager 
cassandraMailboxManager) throws MailboxException {
+    public MailboxManager provideMailboxManager(CassandraMailboxManager 
cassandraMailboxManager, ListeningCurrentQuotaUpdater quotaUpdater,
+                                                QuotaManager quotaManager, 
QuotaRootResolver quotaRootResolver) throws MailboxException {
+        cassandraMailboxManager.setQuotaUpdater(quotaUpdater);
+        cassandraMailboxManager.setQuotaManager(quotaManager);
+        cassandraMailboxManager.setQuotaRootResolver(quotaRootResolver);
         cassandraMailboxManager.init();
         return cassandraMailboxManager;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
new file mode 100644
index 0000000..75d49a3
--- /dev/null
+++ 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraQuotaModule.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.modules.mailbox;
+
+import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.mailbox.cassandra.quota.CassandraCurrentQuotaManager;
+import 
org.apache.james.mailbox.cassandra.quota.CassandraPerUserMaxQuotaManager;
+import org.apache.james.mailbox.quota.CurrentQuotaManager;
+import org.apache.james.mailbox.quota.MaxQuotaManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
+import org.apache.james.mailbox.store.quota.StoreQuotaManager;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
+
+public class CassandraQuotaModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
+        bind(CassandraPerUserMaxQuotaManager.class).in(Scopes.SINGLETON);
+        bind(StoreQuotaManager.class).in(Scopes.SINGLETON);
+        bind(CassandraCurrentQuotaManager.class).in(Scopes.SINGLETON);
+
+        bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class);
+        bind(MaxQuotaManager.class).to(CassandraPerUserMaxQuotaManager.class);
+        bind(QuotaManager.class).to(StoreQuotaManager.class);
+        bind(CurrentQuotaManager.class).to(CassandraCurrentQuotaManager.class);
+        
bind(StoreCurrentQuotaManager.class).to(CassandraCurrentQuotaManager.class);
+
+        Multibinder<CassandraModule> cassandraDataDefinitions = 
Multibinder.newSetBinder(binder(), CassandraModule.class);
+        
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraQuotaModule.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
new file mode 100644
index 0000000..41be7ea
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/mailbox/DefaultQuotaModule.java
@@ -0,0 +1,45 @@
+/****************************************************************
+ * 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.modules.mailbox;
+
+import org.apache.james.mailbox.quota.MaxQuotaManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.NoMaxQuotaManager;
+import org.apache.james.mailbox.store.quota.NoQuotaManager;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+
+public class DefaultQuotaModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(NoQuotaManager.class).in(Scopes.SINGLETON);
+        bind(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
+        bind(NoMaxQuotaManager.class).in(Scopes.SINGLETON);
+
+        bind(MaxQuotaManager.class).to(NoMaxQuotaManager.class);
+        bind(QuotaManager.class).to(NoQuotaManager.class);
+        bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
deleted file mode 100644
index 659434d..0000000
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/****************************************************************
- * 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.modules.server;
-
-import org.apache.james.mailbox.quota.QuotaManager;
-import org.apache.james.mailbox.quota.QuotaRootResolver;
-import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
-import org.apache.james.mailbox.store.quota.NoQuotaManager;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-
-public class QuotaModule extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        bind(QuotaManager.class).to(NoQuotaManager.class).in(Scopes.SINGLETON);
-        
bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index 4514fba..19a8430 100644
--- 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -33,7 +33,6 @@ import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.ActiveMQQueueModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.NoJwtModule;
-import org.apache.james.modules.server.QuotaModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
@@ -55,7 +54,6 @@ public class JPAJamesServerMain {
         new JPAMailboxModule(),
         new JPADataModule(),
         new SieveFileRepositoryModule(),
-        new QuotaModule(),
         new ActiveMQQueueModule(),
         new RawPostDequeueDecoratorModule(),
         new MailboxModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index 4feba2f..b530eb3 100644
--- 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -71,6 +71,8 @@ public class JPAMailboxModule extends AbstractModule {
 
     @Override
     protected void configure() {
+        install(new DefaultQuotaModule());
+
         bind(JPAMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
         bind(OpenJPAMailboxManager.class).in(Scopes.SINGLETON);
         bind(JVMMailboxPathLocker.class).in(Scopes.SINGLETON);

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index ab47e0f..0cf291c 100644
--- 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -32,7 +32,6 @@ import 
org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MemoryMailQueueModule;
-import org.apache.james.modules.server.QuotaModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -52,7 +51,6 @@ public class MemoryJamesServerMain {
             new MemoryDataModule(),
             new MemoryDataJmapModule(),
             new MemoryMailboxModule(),
-            new QuotaModule(),
             new MemoryMailQueueModule(),
             new MailboxModule());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index 5716639..7b1de77 100644
--- 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -44,6 +44,8 @@ import 
org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider;
 import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
 import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.Authorizator;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
@@ -56,6 +58,7 @@ import 
org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.UidProvider;
+import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;
 import org.apache.james.mailbox.store.search.SimpleMessageSearchIndex;
 import org.apache.james.mailbox.store.user.SubscriptionMapperFactory;
@@ -71,6 +74,7 @@ public class MemoryMailboxModule extends AbstractModule {
     @Override
     protected void configure() {
         install(new DefaultEventModule());
+        install(new MemoryQuotaModule());
 
         
bind(MessageMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
         
bind(MailboxMapperFactory.class).to(InMemoryMailboxSessionMapperFactory.class);
@@ -113,7 +117,11 @@ public class MemoryMailboxModule extends AbstractModule {
     }
 
     @Provides @Named(Names.MAILBOXMANAGER_NAME) @Singleton
-    public MailboxManager provideMailboxManager(InMemoryMailboxManager 
mailboxManager) throws MailboxException {
+    public MailboxManager provideMailboxManager(InMemoryMailboxManager 
mailboxManager, ListeningCurrentQuotaUpdater quotaUpdater,
+                                                QuotaManager quotaManager, 
QuotaRootResolver quotaRootResolver) throws MailboxException {
+        mailboxManager.setQuotaRootResolver(quotaRootResolver);
+        mailboxManager.setQuotaManager(quotaManager);
+        mailboxManager.setQuotaUpdater(quotaUpdater);
         mailboxManager.init();
         return mailboxManager;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/fce7b92b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
new file mode 100644
index 0000000..b180b27
--- /dev/null
+++ 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryQuotaModule.java
@@ -0,0 +1,50 @@
+/****************************************************************
+ * 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.modules.mailbox;
+
+import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
+import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
+import org.apache.james.mailbox.quota.CurrentQuotaManager;
+import org.apache.james.mailbox.quota.MaxQuotaManager;
+import org.apache.james.mailbox.quota.QuotaManager;
+import org.apache.james.mailbox.quota.QuotaRootResolver;
+import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver;
+import org.apache.james.mailbox.store.quota.StoreCurrentQuotaManager;
+import org.apache.james.mailbox.store.quota.StoreQuotaManager;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+
+public class MemoryQuotaModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
+        bind(InMemoryPerUserMaxQuotaManager.class).in(Scopes.SINGLETON);
+        bind(StoreQuotaManager.class).in(Scopes.SINGLETON);
+        bind(InMemoryCurrentQuotaManager.class).in(Scopes.SINGLETON);
+
+        bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class);
+        bind(MaxQuotaManager.class).to(InMemoryPerUserMaxQuotaManager.class);
+        bind(QuotaManager.class).to(StoreQuotaManager.class);
+        bind(CurrentQuotaManager.class).to(InMemoryCurrentQuotaManager.class);
+        
bind(StoreCurrentQuotaManager.class).to(InMemoryCurrentQuotaManager.class);
+    }
+}


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

Reply via email to