You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2017/03/31 01:47:21 UTC
[05/11] james-project git commit: MAILBOX-291 Allow to configure
CurrentQuotaManager to use JPA with Spring
MAILBOX-291 Allow to configure CurrentQuotaManager to use JPA with Spring
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4fdd56a3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4fdd56a3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4fdd56a3
Branch: refs/heads/master
Commit: 4fdd56a3bcf68ad283142054cecd61534d770484
Parents: b62c413
Author: benwa <bt...@linagora.com>
Authored: Wed Mar 29 18:47:11 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Mar 31 08:46:25 2017 +0700
----------------------------------------------------------------------
.../run/spring/destination/conf/META-INF/persistence.xml | 1 +
.../james/mailbox/jpa/quota/JpaCurrentQuotaManager.java | 2 ++
.../jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml | 7 ++++++-
server/app/src/main/resources/META-INF/persistence.xml | 1 +
server/app/src/main/resources/quota-template.xml | 1 +
.../factorypostprocessor/QuotaBeanFactoryPostProcessor.java | 2 ++
server/src/site/xdoc/config-quota.xml | 4 ++--
7 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/dockerfiles/run/spring/destination/conf/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/dockerfiles/run/spring/destination/conf/META-INF/persistence.xml b/dockerfiles/run/spring/destination/conf/META-INF/persistence.xml
index 1459879..4518416 100644
--- a/dockerfiles/run/spring/destination/conf/META-INF/persistence.xml
+++ b/dockerfiles/run/spring/destination/conf/META-INF/persistence.xml
@@ -39,6 +39,7 @@
<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)"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
index 1223d9c..29482c9 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/quota/JpaCurrentQuotaManager.java
@@ -19,6 +19,7 @@
package org.apache.james.mailbox.jpa.quota;
+import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -39,6 +40,7 @@ public class JpaCurrentQuotaManager implements StoreCurrentQuotaManager {
private final EntityManager entityManager;
+ @Inject
public JpaCurrentQuotaManager(EntityManagerFactory entityManagerFactory) {
this.entityManager = entityManagerFactory.createEntityManager();
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
index 7572873..f8d4dd0 100644
--- a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
+++ b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml
@@ -90,5 +90,10 @@
<bean id="jpa-mailbox-id-deserializer" class="org.apache.james.mailbox.jpa.JPAMailboxIdDeserializer"/>
- <bean id="jpaMaxQuotaManager" class="org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaManager"/>
+ <bean id="jpaMaxQuotaManager" class="org.apache.james.mailbox.jpa.quota.JPAPerUserMaxQuotaManager">
+ <constructor-arg index="0" ref="entityManagerFactory"/>
+ </bean>
+ <bean id="jpaCurrentQuotaManager" class="org.apache.james.mailbox.jpa.quota.JpaCurrentQuotaManager">
+ <constructor-arg index="0" ref="entityManagerFactory"/>
+ </bean>
</beans>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/server/app/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/server/app/src/main/resources/META-INF/persistence.xml b/server/app/src/main/resources/META-INF/persistence.xml
index 0bf3a18..63285ad 100644
--- a/server/app/src/main/resources/META-INF/persistence.xml
+++ b/server/app/src/main/resources/META-INF/persistence.xml
@@ -39,6 +39,7 @@
<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)"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/server/app/src/main/resources/quota-template.xml
----------------------------------------------------------------------
diff --git a/server/app/src/main/resources/quota-template.xml b/server/app/src/main/resources/quota-template.xml
index e2c4340..9c8c63e 100644
--- a/server/app/src/main/resources/quota-template.xml
+++ b/server/app/src/main/resources/quota-template.xml
@@ -60,6 +60,7 @@
- none: when you use fake as a value for quotaManager's provider
- inmemory
- cassandra
+ - jpa
The inmemory implementation:
- Does not work in a distributed context
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/QuotaBeanFactoryPostProcessor.java
----------------------------------------------------------------------
diff --git a/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/QuotaBeanFactoryPostProcessor.java b/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/QuotaBeanFactoryPostProcessor.java
index 46f8e9a..9d6257e 100644
--- a/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/QuotaBeanFactoryPostProcessor.java
+++ b/server/container/spring/src/main/java/org/apache/james/container/spring/bean/factorypostprocessor/QuotaBeanFactoryPostProcessor.java
@@ -107,6 +107,8 @@ public class QuotaBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
registry.registerAlias("inMemoryCurrentQuotaManager", CURRENT_QUOTA_MANAGER);
} else if (currentQuotaManager.equalsIgnoreCase(CASSANDRA)) {
registry.registerAlias("cassandraCurrentQuotaManager", CURRENT_QUOTA_MANAGER);
+ } else if (currentQuotaManager.equalsIgnoreCase(JPA)) {
+ registry.registerAlias("jpaCurrentQuotaManager", CURRENT_QUOTA_MANAGER);
} else if (! currentQuotaManager.equalsIgnoreCase("none")) {
throw new FatalBeanException("Unreadable value for Current Quota Manager : " + currentQuotaManager);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4fdd56a3/server/src/site/xdoc/config-quota.xml
----------------------------------------------------------------------
diff --git a/server/src/site/xdoc/config-quota.xml b/server/src/site/xdoc/config-quota.xml
index 676eca5..f8e88da 100644
--- a/server/src/site/xdoc/config-quota.xml
+++ b/server/src/site/xdoc/config-quota.xml
@@ -57,8 +57,8 @@
configuration to be persistent. We provide some other implementation: A Cassandra implementation allows to store maximum quota values in Cassandra,
and a JPA implementation.</li>
<li>Current Quota Manager : This component can be omitted if you are running a fake QUOTA manager. inmemory implementation is an event updated cache on
- top of a Quota calculator (that fetches every e-mail metadata of every mailboxes belonging to the QUOTA ROOT: it is expensive). A cassandra implementation
- is also available.</li>
+ top of a Quota calculator (that fetches every e-mail metadata of every mailboxes belonging to the QUOTA ROOT: it is expensive). Cassandra and Jpa implementations
+ are also available.</li>
<li>Quota Updater : This components allows to update current quota values. A fake implementation is available. A real, event base solution also exists.</li>
</ul>
</p>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org