This is an automated email from the ASF dual-hosted git repository. jhelou pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit acb65b2dd14d41fc502daae969943e759c379a5a Author: Jean Helou <j...@xn--gml-cma.com> AuthorDate: Mon Mar 17 11:28:29 2025 +0100 [devscout] adds missing postgres guice modules for common data `SievePostgresRepositoryModules` exposed in `james-server-guice-sieve-postgres` needs `PostgresQuotaCurrentValueDAO` and `PostgresQuotaLimitDAO`. Before this commit - The quota `quota_limit` and `quota_current_value` tables were only created in the `PostgresQuotaModule` of `james-server-guice-mailbox-postgres` - `PostgresQuotaCurrentValueDAO` was only bound as a singleton in guice `PostgresQuotaModule` in `james-server-guice-mailbox-postgres`. - `PostgresQuotaLimitDao` was never bound explicitly to the SINGLETON scope. This commit introduces a dedicated guice module `PostgresQuotaGuiceModule` that : - ensures the quota tables are created if needed - binds both `PostgresQuotaCurrentValueDAO` and `PostgresQuotaLimitDao` to the singleton scope. it is not strictly necessary, but I don't think there is a good reason to create more than once instance of these classes. --- .../modules/mailbox/PostgresMailboxModule.java | 4 +- ...Module.java => PostgresMailboxQuotaModule.java} | 8 +--- .../modules/data/PostgresQuotaGuiceModule.java | 51 ++++++++++++++++++++++ 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java index f7fd1c2ed2..3a45ad0137 100644 --- a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java +++ b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxModule.java @@ -85,6 +85,7 @@ import org.apache.james.mailbox.store.mail.model.impl.MessageParser; import org.apache.james.mailbox.store.mail.model.impl.MessageParserImpl; import org.apache.james.mailbox.store.user.SubscriptionMapperFactory; import org.apache.james.modules.data.PostgresCommonModule; +import org.apache.james.modules.data.PostgresQuotaGuiceModule; import org.apache.james.user.api.DeleteUserDataTaskStep; import org.apache.james.user.api.UsernameChangeTaskStep; import org.apache.james.utils.MailboxManagerDefinition; @@ -107,7 +108,8 @@ public class PostgresMailboxModule extends AbstractModule { Multibinder<PostgresModule> postgresDataDefinitions = Multibinder.newSetBinder(binder(), PostgresModule.class); postgresDataDefinitions.addBinding().toInstance(PostgresMailboxAggregateModule.MODULE); - install(new PostgresQuotaModule()); + install(new PostgresQuotaGuiceModule()); + install(new PostgresMailboxQuotaModule()); bind(PostgresMailboxSessionMapperFactory.class).in(Scopes.SINGLETON); bind(PostgresMailboxManager.class).in(Scopes.SINGLETON); diff --git a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaModule.java b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxQuotaModule.java similarity index 88% rename from server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaModule.java rename to server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxQuotaModule.java index e1877269ae..1b624b97dc 100644 --- a/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresQuotaModule.java +++ b/server/container/guice/mailbox-postgres/src/main/java/org/apache/james/modules/mailbox/PostgresMailboxQuotaModule.java @@ -20,8 +20,6 @@ package org.apache.james.modules.mailbox; import org.apache.james.adapter.mailbox.UsersRepositoryUsernameSupplier; -import org.apache.james.backends.postgres.PostgresModule; -import org.apache.james.backends.postgres.quota.PostgresQuotaCurrentValueDAO; import org.apache.james.events.EventListener; import org.apache.james.mailbox.postgres.quota.PostgresCurrentQuotaManager; import org.apache.james.mailbox.postgres.quota.PostgresPerUserMaxQuotaManager; @@ -42,17 +40,13 @@ import com.google.inject.AbstractModule; import com.google.inject.Scopes; import com.google.inject.multibindings.Multibinder; -public class PostgresQuotaModule extends AbstractModule { +public class PostgresMailboxQuotaModule extends AbstractModule { @Override protected void configure() { - Multibinder<PostgresModule> postgresDataDefinitions = Multibinder.newSetBinder(binder(), PostgresModule.class); - postgresDataDefinitions.addBinding().toInstance(org.apache.james.backends.postgres.quota.PostgresQuotaModule.MODULE); - bind(DefaultUserQuotaRootResolver.class).in(Scopes.SINGLETON); bind(PostgresPerUserMaxQuotaManager.class).in(Scopes.SINGLETON); bind(StoreQuotaManager.class).in(Scopes.SINGLETON); - bind(PostgresQuotaCurrentValueDAO.class).in(Scopes.SINGLETON); bind(PostgresCurrentQuotaManager.class).in(Scopes.SINGLETON); bind(UserQuotaRootResolver.class).to(DefaultUserQuotaRootResolver.class); diff --git a/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresQuotaGuiceModule.java b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresQuotaGuiceModule.java new file mode 100644 index 0000000000..1df8435867 --- /dev/null +++ b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresQuotaGuiceModule.java @@ -0,0 +1,51 @@ +/**************************************************************** + * 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.backends.postgres.PostgresModule; +import org.apache.james.backends.postgres.quota.PostgresQuotaCurrentValueDAO; +import org.apache.james.backends.postgres.quota.PostgresQuotaLimitDAO; +import org.apache.james.domainlist.lib.DomainListConfiguration; +import org.apache.james.domainlist.postgres.PostgresDomainList; +import org.apache.james.utils.InitializationOperation; +import org.apache.james.utils.InitilizationOperationBuilder; + +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; +import com.google.inject.multibindings.Multibinder; +import com.google.inject.multibindings.ProvidesIntoSet; + +public class PostgresQuotaGuiceModule extends AbstractModule { + @Override + public void configure() { + bind(PostgresQuotaCurrentValueDAO.class).in(Scopes.SINGLETON); +// bind(PostgresQuotaLimitDAO.class).in(Scopes.SINGLETON); + + Multibinder<PostgresModule> postgresDataDefinitions = Multibinder.newSetBinder(binder(), PostgresModule.class); + postgresDataDefinitions.addBinding().toInstance(org.apache.james.backends.postgres.quota.PostgresQuotaModule.MODULE); + } + + @ProvidesIntoSet + InitializationOperation configureDomainList(DomainListConfiguration configuration, PostgresDomainList postgresDomainList) { + return InitilizationOperationBuilder + .forClass(PostgresDomainList.class) + .init(() -> postgresDomainList.configure(configuration)); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org