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 2019/03/28 03:21:50 UTC
[james-project] 06/23: JAMES-2685 BlobMemoryModule for
MemoryBlobStore
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 994c58fb99b2b1bdd4512167b828032219a6d5e5
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Tue Mar 19 11:45:15 2019 +0700
JAMES-2685 BlobMemoryModule for MemoryBlobStore
To be used in memory integration tests, more details, it is for injecting
BlobStore to ExportService of DeletedMessageVaultRoute
---
pom.xml | 5 ++
.../apache/james/blob/memory/MemoryBlobStore.java | 4 ++
server/container/guice/blob-memory-guice/pom.xml | 62 ++++++++++++++++++++++
.../org/apache/james/modules/BlobMemoryModule.java | 40 ++++++++++++++
server/container/guice/memory-guice/pom.xml | 4 ++
.../org/apache/james/MemoryJamesServerMain.java | 6 ++-
server/container/guice/pom.xml | 1 +
7 files changed, 120 insertions(+), 2 deletions(-)
diff --git a/pom.xml b/pom.xml
index 23f959f..f478bff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1108,6 +1108,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>blob-memory-guice</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>blob-objectstorage</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
index 2e203ef..c47d83f 100644
--- a/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
+++ b/server/blob/blob-memory/src/main/java/org/apache/james/blob/memory/MemoryBlobStore.java
@@ -25,18 +25,22 @@ import java.io.InputStream;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import javax.inject.Inject;
+
import org.apache.commons.io.IOUtils;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
import org.apache.james.blob.api.ObjectStoreException;
import com.google.common.base.Preconditions;
+
import reactor.core.publisher.Mono;
public class MemoryBlobStore implements BlobStore {
private final ConcurrentHashMap<BlobId, byte[]> blobs;
private final BlobId.Factory factory;
+ @Inject
public MemoryBlobStore(BlobId.Factory factory) {
this.factory = factory;
blobs = new ConcurrentHashMap<>();
diff --git a/server/container/guice/blob-memory-guice/pom.xml b/server/container/guice/blob-memory-guice/pom.xml
new file mode 100644
index 0000000..fbe487e
--- /dev/null
+++ b/server/container/guice/blob-memory-guice/pom.xml
@@ -0,0 +1,62 @@
+<?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.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>blob-memory-guice</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: Blob Memory - guice injection</name>
+ <description>Blob modules on memory storage</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-memory</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <reuseForks>true</reuseForks>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/server/container/guice/blob-memory-guice/src/main/java/org/apache/james/modules/BlobMemoryModule.java b/server/container/guice/blob-memory-guice/src/main/java/org/apache/james/modules/BlobMemoryModule.java
new file mode 100644
index 0000000..a9ab646
--- /dev/null
+++ b/server/container/guice/blob-memory-guice/src/main/java/org/apache/james/modules/BlobMemoryModule.java
@@ -0,0 +1,40 @@
+/****************************************************************
+ * 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.blob.api.BlobId;
+import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.api.HashBlobId;
+import org.apache.james.blob.memory.MemoryBlobStore;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Scopes;
+
+public class BlobMemoryModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(HashBlobId.Factory.class).in(Scopes.SINGLETON);
+ bind(BlobId.Factory.class).to(HashBlobId.Factory.class);
+
+ bind(MemoryBlobStore.class).in(Scopes.SINGLETON);
+ bind(BlobStore.class).to(MemoryBlobStore.class);
+ }
+}
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index e785511..792c017 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -65,6 +65,10 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>blob-memory-guice</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>event-sourcing-event-store-memory</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index cd951da..6e0f235 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -20,6 +20,7 @@
package org.apache.james;
import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.james.modules.BlobMemoryModule;
import org.apache.james.modules.MailboxModule;
import org.apache.james.modules.data.MemoryDataJmapModule;
import org.apache.james.modules.data.MemoryDataModule;
@@ -79,12 +80,13 @@ public class MemoryJamesServerMain {
new JMAPServerModule());
public static final Module IN_MEMORY_SERVER_MODULE = Modules.combine(
+ new BlobMemoryModule(),
new DeletedMessageVaultModule(),
+ new MailboxModule(),
new MemoryDataModule(),
new MemoryEventStoreModule(),
new MemoryMailboxModule(),
- new MemoryMailQueueModule(),
- new MailboxModule());
+ new MemoryMailQueueModule());
public static final Module SMTP_ONLY_MODULE = Modules.combine(
MemoryJamesServerMain.IN_MEMORY_SERVER_MODULE,
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index efc27bc..5948b80 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -34,6 +34,7 @@
<modules>
<module>blob-api-guice</module>
+ <module>blob-memory-guice</module>
<module>blob-objectstorage-guice</module>
<module>cassandra-guice</module>
<module>cassandra-ldap-guice</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org