You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/02/07 02:25:49 UTC

(james-project) 03/05: JAMES-2586 Guice binding PostgresVacationRepository

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 18c7b91edb3c75b79246e337c3a4d44eb62cca7c
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Mon Feb 5 16:57:46 2024 +0700

    JAMES-2586 Guice binding PostgresVacationRepository
---
 .../org/apache/james/PostgresJamesServerMain.java  |  4 +-
 .../java/org/apache/james/PostgresJmapModule.java  | 14 ------
 .../james/modules/data/PostgresVacationModule.java | 56 ++++++++++++++++++++++
 3 files changed, 59 insertions(+), 15 deletions(-)

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 367148dcbe..1566076274 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
@@ -34,6 +34,7 @@ import org.apache.james.modules.data.PostgresDataJmapModule;
 import org.apache.james.modules.data.PostgresDataModule;
 import org.apache.james.modules.data.PostgresDelegationStoreModule;
 import org.apache.james.modules.data.PostgresUsersRepositoryModule;
+import org.apache.james.modules.data.PostgresVacationModule;
 import org.apache.james.modules.data.SievePostgresRepositoryModules;
 import org.apache.james.modules.event.JMAPEventBusModule;
 import org.apache.james.modules.event.RabbitMQEventBusModule;
@@ -114,7 +115,8 @@ public class PostgresJamesServerMain implements JamesServerMain {
         new TaskManagerModule(),
         new MemoryEventStoreModule(),
         new TikaMailboxModule(),
-        new PostgresDLPConfigurationStoreModule());
+        new PostgresDLPConfigurationStoreModule(),
+        new PostgresVacationModule());
 
     public static final Module JMAP = Modules.combine(
         new PostgresJmapModule(),
diff --git a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJmapModule.java b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJmapModule.java
index 9ca2329cbc..1952bfe181 100644
--- a/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJmapModule.java
+++ b/server/apps/postgres-app/src/main/java/org/apache/james/PostgresJmapModule.java
@@ -37,11 +37,6 @@ import org.apache.james.mailbox.RightManager;
 import org.apache.james.mailbox.store.StoreAttachmentManager;
 import org.apache.james.mailbox.store.StoreMessageIdManager;
 import org.apache.james.mailbox.store.StoreRightManager;
-import org.apache.james.vacation.api.NotificationRegistry;
-import org.apache.james.vacation.api.VacationRepository;
-import org.apache.james.vacation.api.VacationService;
-import org.apache.james.vacation.memory.MemoryNotificationRegistry;
-import org.apache.james.vacation.memory.MemoryVacationRepository;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Scopes;
@@ -65,15 +60,6 @@ public class PostgresJmapModule extends AbstractModule {
 
         bind(UploadUsageRepository.class).to(PostgresUploadUsageRepository.class);
 
-        bind(DefaultVacationService.class).in(Scopes.SINGLETON);
-        bind(VacationService.class).to(DefaultVacationService.class);
-
-        bind(MemoryNotificationRegistry.class).in(Scopes.SINGLETON);
-        bind(NotificationRegistry.class).to(MemoryNotificationRegistry.class);
-
-        bind(MemoryVacationRepository.class).in(Scopes.SINGLETON);
-        bind(VacationRepository.class).to(MemoryVacationRepository.class);
-
         bind(MessageIdManager.class).to(StoreMessageIdManager.class);
         bind(AttachmentManager.class).to(StoreAttachmentManager.class);
         bind(StoreMessageIdManager.class).in(Scopes.SINGLETON);
diff --git a/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresVacationModule.java b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresVacationModule.java
new file mode 100644
index 0000000000..a174054f0e
--- /dev/null
+++ b/server/container/guice/postgres-common/src/main/java/org/apache/james/modules/data/PostgresVacationModule.java
@@ -0,0 +1,56 @@
+/****************************************************************
+ * 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.DefaultVacationService;
+import org.apache.james.backends.postgres.PostgresModule;
+import org.apache.james.user.api.DeleteUserDataTaskStep;
+import org.apache.james.vacation.api.NotificationRegistry;
+import org.apache.james.vacation.api.VacationDeleteUserTaskStep;
+import org.apache.james.vacation.api.VacationRepository;
+import org.apache.james.vacation.api.VacationService;
+import org.apache.james.vacation.memory.MemoryNotificationRegistry;
+import org.apache.james.vacation.postgres.PostgresVacationRepository;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
+
+public class PostgresVacationModule extends AbstractModule {
+
+    @Override
+    public void configure() {
+        bind(DefaultVacationService.class).in(Scopes.SINGLETON);
+        bind(VacationService.class).to(DefaultVacationService.class);
+
+        bind(PostgresVacationRepository.class).in(Scopes.SINGLETON);
+        bind(VacationRepository.class).to(PostgresVacationRepository.class);
+
+        bind(MemoryNotificationRegistry.class).in(Scopes.SINGLETON);
+        bind(NotificationRegistry.class).to(MemoryNotificationRegistry.class);
+
+        Multibinder<PostgresModule> postgresVacationModules = Multibinder.newSetBinder(binder(), PostgresModule.class);
+        postgresVacationModules.addBinding().toInstance(org.apache.james.vacation.postgres.PostgresVacationModule.MODULE);
+
+        Multibinder<DeleteUserDataTaskStep> deleteUserDataTaskSteps = Multibinder.newSetBinder(binder(), DeleteUserDataTaskStep.class);
+        deleteUserDataTaskSteps.addBinding().to(VacationDeleteUserTaskStep.class);
+    }
+
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org