Skip to content

Commit

Permalink
JAMES-1693 implement a data memory module for Guice
Browse files Browse the repository at this point in the history
	   That means have a tree of guice modules to pick from
	   when composing an application.
  • Loading branch information
mbaechler committed Mar 23, 2016
1 parent 3413ec5 commit 517a4cf
Show file tree
Hide file tree
Showing 158 changed files with 3,468 additions and 749 deletions.
Expand Up @@ -20,24 +20,26 @@
package org.apache.james.mailbox.inmemory;

import java.util.List;
import javax.inject.Inject;

import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreMailboxManager;

import com.google.common.collect.Lists;

public class InMemoryMailboxManager extends StoreMailboxManager<InMemoryId> {

public InMemoryMailboxManager(Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
super(new InMemoryMailboxSessionMapperFactory(), authenticator, locker, aclResolver, groupMembershipResolver);
@Inject
public InMemoryMailboxManager(MailboxSessionMapperFactory<InMemoryId> mailboxSessionMapperFactory, Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
super(mailboxSessionMapperFactory, authenticator, locker, aclResolver, groupMembershipResolver);
}

@Override
public List<Capabilities> getSupportedCapabilities() {
return Lists.newArrayList(Capabilities.Basic, Capabilities.Move);

}
}
Expand Up @@ -83,7 +83,8 @@ protected void createMailboxManager() throws MailboxException {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();

StoreMailboxManager<InMemoryId> mailboxManager = new InMemoryMailboxManager(new MockAuthenticator(), new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
StoreMailboxManager<InMemoryId> mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, new MockAuthenticator(), new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
mailboxManager.init();

setMailboxManager(mailboxManager);
Expand Down
Expand Up @@ -26,6 +26,7 @@
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
import org.apache.james.mailbox.manager.IntegrationResources;
Expand All @@ -50,7 +51,9 @@ public class InMemoryIntegrationResources implements IntegrationResources {
public MailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver) throws MailboxException {
MockAuthenticator mockAuthenticator = new MockAuthenticator();
mockAuthenticator.addUser(ManagerTestResources.USER, ManagerTestResources.USER_PASS);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
final StoreMailboxManager<InMemoryId> manager = new InMemoryMailboxManager(
mailboxSessionMapperFactory,
mockAuthenticator,
new NoMailboxPathLocker(),
new UnionMailboxACLResolver(),
Expand Down
Expand Up @@ -22,6 +22,8 @@
import java.util.HashSet;
import java.util.List;

import javax.inject.Inject;

import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.RequestAware;
import org.apache.james.mailbox.SubscriptionManager;
Expand All @@ -41,7 +43,8 @@ public class StoreSubscriptionManager implements SubscriptionManager {
private static final int INITIAL_SIZE = 32;

protected SubscriptionMapperFactory mapperFactory;


@Inject
public StoreSubscriptionManager(SubscriptionMapperFactory mapperFactory) {
this.mapperFactory = mapperFactory;
}
Expand Down
Expand Up @@ -30,6 +30,7 @@
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
import org.apache.james.mailbox.inmemory.quota.InMemoryCurrentQuotaManager;
import org.apache.james.mailbox.inmemory.quota.InMemoryPerUserMaxQuotaManager;
import org.apache.james.mailbox.model.MailboxPath;
Expand Down Expand Up @@ -79,7 +80,8 @@ private void initFields() throws MailboxException {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();

mailboxManager = new InMemoryMailboxManager(userManager, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, userManager, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mailboxManager.getMapperFactory());

InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager = new InMemoryPerUserMaxQuotaManager();
Expand Down
6 changes: 6 additions & 0 deletions mpt/impl/smtp/cassandra/pom.xml
Expand Up @@ -158,6 +158,12 @@
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>james-server-guice-common</artifactId>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down
Expand Up @@ -31,6 +31,9 @@
import org.apache.james.mailbox.cassandra.modules.CassandraMessageModule;
import org.apache.james.mailbox.elasticsearch.ClientProvider;
import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
import org.apache.james.modules.CommonServicesModule;
import org.apache.james.modules.MailetProcessingModule;
import org.apache.james.modules.ProtocolsModule;
import org.apache.james.modules.TestFilesystemModule;
import org.apache.james.mpt.api.SmtpHostSystem;
import org.apache.james.mpt.smtp.dns.InMemoryDNSService;
Expand Down Expand Up @@ -85,13 +88,17 @@ protected void configure() {
.build());
};

install(Modules.override(CassandraJamesServerMain.defaultModule)
.with(Modules.combine(
new TestFilesystemModule(folder),
install(Modules
.override(
CassandraJamesServerMain.cassandraServerModule,
new CommonServicesModule<>(CassandraJamesServerMain.cassandraId),
new ProtocolsModule<>(CassandraJamesServerMain.cassandraId),
new MailetProcessingModule())
.with(new TestFilesystemModule(folder),
cassandra,
dns,
elasticSearch,
jmap)));
jmap));
}


Expand Down
Expand Up @@ -57,6 +57,9 @@
<name>X-UserIsAuth</name>
<value>true</value>
</mailet>
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
<mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
<name>X-WasSigned</name>
<value>true</value>
Expand Down
6 changes: 6 additions & 0 deletions mpt/pom.xml
Expand Up @@ -254,6 +254,12 @@
<artifactId>james-server-dnsservice-api</artifactId>
<version>${james.version}</version>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>james-server-guice-common</artifactId>
<version>${james.version}</version>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.james.protocols</groupId>
<artifactId>protocols-imap</artifactId>
Expand Down

0 comments on commit 517a4cf

Please sign in to comment.