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 9edaf85cf0ef2334c602dc2e3458eb915e9c0219
Author: Jean Helou <[email protected]>
AuthorDate: Wed Oct 5 22:34:15 2022 +0200

    [JAMES-3836] implements guice bindings for BlobMailRepository
    
    Note that `BlobMailRepository` cannot be loaded through the 
`GuiceMailRepositoryLoader` since it doesn't take a MailRepositoryUrl as a 
constructor argument.
    This is why the BlobMailRepositoryModule provides the proper factory 
binding for use with the `MultiBoundGuiceMailRepositoryLoader`. The use of this 
binding is demonstrated in `scaling-pulsar-smtp`.
---
 .../src/test/resources/mailetcontainer.xml         |  6 +-
 .../src/test/resources/mailrepositorystore.xml     |  4 +-
 pom.xml                                            |  5 ++
 server/apps/scaling-pulsar-smtp/pom.xml            | 26 ++++++-
 .../apache/james/MailStoreRepositoryModule.java    | 82 ++++++++++++++++++++++
 .../src/main/java/org/apache/james/Main.java       | 23 ++++--
 .../org/apache/james/AwsS3BlobStoreExtension.java  | 50 +++++++++++++
 .../java/org/apache/james/SMTPJamesServerTest.java |  5 +-
 ...sitorystore.xml => backmailrepositorystore.xml} |  4 +-
 .../src/test/resources/mailetcontainer.xml         |  6 +-
 server/container/guice/mailrepository-blob/pom.xml | 75 ++++++++++++++++++++
 .../BlobstoreMailRepositoryModule.java             | 56 +++++++++++++++
 server/container/guice/pom.xml                     |  6 ++
 13 files changed, 331 insertions(+), 17 deletions(-)

diff --git 
a/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailetcontainer.xml 
b/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailetcontainer.xml
index 7c58ed05de..b917304627 100644
--- a/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailetcontainer.xml
+++ b/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailetcontainer.xml
@@ -43,7 +43,7 @@
             <mailet match="All" class="Bounce">
             </mailet>
             <mailet match="All" class="ToRepository">
-                <repositoryPath>cassandra://var/mail/error/</repositoryPath>
+                <repositoryPath>blob://var/mail/error/</repositoryPath>
             </mailet>
         </processor>
 
@@ -82,7 +82,7 @@
                 <attachment>none</attachment>
             </mailet>
             <mailet match="All" class="ToRepository">
-                
<repositoryPath>cassandra://var/mail/relay-denied/</repositoryPath>
+                <repositoryPath>blob://var/mail/relay-denied/</repositoryPath>
                 <notice>Warning: You are sending an e-mail to a remote server. 
You must be authentified to perform such an operation</notice>
             </mailet>
         </processor>
@@ -95,7 +95,7 @@
 
         <processor state="rrt-error" enableJmx="false">
             <mailet match="All" class="ToRepository">
-                
<repositoryPath>cassandra://var/mail/rrt-error/</repositoryPath>
+                <repositoryPath>blob://var/mail/rrt-error/</repositoryPath>
                 <passThrough>true</passThrough>
             </mailet>
             <mailet match="IsSenderInRRTLoop" class="Null"/>
diff --git 
a/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailrepositorystore.xml 
b/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailrepositorystore.xml
index 626e0a2bad..aeefa1800a 100644
--- a/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailrepositorystore.xml
+++ b/mpt/impl/smtp/cassandra-pulsar/src/test/resources/mailrepositorystore.xml
@@ -21,9 +21,9 @@
 
 <mailrepositorystore>
     <mailrepositories>
-        <mailrepository 
class="org.apache.james.mailrepository.cassandra.CassandraMailRepository">
+        <mailrepository 
class="org.apache.james.mailrepository.blob.BlobMailRepository">
             <protocols>
-                <protocol>cassandra</protocol>
+                <protocol>blob</protocol>
             </protocols>
         </mailrepository>
     </mailrepositories>
diff --git a/pom.xml b/pom.xml
index 924aa9a607..2e3a071080 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1651,6 +1651,11 @@
                 <version>${project.version}</version>
                 <type>test-jar</type>
             </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
+                <artifactId>james-server-mailrepository-blob</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
                 <artifactId>james-server-mailrepository-cassandra</artifactId>
diff --git a/server/apps/scaling-pulsar-smtp/pom.xml 
b/server/apps/scaling-pulsar-smtp/pom.xml
index 7d252fd457..27d409a555 100644
--- a/server/apps/scaling-pulsar-smtp/pom.xml
+++ b/server/apps/scaling-pulsar-smtp/pom.xml
@@ -17,7 +17,8 @@
     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/maven-v4_0_0.xsd";>
+<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/maven-v4_0_0.xsd";>
 
     <modelVersion>4.0.0</modelVersion>
 
@@ -84,6 +85,25 @@
             <artifactId>blob-cassandra</artifactId>
             <version>${project.version}</version>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>blob-s3</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>blob-s3-guice</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>blob-s3-guice</artifactId>
+            <version>${project.version}</version>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>data-cassandra</artifactId>
@@ -135,6 +155,10 @@
             <groupId>${james.groupId}</groupId>
             <artifactId>james-server-util</artifactId>
         </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>mailrepository-blob</artifactId>
+        </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>mailrepository-cassandra</artifactId>
diff --git 
a/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/MailStoreRepositoryModule.java
 
b/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/MailStoreRepositoryModule.java
new file mode 100644
index 0000000000..5dca08152a
--- /dev/null
+++ 
b/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/MailStoreRepositoryModule.java
@@ -0,0 +1,82 @@
+/****************************************************************
+ * 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;
+
+import javax.inject.Provider;
+
+import org.apache.commons.configuration2.HierarchicalConfiguration;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.commons.configuration2.tree.ImmutableNode;
+import org.apache.james.mailrepository.api.MailRepositoryLoader;
+import org.apache.james.mailrepository.api.MailRepositoryStore;
+import org.apache.james.mailrepository.memory.MailRepositoryStoreConfiguration;
+import org.apache.james.mailrepository.memory.MemoryMailRepositoryStore;
+import 
org.apache.james.modules.mailrepository.guice.MultiBoundGuiceRepositoryLoader;
+import org.apache.james.server.core.configuration.ConfigurationProvider;
+import org.apache.james.utils.GuiceProbe;
+import org.apache.james.utils.InitializationOperation;
+import org.apache.james.utils.InitilizationOperationBuilder;
+import org.apache.james.utils.MailRepositoryProbeImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.multibindings.ProvidesIntoSet;
+
+public class MailStoreRepositoryModule extends AbstractModule {
+    public static final Logger LOGGER = 
LoggerFactory.getLogger(MailStoreRepositoryModule.class);
+
+    @Override
+    protected void configure() {
+        bind(MemoryMailRepositoryStore.class).in(Scopes.SINGLETON);
+        bind(MailRepositoryStore.class).to(MemoryMailRepositoryStore.class);
+
+        bind(MultiBoundGuiceRepositoryLoader.class).in(Scopes.SINGLETON);
+        
bind(MailRepositoryLoader.class).to(MultiBoundGuiceRepositoryLoader.class);
+
+        Multibinder.newSetBinder(binder(), 
GuiceProbe.class).addBinding().to(MailRepositoryProbeImpl.class);
+    }
+
+    @Provides
+    @Singleton
+    MailRepositoryStoreConfiguration 
provideConfiguration(ConfigurationProvider configurationProvider,
+                                                          
Provider<MailRepositoryStoreConfiguration.Item> defaultConfigurationItem)
+        throws ConfigurationException {
+
+        HierarchicalConfiguration<ImmutableNode> configuration = 
configurationProvider.getConfiguration("mailrepositorystore");
+        MailRepositoryStoreConfiguration userConfiguration = 
MailRepositoryStoreConfiguration.parse(configuration);
+        if (!userConfiguration.getItems().isEmpty()) {
+            return userConfiguration;
+        }
+        LOGGER.warn("Empty MailRepository store configuration supplied. 
Defaulting to default configuration for this product");
+        return 
MailRepositoryStoreConfiguration.forItems(defaultConfigurationItem.get());
+    }
+
+    @ProvidesIntoSet
+    InitializationOperation startMailStore(MemoryMailRepositoryStore instance) 
{
+        return InitilizationOperationBuilder
+            .forClass(MemoryMailRepositoryStore.class)
+            .init(instance::init);
+    }
+}
diff --git 
a/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/Main.java 
b/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/Main.java
index 0ae4fc6146..0239611a07 100644
--- a/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/Main.java
+++ b/server/apps/scaling-pulsar-smtp/src/main/java/org/apache/james/Main.java
@@ -19,19 +19,22 @@
 
 package org.apache.james;
 
+import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.blob.api.BlobStore;
 import org.apache.james.blob.api.BlobStoreDAO;
 import org.apache.james.blob.api.BucketName;
 import org.apache.james.blob.api.MetricableBlobStore;
 import org.apache.james.blob.cassandra.CassandraBlobStoreDAO;
-import org.apache.james.modules.MailetProcessingModule;
+import org.apache.james.mailrepository.api.MailRepositoryUrlStore;
+import 
org.apache.james.mailrepository.cassandra.CassandraMailRepositoryUrlModule;
+import 
org.apache.james.mailrepository.cassandra.CassandraMailRepositoryUrlStore;
 import org.apache.james.modules.data.CassandraDomainListModule;
 import org.apache.james.modules.data.CassandraRecipientRewriteTableModule;
 import org.apache.james.modules.data.CassandraUsersRepositoryModule;
 import org.apache.james.modules.mailbox.BlobStoreAPIModule;
 import org.apache.james.modules.mailbox.CassandraBlobStoreDependenciesModule;
 import org.apache.james.modules.mailbox.CassandraSessionModule;
-import org.apache.james.modules.mailrepository.CassandraMailRepositoryModule;
+import org.apache.james.modules.mailrepository.BlobstoreMailRepositoryModule;
 import org.apache.james.modules.metrics.CassandraMetricsModule;
 import org.apache.james.modules.protocols.ProtocolHandlerModule;
 import org.apache.james.modules.protocols.SMTPServerModule;
@@ -39,6 +42,7 @@ import org.apache.james.modules.server.DataRoutesModules;
 import 
org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
 import org.apache.james.modules.server.MailQueueRoutesModule;
 import org.apache.james.modules.server.MailRepositoriesRoutesModule;
+import org.apache.james.modules.server.MailetContainerModule;
 import org.apache.james.modules.server.NoJwtModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
 import org.apache.james.modules.server.TaskManagerModule;
@@ -48,6 +52,7 @@ import 
org.apache.james.server.blob.deduplication.PassThroughBlobStore;
 
 import com.google.inject.Module;
 import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
 import com.google.inject.name.Names;
 import com.google.inject.util.Modules;
 
@@ -86,13 +91,21 @@ public class Main implements JamesServerMain {
     );
 
     public static final Module SERVER_CORE_MODULES = Modules.combine(
-            new MailetProcessingModule(),
             new DefaultProcessorsConfigurationProviderModule(),
             new CassandraSessionModule(),
+            new MailStoreRepositoryModule(),
+            new MailetContainerModule(),
+            new BlobstoreMailRepositoryModule(),
+            binder -> {
+                
binder.bind(MailRepositoryUrlStore.class).to(CassandraMailRepositoryUrlStore.class).in(Scopes.SINGLETON);
+            },
+            binder -> {
+                Multibinder<CassandraModule> cassandraModuleBinder = 
Multibinder.newSetBinder(binder, CassandraModule.class);
+                
cassandraModuleBinder.addBinding().toInstance(CassandraMailRepositoryUrlModule.MODULE);
+            },
             new CassandraDomainListModule(),
             new CassandraRecipientRewriteTableModule(),
             new CassandraUsersRepositoryModule(),
-            new CassandraMailRepositoryModule(),
             new CassandraMetricsModule(),
             new TaskManagerModule()
     );
@@ -110,6 +123,6 @@ public class Main implements JamesServerMain {
 
     public static GuiceJamesServer createServer(SMTPRelayConfiguration 
configuration) {
         return GuiceJamesServer.forConfiguration(configuration)
-                .combineWith(SERVER_CORE_MODULES, BLOB_MODULE, QUEUE_MODULES, 
PROTOCOLS,WEBADMIN);
+                .combineWith(SERVER_CORE_MODULES, BLOB_MODULE, QUEUE_MODULES, 
PROTOCOLS, WEBADMIN);
     }
 }
diff --git 
a/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/AwsS3BlobStoreExtension.java
 
b/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/AwsS3BlobStoreExtension.java
new file mode 100644
index 0000000000..9cfd69a792
--- /dev/null
+++ 
b/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/AwsS3BlobStoreExtension.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;
+
+import org.apache.james.GuiceModuleTestExtension;
+import org.apache.james.blob.objectstorage.aws.DockerAwsS3Singleton;
+import org.apache.james.modules.objectstorage.aws.s3.DockerAwsS3TestRule;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import com.google.inject.Module;
+
+public class AwsS3BlobStoreExtension implements GuiceModuleTestExtension {
+
+    private final DockerAwsS3TestRule awsS3TestRule;
+
+    public AwsS3BlobStoreExtension() {
+        this.awsS3TestRule = new DockerAwsS3TestRule();
+    }
+
+    @Override
+    public void beforeAll(ExtensionContext extensionContext) {
+        ensureAwsS3started();
+    }
+
+    private void ensureAwsS3started() {
+        DockerAwsS3Singleton.singleton.dockerAwsS3();
+    }
+
+    @Override
+    public Module getModule() {
+        return awsS3TestRule.getModule();
+    }
+}
diff --git 
a/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/SMTPJamesServerTest.java
 
b/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/SMTPJamesServerTest.java
index ecc07391b6..7f1a573c2a 100644
--- 
a/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/SMTPJamesServerTest.java
+++ 
b/server/apps/scaling-pulsar-smtp/src/test/java/org/apache/james/SMTPJamesServerTest.java
@@ -26,7 +26,9 @@ import java.net.InetSocketAddress;
 import java.nio.ByteBuffer;
 import java.nio.channels.SocketChannel;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
+import org.apache.james.modules.AwsS3BlobStoreExtension;
 import org.apache.james.modules.protocols.SmtpGuiceProbe;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -39,6 +41,7 @@ class SMTPJamesServerTest {
         .extension(new DockerOpenSearchExtension())
         .extension(new CassandraExtension())
         .extension(new PulsarExtension())
+        .extension(new AwsS3BlobStoreExtension())
         .server(Main::createServer)
         .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
         .build();
@@ -56,6 +59,6 @@ class SMTPJamesServerTest {
         ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
         socketChannel.read(byteBuffer);
         byte[] bytes = byteBuffer.array();
-        return new String(bytes, Charset.forName("UTF-8"));
+        return new String(bytes, StandardCharsets.UTF_8);
     }
 }
diff --git 
a/server/apps/scaling-pulsar-smtp/src/test/resources/mailrepositorystore.xml 
b/server/apps/scaling-pulsar-smtp/src/test/resources/backmailrepositorystore.xml
similarity index 87%
rename from 
server/apps/scaling-pulsar-smtp/src/test/resources/mailrepositorystore.xml
rename to 
server/apps/scaling-pulsar-smtp/src/test/resources/backmailrepositorystore.xml
index 626e0a2bad..aeefa1800a 100644
--- a/server/apps/scaling-pulsar-smtp/src/test/resources/mailrepositorystore.xml
+++ 
b/server/apps/scaling-pulsar-smtp/src/test/resources/backmailrepositorystore.xml
@@ -21,9 +21,9 @@
 
 <mailrepositorystore>
     <mailrepositories>
-        <mailrepository 
class="org.apache.james.mailrepository.cassandra.CassandraMailRepository">
+        <mailrepository 
class="org.apache.james.mailrepository.blob.BlobMailRepository">
             <protocols>
-                <protocol>cassandra</protocol>
+                <protocol>blob</protocol>
             </protocols>
         </mailrepository>
     </mailrepositories>
diff --git 
a/server/apps/scaling-pulsar-smtp/src/test/resources/mailetcontainer.xml 
b/server/apps/scaling-pulsar-smtp/src/test/resources/mailetcontainer.xml
index 9c41a9fcd2..725c113d2a 100644
--- a/server/apps/scaling-pulsar-smtp/src/test/resources/mailetcontainer.xml
+++ b/server/apps/scaling-pulsar-smtp/src/test/resources/mailetcontainer.xml
@@ -43,7 +43,7 @@
             <mailet match="All" class="Bounce">
             </mailet>
             <mailet match="All" class="ToRepository">
-                <repositoryPath>cassandra://var/mail/error/</repositoryPath>
+                <repositoryPath>blob://var/mail/error/</repositoryPath>
             </mailet>
         </processor>
 
@@ -82,7 +82,7 @@
                 <attachment>none</attachment>
             </mailet>
             <mailet match="All" class="ToRepository">
-                
<repositoryPath>cassandra://var/mail/relay-denied/</repositoryPath>
+                <repositoryPath>blob://var/mail/relay-denied/</repositoryPath>
                 <notice>Warning: You are sending an e-mail to a remote server. 
You must be authentified to perform such an operation</notice>
             </mailet>
         </processor>
@@ -95,7 +95,7 @@
 
         <processor state="rrt-error" enableJmx="false">
             <mailet match="All" class="ToRepository">
-                
<repositoryPath>cassandra://var/mail/rrt-error/</repositoryPath>
+                <repositoryPath>blob://var/mail/rrt-error/</repositoryPath>
                 <passThrough>true</passThrough>
             </mailet>
             <mailet match="IsSenderInRRTLoop" class="Null"/>
diff --git a/server/container/guice/mailrepository-blob/pom.xml 
b/server/container/guice/mailrepository-blob/pom.xml
new file mode 100644
index 0000000000..52b550342c
--- /dev/null
+++ b/server/container/guice/mailrepository-blob/pom.xml
@@ -0,0 +1,75 @@
+<?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/maven-v4_0_0.xsd";>
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.james</groupId>
+        <artifactId>james-server-guice</artifactId>
+        <version>3.8.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>mailrepository-blob</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Apache James :: Server :: MailRepository :: Blobstore / Guice</name>
+    <description>Guice modules for Blobstore implementation of 
'mailrepository' interfaces</description>
+
+    <properties>
+        <cassandra.includes>empty</cassandra.includes>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-guice-configuration</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-mailrepository-blob</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-mailrepository-memory</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>${james.groupId}</groupId>
+            <artifactId>mailrepository-loaders</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.inject</groupId>
+            <artifactId>guice</artifactId>
+        </dependency>
+    </dependencies>
+
+
+</project>
diff --git 
a/server/container/guice/mailrepository-blob/src/main/java/org/apache/james/modules/mailrepository/BlobstoreMailRepositoryModule.java
 
b/server/container/guice/mailrepository-blob/src/main/java/org/apache/james/modules/mailrepository/BlobstoreMailRepositoryModule.java
new file mode 100644
index 0000000000..c1a450611a
--- /dev/null
+++ 
b/server/container/guice/mailrepository-blob/src/main/java/org/apache/james/modules/mailrepository/BlobstoreMailRepositoryModule.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.mailrepository;
+
+import org.apache.commons.configuration2.BaseHierarchicalConfiguration;
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BlobStoreDAO;
+import org.apache.james.blob.mail.MimeMessageStore;
+import org.apache.james.mailrepository.api.MailRepositoryFactory;
+import org.apache.james.mailrepository.api.Protocol;
+import org.apache.james.mailrepository.blob.BlobMailRepository;
+import org.apache.james.mailrepository.blob.BlobMailRepositoryFactory;
+import org.apache.james.mailrepository.memory.MailRepositoryStoreConfiguration;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.ProvidesIntoSet;
+
+public class BlobstoreMailRepositoryModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(MailRepositoryStoreConfiguration.Item.class)
+                .toInstance(
+                        new MailRepositoryStoreConfiguration.Item(
+                                ImmutableList.of(new Protocol("blob")),
+                                BlobMailRepository.class.getName(),
+                                new BaseHierarchicalConfiguration())
+                );
+    }
+
+    @ProvidesIntoSet()
+    public MailRepositoryFactory blobMailRepository(BlobStoreDAO blobStore,
+                                                    BlobId.Factory 
blobIdFactory,
+                                                    MimeMessageStore.Factory 
mimeFactory) {
+        return new BlobMailRepositoryFactory(blobStore, blobIdFactory, 
mimeFactory);
+    }
+
+}
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index 885f086ad6..47608e0994 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -50,6 +50,7 @@
         <module>mailbox-jpa</module>
         <module>mailbox-plugin-deleted-messages-vault</module>
         <module>mailet</module>
+        <module>mailrepository-blob</module>
         <module>mailrepository-cassandra</module>
         <module>mailrepository-loaders</module>
         <module>memory</module>
@@ -250,6 +251,11 @@
                 <version>${project.version}</version>
                 <type>test-jar</type>
             </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
+                <artifactId>mailrepository-blob</artifactId>
+                <version>${project.version}</version>
+            </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
                 <artifactId>mailrepository-cassandra</artifactId>


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

Reply via email to