MAILBOX-291 Adding support for quotas into JPA Guice project

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

Branch: refs/heads/master
Commit: 8e4e162e2a5f98a6e4e0cbda4db3879c4f5f6374
Parents: 51c198a
Author: benwa <[email protected]>
Authored: Wed Mar 29 20:32:44 2017 +0700
Committer: benwa <[email protected]>
Committed: Fri Mar 31 08:46:26 2017 +0700

----------------------------------------------------------------------
 .../james/modules/mailbox/JPAMailboxModule.java |  2 +-
 .../james/modules/mailbox/JpaQuotaModule.java   | 50 ++++++++++++++++++++
 .../src/main/resources/META-INF/persistence.xml |  8 ++++
 3 files changed, 59 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8e4e162e/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 b530eb3..83c147f 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,7 +71,7 @@ public class JPAMailboxModule extends AbstractModule {
 
     @Override
     protected void configure() {
-        install(new DefaultQuotaModule());
+        install(new JpaQuotaModule());
 
         bind(JPAMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
         bind(OpenJPAMailboxManager.class).in(Scopes.SINGLETON);

http://git-wip-us.apache.org/repos/asf/james-project/blob/8e4e162e/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.java
new file mode 100644
index 0000000..f85cec7
--- /dev/null
+++ 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JpaQuotaModule.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.jpa.quota.JPAPerUserMaxQuotaManager;
+import org.apache.james.mailbox.jpa.quota.JpaCurrentQuotaManager;
+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 JpaQuotaModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON);
+        bind(JPAPerUserMaxQuotaManager.class).in(Scopes.SINGLETON);
+        bind(StoreQuotaManager.class).in(Scopes.SINGLETON);
+        bind(JpaCurrentQuotaManager.class).in(Scopes.SINGLETON);
+
+        bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class);
+        bind(MaxQuotaManager.class).to(JPAPerUserMaxQuotaManager.class);
+        bind(QuotaManager.class).to(StoreQuotaManager.class);
+        bind(CurrentQuotaManager.class).to(JpaCurrentQuotaManager.class);
+        bind(StoreCurrentQuotaManager.class).to(JpaCurrentQuotaManager.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/8e4e162e/server/container/guice/jpa-guice/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/main/resources/META-INF/persistence.xml 
b/server/container/guice/jpa-guice/src/main/resources/META-INF/persistence.xml
index 24a8d67..25a8596 100644
--- 
a/server/container/guice/jpa-guice/src/main/resources/META-INF/persistence.xml
+++ 
b/server/container/guice/jpa-guice/src/main/resources/META-INF/persistence.xml
@@ -30,9 +30,17 @@
         
<class>org.apache.james.mailbox.jpa.mail.model.openjpa.JPAMailboxMessage</class>
         <class>org.apache.james.mailbox.jpa.mail.model.JPAProperty</class>
         <class>org.apache.james.mailbox.jpa.user.model.JPASubscription</class>
+
         <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
         <class>org.apache.james.user.jpa.model.JPAUser</class>
         <class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
+
+        
<class>org.apache.james.mailbox.jpa.quota.model.MaxDefaultMessageCount</class>
+        
<class>org.apache.james.mailbox.jpa.quota.model.MaxDefaultStorage</class>
+        
<class>org.apache.james.mailbox.jpa.quota.model.MaxUserMessageCount</class>
+        <class>org.apache.james.mailbox.jpa.quota.model.MaxUserStorage</class>
+        <class>org.apache.james.mailbox.jpa.quota.model.JpaCurrentQuota</class>
+
         <properties>
             <property name="openjpa.jdbc.SynchronizeMappings" 
value="buildSchema(ForeignKeys=true)"/>
             <property name="openjpa.jdbc.MappingDefaults" 
value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>


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

Reply via email to