http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
new file mode 100644
index 0000000..22d8e59
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/JMAPServerModule.java
@@ -0,0 +1,75 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.jmap.JMAPModule;
+import org.apache.james.jmap.JMAPServer;
+import org.apache.james.jmap.crypto.JamesSignatureHandler;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.utils.ConfigurationPerformer;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.multibindings.Multibinder;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+import java.security.Security;
+
+public class JMAPServerModule<Id extends MailboxId> extends AbstractModule {
+
+    private final TypeLiteral<Id> type;
+
+    public JMAPServerModule(TypeLiteral<Id> type) {
+        this.type = type;
+    }
+
+    @Override
+    protected void configure() {
+        install(new JMAPModule<Id>(type));
+        Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(JMAPModuleConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class JMAPModuleConfigurationPerformer implements 
ConfigurationPerformer {
+
+        private final JMAPServer server;
+        private final JamesSignatureHandler signatureHandler;
+
+        @Inject
+        public JMAPModuleConfigurationPerformer(JMAPServer server, 
JamesSignatureHandler signatureHandler) {
+            this.server = server;
+            this.signatureHandler = signatureHandler;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            signatureHandler.init();
+            server.configure(null);
+            registerPEMWithSecurityProvider();
+        }
+
+        private void registerPEMWithSecurityProvider() {
+            Security.addProvider(new BouncyCastleProvider());
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
new file mode 100644
index 0000000..a7b7c83
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/LMTPServerModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.lmtpserver.netty.LMTPServerFactory;
+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 LMTPServerModule extends AbstractModule {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(LMTPServerModule.class);
+
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(LMTPModuleConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class LMTPModuleConfigurationPerformer implements 
ConfigurationPerformer {
+
+        private final ConfigurationProvider configurationProvider;
+        private final LMTPServerFactory lmtpServerFactory;
+
+        @Inject
+        public LMTPModuleConfigurationPerformer(ConfigurationProvider 
configurationProvider, LMTPServerFactory lmtpServerFactory) {
+            this.configurationProvider = configurationProvider;
+            this.lmtpServerFactory = lmtpServerFactory;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            lmtpServerFactory.setLog(LOGGER);
+            
lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
+            lmtpServerFactory.init();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
new file mode 100644
index 0000000..b03eb70
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ManageSieveServerModule.java
@@ -0,0 +1,63 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.managesieve.api.commands.CoreCommands;
+import org.apache.james.managesieve.core.CoreProcessor;
+import org.apache.james.managesieveserver.netty.ManageSieveServerFactory;
+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 ManageSieveServerModule extends AbstractModule {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ManageSieveServerModule.class);
+
+    @Override
+    protected void configure() {
+        bind(CoreCommands.class).to(CoreProcessor.class);
+        Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(ManageSieveModuleConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class ManageSieveModuleConfigurationPerformer implements 
ConfigurationPerformer {
+
+        private final ConfigurationProvider configurationProvider;
+        private final ManageSieveServerFactory manageSieveServerFactory;
+
+        @Inject
+        public ManageSieveModuleConfigurationPerformer(ConfigurationProvider 
configurationProvider, ManageSieveServerFactory manageSieveServerFactory) {
+            this.configurationProvider = configurationProvider;
+            this.manageSieveServerFactory = manageSieveServerFactory;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            manageSieveServerFactory.setLog(LOGGER);
+            
manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
+            manageSieveServerFactory.init();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
new file mode 100644
index 0000000..2bbe6a8
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/POP3ServerModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.pop3server.netty.POP3ServerFactory;
+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 POP3ServerModule extends AbstractModule {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(POP3ServerModule.class);
+
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(POP3ModuleConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class POP3ModuleConfigurationPerformer implements 
ConfigurationPerformer {
+
+        private final ConfigurationProvider configurationProvider;
+        private final POP3ServerFactory pop3ServerFactory;
+
+        @Inject
+        public POP3ModuleConfigurationPerformer(ConfigurationProvider 
configurationProvider, POP3ServerFactory pop3ServerFactory) {
+            this.configurationProvider = configurationProvider;
+            this.pop3ServerFactory = pop3ServerFactory;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            pop3ServerFactory.setLog(LOGGER);
+            
pop3ServerFactory.configure(configurationProvider.getConfiguration("pop3server"));
+            pop3ServerFactory.init();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
new file mode 100644
index 0000000..10d20d2
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/ProtocolHandlerModule.java
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.protocols.lib.handler.ProtocolHandlerLoader;
+import org.apache.james.utils.GuiceProtocolHandlerLoader;
+
+import com.google.inject.AbstractModule;
+
+public class ProtocolHandlerModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        bind(ProtocolHandlerLoader.class).to(GuiceProtocolHandlerLoader.class);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
new file mode 100644
index 0000000..6275822
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/SMTPServerModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.protocols;
+
+import org.apache.james.smtpserver.SendMailHandler;
+import org.apache.james.smtpserver.netty.SMTPServerFactory;
+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 SMTPServerModule extends AbstractModule {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(SMTPServerModule.class);
+
+    @Override
+    protected void configure() {
+        Multibinder.newSetBinder(binder(), 
ConfigurationPerformer.class).addBinding().to(SMTPModuleConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class SMTPModuleConfigurationPerformer implements 
ConfigurationPerformer {
+
+        private final ConfigurationProvider configurationProvider;
+        private final SMTPServerFactory smtpServerFactory;
+        private final SendMailHandler sendMailHandler;
+
+        @Inject
+        public SMTPModuleConfigurationPerformer(ConfigurationProvider 
configurationProvider,
+                SMTPServerFactory smtpServerFactory,
+            SendMailHandler sendMailHandler) {
+            this.configurationProvider = configurationProvider;
+            this.smtpServerFactory = smtpServerFactory;
+            this.sendMailHandler = sendMailHandler;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            smtpServerFactory.setLog(LOGGER);
+            
smtpServerFactory.configure(configurationProvider.getConfiguration("smtpserver"));
+            smtpServerFactory.init();
+            sendMailHandler.init(null);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
new file mode 100644
index 0000000..336dc55
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ActiveMQQueueModule.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * 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.jms.ConnectionFactory;
+
+import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.queue.activemq.ActiveMQMailQueueFactory;
+import org.apache.james.queue.api.MailQueueFactory;
+import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
+import org.apache.james.utils.GuiceGenericType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+public class ActiveMQQueueModule<Id extends MailboxId> extends AbstractModule {
+
+    private static final Logger LOGGER = 
LoggerFactory.getLogger(ActiveMQQueueModule.class);
+    private final GuiceGenericType<Id> guiceGenericType;
+
+    public ActiveMQQueueModule(TypeLiteral<Id> type) {
+        guiceGenericType = new GuiceGenericType<>(type);
+    }
+    
+    @Override
+    protected void configure() {
+        bind(MailQueueItemDecoratorFactory.class)
+        .to(guiceGenericType.newGenericType(PostDequeueDecoratorFactory.class))
+        .in(Singleton.class);
+    }
+    
+    @Provides
+    @Singleton
+    ConnectionFactory provideEmbededActiveMQ(EmbeddedActiveMQ 
embeddedActiveMQ) {
+        return embeddedActiveMQ.getConnectionFactory();
+    }
+
+    @Provides
+    @Singleton
+    public MailQueueFactory 
createActiveMailQueueFactory(ActiveMQMailQueueFactory activeMQMailQueueFactory) 
{
+        activeMQMailQueueFactory.setUseJMX(true);
+        activeMQMailQueueFactory.setLog(LOGGER);
+        activeMQMailQueueFactory.init();
+        return activeMQMailQueueFactory;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
new file mode 100644
index 0000000..a608906
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/CamelMailetContainerModule.java
@@ -0,0 +1,111 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
new file mode 100644
index 0000000..f9d3cff
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/ConfigurationProviderModule.java
@@ -0,0 +1,33 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
new file mode 100644
index 0000000..5d3b49f
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/DNSServiceModule.java
@@ -0,0 +1,62 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
new file mode 100644
index 0000000..3c34f74
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/EmbeddedActiveMQ.java
@@ -0,0 +1,107 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
new file mode 100644
index 0000000..4b4e63d
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServer.java
@@ -0,0 +1,125 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
new file mode 100644
index 0000000..f5ad703
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/JMXServerModule.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * 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.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 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);
+    }
+
+    @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/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
new file mode 100644
index 0000000..8e91d64
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/MailStoreRepositoryModule.java
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
new file mode 100644
index 0000000..f8e7815
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/QuotaModule.java
@@ -0,0 +1,38 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
new file mode 100644
index 0000000..229b479
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/server/SieveModule.java
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
new file mode 100644
index 0000000..ae2ef87
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationPerformer.java
@@ -0,0 +1,27 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
new file mode 100644
index 0000000..cf3126e
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationProvider.java
@@ -0,0 +1,30 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
new file mode 100644
index 0000000..b188774
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ConfigurationsPerformer.java
@@ -0,0 +1,41 @@
+/****************************************************************
+ * 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.Set;
+
+import com.google.inject.Inject;
+
+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/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.java
new file mode 100644
index 0000000..d7cf48c
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/ExtendedServerProbe.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.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.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;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public interface ExtendedServerProbe<Id extends MailboxId> extends ServerProbe 
{
+
+    void appendMessage(String username, MailboxPath mailboxPath, InputStream 
message, Date internalDate, boolean isRecent, Flags flags) 
+            throws BadCredentialsException, MailboxException;
+
+    Mailbox<Id> getMailbox(String namespace, String user, String name);
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
new file mode 100644
index 0000000..b28a94a
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/FileConfigurationProvider.java
@@ -0,0 +1,90 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
new file mode 100644
index 0000000..645d9b0
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericLoader.java
@@ -0,0 +1,47 @@
+/****************************************************************
+ * 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/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.java
new file mode 100644
index 0000000..2487810
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceGenericType.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.utils;
+
+import java.lang.reflect.Type;
+
+import com.google.inject.TypeLiteral;
+import com.google.inject.util.Types;
+
+public class GuiceGenericType<T> {
+
+    private final TypeLiteral<T> type;
+
+    public GuiceGenericType(TypeLiteral<T> type) {
+        this.type = type;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public <V> TypeLiteral<V> newGenericType(Class<?> base) {
+        Type newType = Types.newParameterizedType(base, type.getType());
+        return (TypeLiteral<V>) TypeLiteral.get(newType);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/517a4cfe/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
new file mode 100644
index 0000000..fe55c9c
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/GuiceMailboxManagerResolver.java
@@ -0,0 +1,59 @@
+/****************************************************************
+ * 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));
+    }
+    
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to