http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java deleted file mode 100644 index a608906..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.camel.impl.DefaultCamelContext; -import org.apache.james.dnsservice.api.DNSService; -import org.apache.james.domainlist.api.DomainList; -import org.apache.james.mailetcontainer.api.MailProcessor; -import org.apache.james.mailetcontainer.api.MailetLoader; -import org.apache.james.mailetcontainer.api.MatcherLoader; -import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean; -import org.apache.james.mailetcontainer.impl.JamesMailSpooler; -import org.apache.james.mailetcontainer.impl.JamesMailetContext; -import org.apache.james.mailetcontainer.impl.camel.CamelCompositeProcessor; -import org.apache.james.user.api.UsersRepository; -import org.apache.james.utils.ConfigurationPerformer; -import org.apache.james.utils.ConfigurationProvider; -import org.apache.james.utils.GuiceMailetLoader; -import org.apache.james.utils.GuiceMatcherLoader; -import org.apache.mailet.MailetContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.inject.AbstractModule; -import com.google.inject.Inject; -import com.google.inject.Provides; -import com.google.inject.Singleton; -import com.google.inject.multibindings.Multibinder; - -public class CamelMailetContainerModule extends AbstractModule { - - private static final Logger CAMEL_LOGGER = LoggerFactory.getLogger(CamelCompositeProcessor.class); - private static final Logger SPOOLER_LOGGER = LoggerFactory.getLogger(JamesMailSpooler.class); - private static final Logger MAILET_LOGGER = LoggerFactory.getLogger(JamesMailetContext.class); - - @Override - protected void configure() { - 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); - Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailetModuleConfigurationPerformer.class); - } - - @Provides - @Singleton - private MailetContext provideMailetContext(MailProcessor processorList, - DNSService dns, - UsersRepository localusers, - DomainList domains) { - JamesMailetContext jamesMailetContext = new JamesMailetContext(); - jamesMailetContext.setLog(MAILET_LOGGER); - jamesMailetContext.setDNSService(dns); - jamesMailetContext.setMailProcessor(processorList); - jamesMailetContext.setUsersRepository(localusers); - jamesMailetContext.setDomainList(domains); - return jamesMailetContext; - } - - @Singleton - public static class MailetModuleConfigurationPerformer implements ConfigurationPerformer { - - private final ConfigurationProvider configurationProvider; - private final CamelCompositeProcessor camelCompositeProcessor; - private final JamesMailSpooler jamesMailSpooler; - private final JamesMailetContext mailetContext; - - @Inject - public MailetModuleConfigurationPerformer(ConfigurationProvider configurationProvider, - CamelCompositeProcessor camelCompositeProcessor, - JamesMailSpooler jamesMailSpooler, - JamesMailetContext mailetContext) { - this.configurationProvider = configurationProvider; - this.camelCompositeProcessor = camelCompositeProcessor; - this.jamesMailSpooler = jamesMailSpooler; - this.mailetContext = mailetContext; - } - - @Override - public void initModule() throws Exception { - camelCompositeProcessor.setLog(CAMEL_LOGGER); - camelCompositeProcessor.setCamelContext(new DefaultCamelContext()); - camelCompositeProcessor.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("processors")); - camelCompositeProcessor.init(); - jamesMailSpooler.setLog(SPOOLER_LOGGER); - jamesMailSpooler.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("spooler")); - jamesMailSpooler.init(); - mailetContext.setLog(MAILET_LOGGER); - mailetContext.configure(configurationProvider.getConfiguration("mailetcontainer").configurationAt("context")); - mailetContext.setMailProcessor(camelCompositeProcessor); - } - } - -}
http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java deleted file mode 100644 index f9d3cff..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.utils.ConfigurationProvider; -import org.apache.james.utils.FileConfigurationProvider; - -import com.google.inject.AbstractModule; - -public class ConfigurationProviderModule extends AbstractModule { - - @Override - public void configure() { - bind(ConfigurationProvider.class).to(FileConfigurationProvider.class); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java deleted file mode 100644 index 5d3b49f..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/DNSServiceModule.java +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.dnsservice.api.DNSService; -import org.apache.james.dnsservice.dnsjava.DNSJavaService; -import org.apache.james.utils.ConfigurationPerformer; -import org.apache.james.utils.ConfigurationProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.inject.AbstractModule; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.inject.multibindings.Multibinder; - -public class DNSServiceModule extends AbstractModule { - - private static final Logger LOGGER = LoggerFactory.getLogger(DNSServiceModule.class); - - @Override - protected void configure() { - bind(DNSService.class).to(DNSJavaService.class); - Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(DNSServiceConfigurationPerformer.class); - } - - @Singleton - public static class DNSServiceConfigurationPerformer implements ConfigurationPerformer { - - private final ConfigurationProvider configurationProvider; - private final DNSJavaService dnsService; - - @Inject - public DNSServiceConfigurationPerformer(ConfigurationProvider configurationProvider, - DNSJavaService dnsService) { - this.configurationProvider = configurationProvider; - this.dnsService = dnsService; - } - - public void initModule() throws Exception { - dnsService.setLog(LOGGER); - dnsService.configure(configurationProvider.getConfiguration("dnsservice")); - dnsService.init(); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java deleted file mode 100644 index 3c34f74..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************** - * 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.server; - -import javax.annotation.PreDestroy; -import javax.jms.ConnectionFactory; - -import org.apache.activemq.ActiveMQConnectionFactory; -import org.apache.activemq.ActiveMQPrefetchPolicy; -import org.apache.activemq.blob.BlobTransferPolicy; -import org.apache.activemq.broker.BrokerPlugin; -import org.apache.activemq.broker.BrokerService; -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 com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.google.inject.Singleton; - -@Singleton -public class EmbeddedActiveMQ { - - private final ActiveMQConnectionFactory activeMQConnectionFactory; - private BrokerService brokerService; - - @Inject private EmbeddedActiveMQ(FileSystem fileSystem) { - try { - launchEmbeddedBroker(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - activeMQConnectionFactory = createActiveMQConnectionFactory(createBlobTransferPolicy(fileSystem)); - } - - public ConnectionFactory getConnectionFactory() { - return activeMQConnectionFactory; - } - - @PreDestroy - public void stop() throws Exception { - brokerService.stop(); - } - - private ActiveMQConnectionFactory createActiveMQConnectionFactory(BlobTransferPolicy blobTransferPolicy) { - ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://james?create=false"); - connectionFactory.setBlobTransferPolicy(blobTransferPolicy); - connectionFactory.setPrefetchPolicy(createActiveMQPrefetchPolicy()); - return connectionFactory; - } - - private ActiveMQPrefetchPolicy createActiveMQPrefetchPolicy() { - ActiveMQPrefetchPolicy prefetchPolicy = new ActiveMQPrefetchPolicy(); - prefetchPolicy.setQueuePrefetch(0); - prefetchPolicy.setTopicPrefetch(0); - return prefetchPolicy; - } - - private BlobTransferPolicy createBlobTransferPolicy(FileSystem fileSystem) { - FileSystemBlobTransferPolicy blobTransferPolicy = new FileSystemBlobTransferPolicy(); - blobTransferPolicy.setDefaultUploadUrl("file://var/store/activemq/blob-transfer"); - blobTransferPolicy.setFileSystem(fileSystem); - return blobTransferPolicy; - } - - private void launchEmbeddedBroker() throws Exception { - brokerService = new BrokerService(); - brokerService.setBrokerName("james"); - brokerService.setUseJmx(false); - brokerService.setPersistent(true); - brokerService.setDataDirectory("filesystem=file://var/store/activemq/brokers"); - brokerService.setUseShutdownHook(false); - brokerService.setSchedulerSupport(false); - brokerService.setBrokerId("broker"); - String[] uris = {"tcp://localhost:0"}; - brokerService.setTransportConnectorURIs(uris); - ManagementContext managementContext = new ManagementContext(); - managementContext.setCreateConnector(false); - brokerService.setManagementContext(managementContext); - brokerService.setPersistenceAdapter(new AMQPersistenceAdapter()); - BrokerPlugin[] brokerPlugins = {new StatisticsBrokerPlugin()}; - brokerService.setPlugins(brokerPlugins); - String[] transportConnectorsURIs = {"tcp://localhost:0"}; - brokerService.setTransportConnectorURIs(transportConnectorsURIs); - brokerService.start(); - System.out.println("Started : " + brokerService.isStarted()); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java deleted file mode 100644 index 4b4e63d..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServer.java +++ /dev/null @@ -1,125 +0,0 @@ -/**************************************************************** - * 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.server; - -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.rmi.registry.LocateRegistry; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import javax.management.remote.JMXConnectorServer; -import javax.management.remote.JMXConnectorServerFactory; -import javax.management.remote.JMXServiceURL; - -import org.apache.commons.configuration.PropertiesConfiguration; -import org.apache.james.filesystem.api.FileSystem; -import org.apache.james.util.RestrictingRMISocketFactory; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableMap; - -public class JMXServer { - - private final FileSystem fileSystem; - private final Set<String> registeredKeys; - private final Object lock; - private JMXConnectorServer jmxConnectorServer; - private boolean isStarted; - - @Inject - public JMXServer(FileSystem fileSystem) { - this.fileSystem = fileSystem; - isStarted = false; - registeredKeys = new HashSet<>(); - lock = new Object(); - } - - public void start() { - synchronized (lock) { - if (isStarted) { - return; - } - isStarted = true; - doStart(); - } - } - - @PreDestroy - public void stop() { - synchronized (lock) { - if (!isStarted) { - return; - } - isStarted = false; - doStop(); - } - } - - public void register(String key, Object remote) throws Exception { - ManagementFactory.getPlatformMBeanServer().registerMBean(remote, new ObjectName(key)); - synchronized (lock) { - registeredKeys.add(key); - } - } - - private void doStart() { - try { - PropertiesConfiguration configuration = new PropertiesConfiguration(fileSystem.getFile(FileSystem.FILE_PROTOCOL_AND_CONF + "jmx.properties")); - String address = configuration.getString("jmx.address"); - int port = configuration.getInt("jmx.port"); - String serviceURL = "service:jmx:rmi://" + address + "/jndi/rmi://" + address+ ":" + port +"/jmxrmi"; - RestrictingRMISocketFactory restrictingRMISocketFactory = new RestrictingRMISocketFactory(address); - LocateRegistry.createRegistry(port, restrictingRMISocketFactory, restrictingRMISocketFactory); - - Map<String, ?> environment = ImmutableMap.of(); - jmxConnectorServer = JMXConnectorServerFactory.newJMXConnectorServer(new JMXServiceURL(serviceURL), - environment, - ManagementFactory.getPlatformMBeanServer()); - - jmxConnectorServer.start(); - } catch (Exception e) { - throw Throwables.propagate(e); - } - } - - private void doStop() { - try { - MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); - registeredKeys.forEach(key -> { - try { - mBeanServer.unregisterMBean(new ObjectName(key)); - } catch (Exception e) { - throw Throwables.propagate(e); - } - }); - registeredKeys.clear(); - jmxConnectorServer.stop(); - } catch (IOException e) { - throw Throwables.propagate(e); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java deleted file mode 100644 index 019b546..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/JMXServerModule.java +++ /dev/null @@ -1,114 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.adapter.mailbox.MailboxCopierManagement; -import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean; -import org.apache.james.adapter.mailbox.MailboxManagerManagement; -import org.apache.james.adapter.mailbox.MailboxManagerManagementMBean; -import org.apache.james.adapter.mailbox.MailboxManagerResolver; -import org.apache.james.domainlist.api.DomainListManagementMBean; -import org.apache.james.domainlist.lib.DomainListManagement; -import org.apache.james.mailbox.cassandra.CassandraMailboxManager; -import org.apache.james.mailbox.copier.MailboxCopier; -import org.apache.james.mailbox.copier.MailboxCopierImpl; -import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean; -import org.apache.james.mailetcontainer.impl.JamesMailSpooler; -import org.apache.james.rrt.api.RecipientRewriteTableManagementMBean; -import org.apache.james.rrt.lib.RecipientRewriteTableManagement; -import org.apache.james.user.api.UsersRepositoryManagementMBean; -import org.apache.james.user.lib.UsersRepositoryManagement; -import org.apache.james.utils.ConfigurationPerformer; -import org.apache.james.utils.GuiceMailboxManagerResolver; -import org.apache.james.utils.MailboxManagerDefinition; - -import com.google.inject.AbstractModule; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.inject.multibindings.Multibinder; -import com.google.inject.name.Names; - -public class JMXServerModule extends AbstractModule { - - private static final String JMX_COMPONENT_DOMAINLIST = "org.apache.james:type=component,name=domainlist"; - private static final String JMX_COMPONENT_USERS_REPOSITORY = "org.apache.james:type=component,name=usersrepository"; - private static final String JMX_COMPONENT_RECIPIENTREWRITETABLE = "org.apache.james:type=component,name=recipientrewritetable"; - private static final String JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN = "org.apache.james:type=component,name=mailboxmanagerbean"; - private static final String JMX_COMPONENT_MAILBOXCOPIER = "org.apache.james:type=component,name=mailboxcopier"; - - @Override - protected void configure() { - bind(MailboxCopier.class).annotatedWith(Names.named("mailboxcopier")).to(MailboxCopierImpl.class); - bind(MailboxCopierManagementMBean.class).to(MailboxCopierManagement.class); - bind(MailboxManagerResolver.class).to(GuiceMailboxManagerResolver.class); - bind(DomainListManagementMBean.class).to(DomainListManagement.class); - bind(UsersRepositoryManagementMBean.class).to(UsersRepositoryManagement.class); - bind(MailboxManagerManagementMBean.class).to(MailboxManagerManagement.class); - bind(RecipientRewriteTableManagementMBean.class).to(RecipientRewriteTableManagement.class); - bind(MailSpoolerMBean.class).to(JamesMailSpooler.class); - Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JMXModuleConfigurationPerformer.class); - Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(CassandraMailboxManagerDefinition.class); - } - - @Singleton - private static class CassandraMailboxManagerDefinition extends MailboxManagerDefinition { - @Inject - private CassandraMailboxManagerDefinition(CassandraMailboxManager manager) { - super("cassandra-mailboxmanager", manager); - } - } - - @Singleton - public static class JMXModuleConfigurationPerformer implements ConfigurationPerformer { - - private final JMXServer jmxServer; - private final DomainListManagementMBean domainListManagementMBean; - private final UsersRepositoryManagementMBean usersRepositoryManagementMBean; - private final RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean; - private final MailboxManagerManagementMBean mailboxManagerManagementMBean; - private final MailboxCopierManagementMBean mailboxCopierManagementMBean; - - @Inject - public JMXModuleConfigurationPerformer(JMXServer jmxServer, - DomainListManagementMBean domainListManagementMBean, - UsersRepositoryManagementMBean usersRepositoryManagementMBean, - RecipientRewriteTableManagementMBean recipientRewriteTableManagementMBean, - MailboxManagerManagementMBean mailboxManagerManagementMBean, - MailboxCopierManagementMBean mailboxCopierManagementMBean) { - this.jmxServer = jmxServer; - this.domainListManagementMBean = domainListManagementMBean; - this.usersRepositoryManagementMBean = usersRepositoryManagementMBean; - this.recipientRewriteTableManagementMBean = recipientRewriteTableManagementMBean; - this.mailboxManagerManagementMBean = mailboxManagerManagementMBean; - this.mailboxCopierManagementMBean = mailboxCopierManagementMBean; - } - - @Override - public void initModule() throws Exception { - jmxServer.start(); - jmxServer.register(JMX_COMPONENT_DOMAINLIST, domainListManagementMBean); - jmxServer.register(JMX_COMPONENT_USERS_REPOSITORY, usersRepositoryManagementMBean); - jmxServer.register(JMX_COMPONENT_RECIPIENTREWRITETABLE, recipientRewriteTableManagementMBean); - jmxServer.register(JMX_COMPONENT_NAME_MAILBOXMANAGERBEAN, mailboxManagerManagementMBean); - jmxServer.register(JMX_COMPONENT_MAILBOXCOPIER, mailboxCopierManagementMBean); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java deleted file mode 100644 index 8e91d64..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.filesystem.api.FileSystem; -import org.apache.james.mailrepository.api.MailRepository; -import org.apache.james.mailrepository.api.MailRepositoryStore; -import org.apache.james.mailrepository.file.FileMailRepository; -import org.apache.james.utils.ConfigurationPerformer; -import org.apache.james.utils.ConfigurationProvider; -import org.apache.james.utils.InMemoryMailRepositoryStore; -import org.apache.james.utils.MailRepositoryProvider; -import org.slf4j.LoggerFactory; - -import com.google.inject.AbstractModule; -import com.google.inject.Inject; -import com.google.inject.Singleton; -import com.google.inject.multibindings.Multibinder; - -public class MailStoreRepositoryModule extends AbstractModule { - - @Override - protected void configure() { - bind(MailRepositoryStore.class).to(InMemoryMailRepositoryStore.class); - Multibinder<MailRepositoryProvider> multibinder = Multibinder.newSetBinder(binder(), MailRepositoryProvider.class); - multibinder.addBinding().to(FileMailRepositoryProvider.class); - Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailRepositoryStoreModuleConfigurationPerformer.class); - } - - public static class FileMailRepositoryProvider implements MailRepositoryProvider { - - private final FileSystem fileSystem; - - @Inject - public FileMailRepositoryProvider(FileSystem fileSystem) { - this.fileSystem = fileSystem; - } - - - @Override - public String canonicalName() { - return FileMailRepository.class.getCanonicalName(); - } - - @Override - public MailRepository get() { - FileMailRepository fileMailRepository = new FileMailRepository(); - fileMailRepository.setFileSystem(fileSystem); - fileMailRepository.setLog(LoggerFactory.getLogger(FileMailRepository.class)); - return fileMailRepository; - } - } - - @Singleton - public static class MailRepositoryStoreModuleConfigurationPerformer implements ConfigurationPerformer { - - private final ConfigurationProvider configurationProvider; - private final InMemoryMailRepositoryStore javaMailRepositoryStore; - - @Inject - public MailRepositoryStoreModuleConfigurationPerformer(ConfigurationProvider configurationProvider, - InMemoryMailRepositoryStore javaMailRepositoryStore) { - this.configurationProvider = configurationProvider; - this.javaMailRepositoryStore = javaMailRepositoryStore; - } - - @Override - public void initModule() throws Exception { - javaMailRepositoryStore.configure(configurationProvider.getConfiguration("mailrepositorystore")); - javaMailRepositoryStore.init(); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java deleted file mode 100644 index f8e7815..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/QuotaModule.java +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.mailbox.quota.QuotaManager; -import org.apache.james.mailbox.quota.QuotaRootResolver; -import org.apache.james.mailbox.store.quota.DefaultQuotaRootResolver; -import org.apache.james.mailbox.store.quota.NoQuotaManager; - -import com.google.inject.AbstractModule; -import com.google.inject.Scopes; - -public class QuotaModule extends AbstractModule { - - @Override - protected void configure() { - bind(QuotaManager.class).to(NoQuotaManager.class); - bind(QuotaRootResolver.class).to(DefaultQuotaRootResolver.class).in(Scopes.SINGLETON); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java b/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java deleted file mode 100644 index 229b479..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/modules/server/SieveModule.java +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************** - * 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.server; - -import org.apache.james.managesieve.api.SieveParser; -import org.apache.james.managesieve.jsieve.Parser; -import org.apache.james.sieverepository.api.SieveRepository; -import org.apache.james.sieverepository.file.SieveFileRepository; - -import com.google.inject.AbstractModule; - -public class SieveModule extends AbstractModule { - - @Override - protected void configure() { - bind(SieveParser.class).to(Parser.class); - bind(SieveRepository.class).to(SieveFileRepository.class); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java deleted file mode 100644 index ae2ef87..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationPerformer.java +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************** - * 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.utils; - - -public interface ConfigurationPerformer { - - void initModule() throws Exception; - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java deleted file mode 100644 index cf3126e..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationProvider.java +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************** - * 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.utils; - -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.HierarchicalConfiguration; - -public interface ConfigurationProvider { - - HierarchicalConfiguration getConfiguration(String component) - throws ConfigurationException; - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java deleted file mode 100644 index f64d640..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java +++ /dev/null @@ -1,41 +0,0 @@ -/**************************************************************** - * 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.utils; - -import com.google.inject.Inject; - -import java.util.Set; - -public class ConfigurationsPerformer { - - private final Set<ConfigurationPerformer> configurationPerformers; - - @Inject - public ConfigurationsPerformer(Set<ConfigurationPerformer> configurationPerformers) throws Exception { - this.configurationPerformers = configurationPerformers; - } - - public void initModules() throws Exception { - for(ConfigurationPerformer configurationPerformer : configurationPerformers) { - configurationPerformer.initModule(); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java deleted file mode 100644 index fc27b61..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/ExtendedServerProbe.java +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************** - * 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.utils; - -import java.io.InputStream; -import java.util.Date; - -import javax.mail.Flags; - -import org.apache.james.cli.probe.ServerProbe; -import org.apache.james.mailbox.cassandra.CassandraId; -import org.apache.james.mailbox.exception.BadCredentialsException; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.store.mail.model.Mailbox; - -public interface ExtendedServerProbe extends ServerProbe { - - void appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags) - throws BadCredentialsException, MailboxException; - - Mailbox<CassandraId> getMailbox(String namespace, String user, String name); -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java deleted file mode 100644 index b28a94a..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/FileConfigurationProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************** - * 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.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.List; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.apache.commons.cli.MissingArgumentException; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.commons.configuration.HierarchicalConfiguration; -import org.apache.commons.configuration.XMLConfiguration; -import org.apache.james.filesystem.api.FileSystem; -import org.apache.james.modules.CommonServicesModule; - -import com.google.common.base.Preconditions; -import com.google.common.base.Splitter; -import com.google.common.base.Strings; -import com.google.common.collect.Iterables; -import com.google.inject.Singleton; - -@Singleton -public class FileConfigurationProvider implements ConfigurationProvider { - - private static final String CONFIGURATION_FILE_SUFFIX = ".xml"; - - private final FileSystem fileSystem; - private final String configurationPrefix; - - @Inject - public FileConfigurationProvider(FileSystem fileSystem, @Named(CommonServicesModule.CONFIGURATION_PATH) String configurationPrefix) throws MissingArgumentException { - this.fileSystem = fileSystem; - this.configurationPrefix = configurationPrefix; - } - - @Override - public HierarchicalConfiguration getConfiguration(String component) throws ConfigurationException { - Preconditions.checkNotNull(component); - List<String> configPathParts = Splitter.on(".").splitToList(component); - Preconditions.checkArgument(!configPathParts.isEmpty()); - HierarchicalConfiguration config = getConfig(retrieveConfigInputStream(configPathParts.get(0))); - return selectHierarchicalConfigPart(config, Iterables.skip(configPathParts, 1)); - } - - private InputStream retrieveConfigInputStream(String configurationFileWithoutExtension) throws ConfigurationException { - Preconditions.checkArgument(!Strings.isNullOrEmpty(configurationFileWithoutExtension), "The configuration file name should not be empty or null"); - try { - return fileSystem.getResource(configurationPrefix + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX); - } catch (IOException e) { - throw new ConfigurationException("Unable to locate configuration file " + configurationFileWithoutExtension + CONFIGURATION_FILE_SUFFIX, e); - } - } - - private XMLConfiguration getConfig(InputStream configStream) throws ConfigurationException { - XMLConfiguration config = new XMLConfiguration(); - config.setDelimiterParsingDisabled(true); - config.setAttributeSplittingDisabled(true); - config.load(configStream); - return config; - } - - private HierarchicalConfiguration selectHierarchicalConfigPart(HierarchicalConfiguration config, Iterable<String> configsPathParts) { - HierarchicalConfiguration currentConfig = config; - for (String nextPathPart : configsPathParts) { - currentConfig = currentConfig.configurationAt(nextPathPart); - } - return currentConfig; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java deleted file mode 100644 index 645d9b0..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceGenericLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************** - * 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.utils; - -import com.google.inject.Injector; - -public class GuiceGenericLoader<T> { - - private final Injector injector; - private final String defaultPackageName; - - public GuiceGenericLoader(Injector injector, String defaultPackageName) { - this.injector = injector; - this.defaultPackageName = defaultPackageName; - } - - public T instanciate(String className) throws Exception { - @SuppressWarnings("unchecked") - Class<T> clazz = (Class<T>) ClassLoader.getSystemClassLoader().loadClass(constructFullName(className)); - return injector.getInstance(clazz); - } - - private String constructFullName(String name) { - if (! name.contains(".")) { - return defaultPackageName + name; - } - return name; - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java deleted file mode 100644 index fe55c9c..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************** - * 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.utils; - -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.james.adapter.mailbox.MailboxManagerResolver; -import org.apache.james.adapter.mailbox.MailboxManagerResolverException; -import org.apache.james.mailbox.MailboxManager; - -import com.google.common.collect.ImmutableMap; -import com.google.inject.Inject; - -public class GuiceMailboxManagerResolver implements MailboxManagerResolver { - - private final ImmutableMap<String, MailboxManager> managers; - - @Inject - private GuiceMailboxManagerResolver(Set<MailboxManagerDefinition> managers) { - this.managers = indexManagersByName(managers); - } - - private static ImmutableMap<String, MailboxManager> indexManagersByName(Set<MailboxManagerDefinition> managers) { - return ImmutableMap.copyOf(managers.stream().collect( - Collectors.toMap(MailboxManagerDefinition::getName, MailboxManagerDefinition::getManager))); - } - - @Override - public Map<String, MailboxManager> getMailboxManagerBeans() { - return managers; - } - - @Override - public MailboxManager resolveMailboxManager(String mailboxManagerClassName) { - return Optional.ofNullable(managers.get(mailboxManagerClassName)).orElseThrow( - () -> new MailboxManagerResolverException("Unable to find a mailbox manager with name " + mailboxManagerClassName)); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java deleted file mode 100644 index 3efdce6..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMailetLoader.java +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************** - * 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.utils; - -import com.google.inject.Inject; -import com.google.inject.Injector; -import org.apache.james.mailetcontainer.api.MailetLoader; -import org.apache.mailet.Mailet; -import org.apache.mailet.MailetConfig; - -import javax.mail.MessagingException; - -public class GuiceMailetLoader implements MailetLoader { - - private static final String STANDARD_PACKAGE = "org.apache.james.transport.mailets."; - - private final GuiceGenericLoader<Mailet> genericLoader; - - @Inject - public GuiceMailetLoader(Injector injector) { - this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE); - } - - @Override - public Mailet getMailet(MailetConfig config) throws MessagingException { - try { - Mailet result = genericLoader.instanciate(config.getMailetName()); - result.init(config); - return result; - } catch (Exception e) { - throw new MessagingException("Can not load mailet " + config.getMailetName(), e); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java deleted file mode 100644 index a6d966b..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceMatcherLoader.java +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************** - * 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.utils; - -import com.google.inject.Inject; -import com.google.inject.Injector; -import org.apache.james.mailetcontainer.api.MatcherLoader; -import org.apache.mailet.Matcher; -import org.apache.mailet.MatcherConfig; - -import javax.mail.MessagingException; - -public class GuiceMatcherLoader implements MatcherLoader { - - private static final String STANDARD_PACKAGE = "org.apache.james.transport.matchers."; - - private final GuiceGenericLoader<Matcher> genericLoader; - - @Inject - public GuiceMatcherLoader(Injector injector) { - this.genericLoader = new GuiceGenericLoader<>(injector, STANDARD_PACKAGE); - } - - @Override - public Matcher getMatcher(MatcherConfig config) throws MessagingException { - try { - Matcher result = genericLoader.instanciate(config.getMatcherName()); - result.init(config); - return result; - } catch (Exception e) { - throw new MessagingException("Can not load matcher " + config.getMatcherName(), e); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java deleted file mode 100644 index e677ce3..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceProtocolHandlerLoader.java +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************** - * 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.utils; - -import com.google.common.base.Throwables; -import com.google.inject.Inject; -import com.google.inject.Injector; -import org.apache.commons.configuration.Configuration; -import org.apache.commons.configuration.ConfigurationException; -import org.apache.james.protocols.api.handler.ProtocolHandler; -import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader; - -public class GuiceProtocolHandlerLoader implements ProtocolHandlerLoader { - - private final Injector injector; - - @Inject - public GuiceProtocolHandlerLoader(Injector injector) { - this.injector = injector; - } - - @Override - public ProtocolHandler load(String name, Configuration config) throws LoadingException { - ProtocolHandler handler = createProtocolHandler(name); - try { - handler.init(config); - } catch (ConfigurationException e) { - throw Throwables.propagate(e); - } - return handler; - } - - private ProtocolHandler createProtocolHandler(String name) throws LoadingException { - try { - @SuppressWarnings("unchecked") - Class<ProtocolHandler> clazz = (Class<ProtocolHandler>) ClassLoader.getSystemClassLoader().loadClass(name); - return injector.getInstance(clazz); - } catch (ClassNotFoundException e) { - throw new LoadingException("Can not load " + name); - } - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java ---------------------------------------------------------------------- diff --git a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java b/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java deleted file mode 100644 index 43850fe..0000000 --- a/server/container/cassandra-guice/src/main/java/org/apache/james/utils/GuiceServerProbe.java +++ /dev/null @@ -1,344 +0,0 @@ -/**************************************************************** - * 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.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.inject.Inject; -import javax.mail.Flags; - -import org.apache.commons.lang.NotImplementedException; -import org.apache.james.adapter.mailbox.SerializableQuota; -import org.apache.james.domainlist.api.DomainList; -import org.apache.james.mailbox.MailboxManager; -import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.MessageManager; -import org.apache.james.mailbox.cassandra.CassandraId; -import org.apache.james.mailbox.exception.MailboxException; -import org.apache.james.mailbox.model.MailboxConstants; -import org.apache.james.mailbox.model.MailboxMetaData; -import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.MailboxQuery; -import org.apache.james.mailbox.store.mail.MailboxMapper; -import org.apache.james.mailbox.store.mail.MailboxMapperFactory; -import org.apache.james.mailbox.store.mail.model.Mailbox; -import org.apache.james.rrt.lib.Mappings; -import org.apache.james.sieverepository.api.SieveRepository; -import org.apache.james.user.api.UsersRepository; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.base.Throwables; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; - -public class GuiceServerProbe implements ExtendedServerProbe { - - private static final Logger LOGGER = LoggerFactory.getLogger(GuiceServerProbe.class); - - private final MailboxManager mailboxManager; - private final MailboxMapperFactory<CassandraId> mailboxMapperFactory; - private final DomainList domainList; - private final UsersRepository usersRepository; - private final SieveRepository sieveRepository; - - @Inject - private GuiceServerProbe(MailboxManager mailboxManager, MailboxMapperFactory<CassandraId> mailboxMapperFactory, - DomainList domainList, UsersRepository usersRepository, SieveRepository sieveRepository) { - this.mailboxManager = mailboxManager; - this.mailboxMapperFactory = mailboxMapperFactory; - this.domainList = domainList; - this.usersRepository = usersRepository; - this.sieveRepository = sieveRepository; - } - - @Override - public void close() throws IOException { - } - - @Override - public void addUser(String userName, String password) throws Exception { - usersRepository.addUser(userName, password); - } - - @Override - public void removeUser(String username) throws Exception { - usersRepository.removeUser(username); - } - - @Override - public String[] listUsers() throws Exception { - return Iterables.toArray(ImmutableList.copyOf(usersRepository.list()), String.class); - } - - @Override - public void setPassword(String userName, String password) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void addDomain(String domain) throws Exception { - domainList.addDomain(domain); - } - - @Override - public boolean containsDomain(String domain) throws Exception { - return domainList.containsDomain(domain); - } - - @Override - public void removeDomain(String domain) throws Exception { - domainList.removeDomain(domain); - } - - @Override - public String[] listDomains() throws Exception { - return domainList.getDomains(); - } - - @Override - public Map<String, Mappings> listMappings() throws Exception { - throw new NotImplementedException(); - } - - @Override - public void addAddressMapping(String user, String domain, String toAddress) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void removeAddressMapping(String user, String domain, String fromAddress) throws Exception { - throw new NotImplementedException(); - } - - @Override - public Mappings listUserDomainMappings(String user, String domain) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void addRegexMapping(String user, String domain, String regex) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void removeRegexMapping(String user, String domain, String regex) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void copyMailbox(String srcBean, String dstBean) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void deleteUserMailboxesNames(String user) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void createMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - mailboxManager.createMailbox(new MailboxPath(namespace, user, name), mailboxSession); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - @Override - public Mailbox<CassandraId> getMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - MailboxMapper<CassandraId> mailboxMapper = mailboxMapperFactory.getMailboxMapper(mailboxSession); - return mailboxMapper.findMailboxByPath(new MailboxPath(namespace, user, name)); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - private void closeSession(MailboxSession session) { - if (session != null) { - mailboxManager.endProcessingRequest(session); - try { - mailboxManager.logout(session, true); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } - } - } - - @Override - public Collection<String> listUserMailboxes(String user) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - return searchUserMailboxes(user, mailboxSession) - .stream() - .map(MailboxMetaData::getPath) - .map(MailboxPath::getName) - .collect(Collectors.toList()); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession session) throws MailboxException { - return mailboxManager.search( - new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""), - "*", - session.getPathDelimiter()), - session); - } - - @Override - public void deleteMailbox(String namespace, String user, String name) { - MailboxSession mailboxSession = null; - try { - mailboxSession = mailboxManager.createSystemSession(user, LOGGER); - mailboxManager.startProcessingRequest(mailboxSession); - mailboxManager.deleteMailbox(new MailboxPath(namespace, user, name), mailboxSession); - } catch (MailboxException e) { - throw Throwables.propagate(e); - } finally { - closeSession(mailboxSession); - } - } - - @Override - public String getQuotaRoot(String namespace, String user, String name) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public SerializableQuota getMessageCountQuota(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public SerializableQuota getStorageQuota(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getMaxMessageCount(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getMaxStorage(String quotaRoot) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getDefaultMaxMessageCount() throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public long getDefaultMaxStorage() throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setMaxMessageCount(String quotaRoot, long maxMessageCount) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setMaxStorage(String quotaRoot, long maxSize) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setDefaultMaxMessageCount(long maxDefaultMessageCount) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void setDefaultMaxStorage(long maxDefaultSize) throws MailboxException { - throw new NotImplementedException(); - } - - @Override - public void appendMessage(String username, MailboxPath mailboxPath, InputStream message, Date internalDate, boolean isRecent, Flags flags) - throws MailboxException { - - MailboxSession mailboxSession = mailboxManager.createSystemSession(username, LOGGER); - MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession); - messageManager.appendMessage(message, internalDate, mailboxSession, isRecent, flags); - } - - @Override - public void reIndexMailbox(String namespace, String user, String name) throws Exception { - throw new NotImplementedException(); - } - - @Override - public void reIndexAll() throws Exception { - throw new NotImplementedException(); - } - - @Override - public long getSieveQuota() throws Exception { - return sieveRepository.getQuota(); - } - - @Override - public void setSieveQuota(long quota) throws Exception { - sieveRepository.setQuota(quota); - } - - @Override - public void removeSieveQuota() throws Exception { - sieveRepository.removeQuota(); - } - - @Override - public long getSieveQuota(String user) throws Exception { - return sieveRepository.getQuota(user); - } - - @Override - public void setSieveQuota(String user, long quota) throws Exception { - sieveRepository.setQuota(user, quota); - } - - @Override - public void removeSieveQuota(String user) throws Exception { - sieveRepository.removeQuota(user); - } -} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org