This is an automated email from the ASF dual-hosted git repository. rcordier pushed a commit to branch postgresql in repository https://gitbox.apache.org/repos/asf/james-project.git
commit b3c0cfbce1d735b83bed97992e2feaa9dc5a4fc9 Author: Quan Tran <[email protected]> AuthorDate: Tue Nov 28 15:58:11 2023 +0700 JAMES-2586 Guice binding for SieveQuotaRepository backed by Postgres --- .../quota/PostgresQuotaCurrentValueDAO.java | 7 ++- .../postgres/quota/PostgresQuotaLimitDAO.java | 4 +- pom.xml | 11 +++++ server/apps/postgres-app/pom.xml | 2 +- .../org/apache/james/PostgresJamesServerMain.java | 4 +- server/container/guice/pom.xml | 6 +++ server/container/guice/sieve-postgres/pom.xml | 53 ++++++++++++++++++++++ .../data/SievePostgresRepositoryModules.java | 37 +++++++++++++++ .../sieve/postgres/PostgresSieveQuotaDAO.java | 3 ++ 9 files changed, 122 insertions(+), 5 deletions(-) diff --git a/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaCurrentValueDAO.java b/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaCurrentValueDAO.java index 8f5c7eea6c..70b471a117 100644 --- a/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaCurrentValueDAO.java +++ b/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaCurrentValueDAO.java @@ -25,9 +25,13 @@ import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.Postg import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaCurrentValueTable.PRIMARY_KEY_CONSTRAINT_NAME; import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaCurrentValueTable.TABLE_NAME; import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaCurrentValueTable.TYPE; +import static org.apache.james.backends.postgres.utils.PostgresExecutor.DEFAULT_INJECT; import java.util.function.Function; +import javax.inject.Inject; +import javax.inject.Named; + import org.apache.james.backends.postgres.utils.PostgresExecutor; import org.apache.james.core.quota.QuotaComponent; import org.apache.james.core.quota.QuotaCurrentValue; @@ -44,7 +48,8 @@ public class PostgresQuotaCurrentValueDAO { private final PostgresExecutor postgresExecutor; - public PostgresQuotaCurrentValueDAO(PostgresExecutor postgresExecutor) { + @Inject + public PostgresQuotaCurrentValueDAO(@Named(DEFAULT_INJECT) PostgresExecutor postgresExecutor) { this.postgresExecutor = postgresExecutor; } diff --git a/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaLimitDAO.java b/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaLimitDAO.java index ff17e94841..ee851a75d9 100644 --- a/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaLimitDAO.java +++ b/backends-common/postgres/src/main/java/org/apache/james/backends/postgres/quota/PostgresQuotaLimitDAO.java @@ -26,8 +26,10 @@ import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.Postg import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaLimitTable.QUOTA_SCOPE; import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaLimitTable.QUOTA_TYPE; import static org.apache.james.backends.postgres.quota.PostgresQuotaModule.PostgresQuotaLimitTable.TABLE_NAME; +import static org.apache.james.backends.postgres.utils.PostgresExecutor.DEFAULT_INJECT; import javax.inject.Inject; +import javax.inject.Named; import org.apache.james.backends.postgres.utils.PostgresExecutor; import org.apache.james.core.quota.QuotaComponent; @@ -45,7 +47,7 @@ public class PostgresQuotaLimitDAO { private final PostgresExecutor postgresExecutor; @Inject - public PostgresQuotaLimitDAO(PostgresExecutor postgresExecutor) { + public PostgresQuotaLimitDAO(@Named(DEFAULT_INJECT) PostgresExecutor postgresExecutor) { this.postgresExecutor = postgresExecutor; } diff --git a/pom.xml b/pom.xml index cec1d1216c..3541398be6 100644 --- a/pom.xml +++ b/pom.xml @@ -1562,6 +1562,17 @@ <version>${project.version}</version> <type>test-jar</type> </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-guice-sieve-postgres</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-guice-sieve-postgres</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + </dependency> <dependency> <groupId>${james.groupId}</groupId> <artifactId>james-server-guice-smtp</artifactId> diff --git a/server/apps/postgres-app/pom.xml b/server/apps/postgres-app/pom.xml index 66e4105cfa..3ce2ab8e59 100644 --- a/server/apps/postgres-app/pom.xml +++ b/server/apps/postgres-app/pom.xml @@ -125,7 +125,7 @@ </dependency> <dependency> <groupId>${james.groupId}</groupId> - <artifactId>james-server-guice-sieve-jpa</artifactId> + <artifactId>james-server-guice-sieve-postgres</artifactId> </dependency> <dependency> <groupId>${james.groupId}</groupId> diff --git a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java index 7c5f47c086..8ecba40bb7 100644 --- a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java +++ b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJamesServerMain.java @@ -25,7 +25,7 @@ import org.apache.james.modules.MailetProcessingModule; import org.apache.james.modules.RunArgumentsModule; import org.apache.james.modules.data.PostgresDataModule; import org.apache.james.modules.data.PostgresUsersRepositoryModule; -import org.apache.james.modules.data.SieveJPARepositoryModules; +import org.apache.james.modules.data.SievePostgresRepositoryModules; import org.apache.james.modules.mailbox.DefaultEventModule; import org.apache.james.modules.mailbox.JPAMailboxModule; import org.apache.james.modules.mailbox.LuceneSearchMailboxModule; @@ -89,7 +89,7 @@ public class PostgresJamesServerMain implements JamesServerMain { new LuceneSearchMailboxModule(), new NoJwtModule(), new RawPostDequeueDecoratorModule(), - new SieveJPARepositoryModules(), + new SievePostgresRepositoryModules(), new DefaultEventModule(), new TaskManagerModule(), new MemoryDeadLetterModule()); diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml index 40a437596f..96b681617a 100644 --- a/server/container/guice/pom.xml +++ b/server/container/guice/pom.xml @@ -79,6 +79,7 @@ <module>queue/rabbitmq</module> <module>sieve-file</module> <module>sieve-jpa</module> + <module>sieve-postgres</module> <module>testing</module> <module>utils</module> </modules> @@ -192,6 +193,11 @@ <artifactId>james-server-guice-sieve-jpa</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-guice-sieve-postgres</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>${james.groupId}</groupId> <artifactId>james-server-guice-smtp</artifactId> diff --git a/server/container/guice/sieve-postgres/pom.xml b/server/container/guice/sieve-postgres/pom.xml new file mode 100644 index 0000000000..512875ef11 --- /dev/null +++ b/server/container/guice/sieve-postgres/pom.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.apache.james</groupId> + <artifactId>james-server-guice</artifactId> + <version>3.9.0-SNAPSHOT</version> + </parent> + + <artifactId>james-server-guice-sieve-postgres</artifactId> + <packaging>jar</packaging> + + <name>Apache James :: Server :: Guice :: Sieve :: Postgres</name> + <description>Sieve Postgres modules for Guice implementation of James server</description> + + <dependencies> + <dependency> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-data-postgres</artifactId> + </dependency> + <dependency> + <!-- Added because of https://issues.apache.org/jira/browse/SUREFIRE-1266 --> + <groupId>${james.groupId}</groupId> + <artifactId>james-server-testing</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + </dependency> + </dependencies> + +</project> diff --git a/server/container/guice/sieve-postgres/src/main/java/org/apache/james/modules/data/SievePostgresRepositoryModules.java b/server/container/guice/sieve-postgres/src/main/java/org/apache/james/modules/data/SievePostgresRepositoryModules.java new file mode 100644 index 0000000000..b2784c6be7 --- /dev/null +++ b/server/container/guice/sieve-postgres/src/main/java/org/apache/james/modules/data/SievePostgresRepositoryModules.java @@ -0,0 +1,37 @@ +/**************************************************************** + * 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.data; + +import org.apache.james.sieve.postgres.PostgresSieveRepository; +import org.apache.james.sieverepository.api.SieveQuotaRepository; +import org.apache.james.sieverepository.api.SieveRepository; + +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; + +public class SievePostgresRepositoryModules extends AbstractModule { + @Override + protected void configure() { + bind(PostgresSieveRepository.class).in(Scopes.SINGLETON); + + bind(SieveRepository.class).to(PostgresSieveRepository.class); + bind(SieveQuotaRepository.class).to(PostgresSieveRepository.class); + } +} diff --git a/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/PostgresSieveQuotaDAO.java b/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/PostgresSieveQuotaDAO.java index dff7d4ef71..dd894cb911 100644 --- a/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/PostgresSieveQuotaDAO.java +++ b/server/data/data-postgres/src/main/java/org/apache/james/sieve/postgres/PostgresSieveQuotaDAO.java @@ -23,6 +23,8 @@ import static org.apache.james.core.quota.QuotaType.SIZE; import java.util.Optional; +import javax.inject.Inject; + import org.apache.james.backends.postgres.quota.PostgresQuotaCurrentValueDAO; import org.apache.james.backends.postgres.quota.PostgresQuotaLimitDAO; import org.apache.james.core.Username; @@ -41,6 +43,7 @@ public class PostgresSieveQuotaDAO { private final PostgresQuotaCurrentValueDAO currentValueDao; private final PostgresQuotaLimitDAO limitDao; + @Inject public PostgresSieveQuotaDAO(PostgresQuotaCurrentValueDAO currentValueDao, PostgresQuotaLimitDAO limitDao) { this.currentValueDao = currentValueDao; this.limitDao = limitDao; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
