Skip to content

Commit

Permalink
JAMES-1644 cleanup injection of Cassandra-guice
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/james/project/trunk@1719313 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mbaechler committed Dec 11, 2015
1 parent 283bc73 commit bd88a49
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 32 deletions.
Expand Up @@ -31,15 +31,14 @@
import org.apache.james.mailbox.cassandra.CassandraSubscriptionManager;
import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.store.Authenticator;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
import org.apache.james.mailbox.store.mail.MessageMapperFactory;
import org.apache.james.mailbox.store.mail.ModSeqProvider;
import org.apache.james.mailbox.store.mail.UidProvider;
import org.apache.james.mailbox.store.search.MessageSearchIndex;

import com.google.inject.AbstractModule;
import com.google.inject.Provides;
Expand All @@ -53,7 +52,11 @@ public class CassandraMailboxModule extends AbstractModule {

@Override
protected void configure() {
bind(new TypeLiteral<MessageSearchIndex<CassandraId>>(){}).to(new TypeLiteral<ElasticSearchListeningMessageSearchIndex<CassandraId>>(){});
bind(new TypeLiteral<MessageMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
bind(new TypeLiteral<MailboxMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
bind(new TypeLiteral<MailboxSessionMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
bind(new TypeLiteral<ModSeqProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraModSeqProvider>(){});
bind(new TypeLiteral<UidProvider<CassandraId>>(){}).to(new TypeLiteral<CassandraUidProvider>(){});

bind(SubscriptionManager.class).to(CassandraSubscriptionManager.class);
bind(new TypeLiteral<MessageMapperFactory<CassandraId>>(){}).to(CassandraMailboxSessionMapperFactory.class);
Expand Down
Expand Up @@ -46,8 +46,6 @@ public class ElasticSearchMailboxModule extends AbstractModule {
protected void configure() {
bind(new TypeLiteral<MessageSearchIndex<CassandraId>>(){}).to(new TypeLiteral<ElasticSearchListeningMessageSearchIndex<CassandraId>>() {});
bind(TextExtractor.class).to(TikaTextExtractor.class);
bind(new TypeLiteral<MessageSearchIndex<CassandraId>>() {})
.to(new TypeLiteral<ElasticSearchListeningMessageSearchIndex<CassandraId>>() {});
}

@Provides
Expand Down
Expand Up @@ -50,7 +50,7 @@ public class CamelMailetContainerModule extends AbstractModule {

@Override
protected void configure() {
bind(MailProcessor.class).to(CamelCompositeProcessor.class);
bind(MailProcessor.class).to(CamelCompositeProcessor.class).in(Singleton.class);
bind(MailSpoolerMBean.class).to(JamesMailSpooler.class);
bind(MailetLoader.class).to(GuiceMailetLoader.class);
bind(MatcherLoader.class).to(GuiceMatcherLoader.class);
Expand Down
Expand Up @@ -19,9 +19,9 @@

package org.apache.james.modules.server;

import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import javax.annotation.PreDestroy;
import javax.jms.ConnectionFactory;

import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.ActiveMQPrefetchPolicy;
import org.apache.activemq.blob.BlobTransferPolicy;
Expand All @@ -30,24 +30,26 @@
import org.apache.activemq.broker.jmx.ManagementContext;
import org.apache.activemq.plugin.StatisticsBrokerPlugin;
import org.apache.activemq.store.amq.AMQPersistenceAdapter;
import org.apache.james.filesystem.api.FileSystem;
import org.apache.james.queue.activemq.FileSystemBlobTransferPolicy;

import javax.annotation.PreDestroy;
import javax.jms.ConnectionFactory;
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.Singleton;

@Singleton
public class EmbeddedActiveMQ {

private ActiveMQConnectionFactory activeMQConnectionFactory;
private BrokerService brokerService;

@Inject private EmbeddedActiveMQ() {
@Inject private EmbeddedActiveMQ(FileSystem fileSystem) {
try {
launchEmbeddedBroker();
} catch (Exception e) {
throw Throwables.propagate(e);
}
activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy());
activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy(fileSystem));
}

public ConnectionFactory getConnectionFactory() {
Expand All @@ -73,9 +75,10 @@ private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() {
return prefetchPolicy;
}

private BlobTransferPolicy createBlobTransferPolicy() {
BlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) {
FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy();
blobTransferPolicy.setDefaultUploadUrl("file://var/store/activemq/blob-transfer");
blobTransferPolicy.setFileSystem(fileSystem);
return blobTransferPolicy;
}

Expand Down

This file was deleted.

0 comments on commit bd88a49

Please sign in to comment.