james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [2/2] james-project git commit: JAMES-1732 Init modules in the Guice injection order ConfigurationPerformer should also be responsible of only one Configurable
Date Tue, 17 May 2016 07:06:08 GMT
JAMES-1732 Init modules in the Guice injection order
ConfigurationPerformer should also be responsible of only one Configurable


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/52153c42
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/52153c42
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/52153c42

Branch: refs/heads/master
Commit: 52153c42f38dc09eb3ebc45ee2df9112dbb681e8
Parents: 0978270
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Wed May 4 09:01:54 2016 +0200
Committer: Antoine Duprat <antduprat@gmail.com>
Committed: Fri May 13 16:21:40 2016 +0200

----------------------------------------------------------------------
 .../modules/data/CassandraDomainListModule.java |  21 +-
 .../CassandraRecipientRewriteTableModule.java   |  21 +-
 .../data/CassandraUsersRepositoryModule.java    |  21 +-
 .../java/org/apache/james/jmap/JMAPModule.java  |  51 +++--
 .../james/modules/CommonServicesModule.java     |   1 +
 .../james/modules/ConfigurablesModule.java      |  77 +++++++
 .../modules/protocols/IMAPServerModule.java     |  22 +-
 .../modules/protocols/JMAPServerModule.java     |  27 ++-
 .../modules/protocols/LMTPServerModule.java     |  22 +-
 .../protocols/ManageSieveServerModule.java      |  22 +-
 .../modules/protocols/POP3ServerModule.java     |  22 +-
 .../modules/protocols/SMTPServerModule.java     |  24 +-
 .../server/CamelMailetContainerModule.java      |  43 ++--
 .../james/modules/server/DNSServiceModule.java  |  22 +-
 .../james/modules/server/JMXServerModule.java   |  28 ++-
 .../server/MailStoreRepositoryModule.java       |  20 +-
 .../org/apache/james/utils/Configurables.java   |  44 ++++
 .../james/utils/ConfigurationPerformer.java     |   7 +-
 .../james/utils/ConfigurationsPerformer.java    |  33 ++-
 .../utils/InMemoryMailRepositoryStore.java      |   3 +-
 .../modules/ConfigurationsPerformerTest.java    | 221 +++++++++++++++++++
 .../apache/james/utils/ConfigurablesTest.java   |  69 ++++++
 .../james/modules/data/MemoryDataModule.java    |  25 ++-
 .../src/test/java/org/apache/james/A.java       |  48 ----
 .../src/test/java/org/apache/james/B.java       |  46 ----
 .../src/test/java/org/apache/james/C.java       |  24 --
 .../org/apache/james/MemoryJamesServerTest.java |   3 +-
 .../test/java/org/apache/james/TestModule.java  |  81 -------
 28 files changed, 753 insertions(+), 295 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
index 4f815f2..6d5abcc 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraDomainListModule.java
@@ -18,14 +18,20 @@
  ****************************************************************/
 package org.apache.james.modules.data;
 
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.cassandra.CassandraDomainList;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Scopes;
@@ -57,9 +63,18 @@ public class CassandraDomainListModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            cassandraDomainList.setLog(LOGGER);
-            cassandraDomainList.configure(configurationProvider.getConfiguration("domainlist"));
+        public void initModule() {
+            try {
+                cassandraDomainList.setLog(LOGGER);
+                cassandraDomainList.configure(configurationProvider.getConfiguration("domainlist"));
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(CassandraDomainList.class);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
index d261a7d..8ff4123 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraRecipientRewriteTableModule.java
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.james.modules.data;
 
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.cassandra.CassandraRRTModule;
 import org.apache.james.rrt.cassandra.CassandraRecipientRewriteTable;
@@ -27,6 +31,8 @@ import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Scopes;
@@ -59,9 +65,18 @@ public class CassandraRecipientRewriteTableModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            recipientRewriteTable.setLog(LOGGER);
-            recipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+        public void initModule() {
+            try {
+                recipientRewriteTable.setLog(LOGGER);
+                recipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(CassandraRecipientRewriteTable.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
index ba57eb4..c61aa82 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
@@ -18,7 +18,11 @@
  ****************************************************************/
 package org.apache.james.modules.data;
 
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.cassandra.CassandraUsersRepository;
 import org.apache.james.utils.ConfigurationPerformer;
@@ -26,6 +30,8 @@ import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Scopes;
@@ -59,9 +65,18 @@ public class CassandraUsersRepositoryModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            usersRepository.setLog(LOGGER);
-            usersRepository.configure(configurationProvider.getConfiguration("usersrepository"));
+        public void initModule() {
+            try {
+                usersRepository.setLog(LOGGER);
+                usersRepository.configure(configurationProvider.getConfiguration("usersrepository"));
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(CassandraUsersRepository.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
index 9a5aee7..ca33dd9 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -20,6 +20,7 @@ package org.apache.james.jmap;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.util.List;
 import java.util.Optional;
 
 import org.apache.commons.configuration.ConfigurationException;
@@ -28,6 +29,7 @@ import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.io.FileUtils;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.jmap.methods.RequestHandler;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.utils.ConfigurationPerformer;
@@ -35,6 +37,8 @@ import org.apache.james.utils.ConfigurationProvider;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
@@ -55,9 +59,8 @@ public class JMAPModule<Id extends MailboxId> extends AbstractModule {
         install(new JMAPCommonModule());
         install(new MethodsModule<Id>(type));
         bind(RequestHandler.class).in(Singleton.class);
-        Multibinder<ConfigurationPerformer> preconditions = Multibinder.newSetBinder(binder(), ConfigurationPerformer.class);
-        preconditions.addBinding().to(MailetConfigurationPrecondition.class);
-        preconditions.addBinding().to(MoveCapabilityPrecondition.class);
+        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MailetConfigurationPrecondition.class);
+        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(MoveCapabilityPrecondition.class);
     }
 
     @Provides
@@ -91,21 +94,30 @@ public class JMAPModule<Id extends MailboxId> extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            Optional<HierarchicalConfiguration> removeMimeHeaderMailet = configurationProvider.getConfiguration("mailetcontainer")
-                .configurationAt("processors")
-                .configurationsAt("processor")
-                .stream()
-                .filter(processor -> processor.getString("[@state]").equals("transport"))
-                .flatMap(transport -> transport.configurationsAt("mailet").stream())
-                .filter(mailet -> mailet.getString("[@class]").equals("RemoveMimeHeader"))
-                .filter(mailet -> mailet.getString("[@match]").equals("All"))
-                .filter(mailet -> mailet.getProperty("name").equals("bcc"))
-                .findAny();
-            if (!removeMimeHeaderMailet.isPresent()) {
-                throw new ConfigurationException("Missing RemoveMimeHeader in mailets configuration (mailetcontainer -> processors -> transport). Should be configured to remove Bcc header");
+        public void initModule() {
+            try {
+                Optional<HierarchicalConfiguration> removeMimeHeaderMailet = configurationProvider.getConfiguration("mailetcontainer")
+                    .configurationAt("processors")
+                    .configurationsAt("processor")
+                    .stream()
+                    .filter(processor -> processor.getString("[@state]").equals("transport"))
+                    .flatMap(transport -> transport.configurationsAt("mailet").stream())
+                    .filter(mailet -> mailet.getString("[@class]").equals("RemoveMimeHeader"))
+                    .filter(mailet -> mailet.getString("[@match]").equals("All"))
+                    .filter(mailet -> mailet.getProperty("name").equals("bcc"))
+                    .findAny();
+                if (!removeMimeHeaderMailet.isPresent()) {
+                    throw new ConfigurationException("Missing RemoveMimeHeader in mailets configuration (mailetcontainer -> processors -> transport). Should be configured to remove Bcc header");
+                }
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
             }
         }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of();
+        }
     }
 
     @Singleton
@@ -119,9 +131,14 @@ public class JMAPModule<Id extends MailboxId> extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
+        public void initModule() {
             Preconditions.checkArgument(mailboxManager.getSupportedCapabilities().contains(MailboxManager.Capabilities.Move),
                     "MOVE support in MailboxManager is required by JMAP Module");
         }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of();
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
index 029362c..ccf3822 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/CommonServicesModule.java
@@ -54,6 +54,7 @@ public class CommonServicesModule<Id extends MailboxId> extends AbstractModule {
     
     @Override
     protected void configure() {
+        install(new ConfigurablesModule());
         install(new ConfigurationProviderModule());
         install(new PreDestroyModule());
         install(new DNSServiceModule());

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ConfigurablesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ConfigurablesModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ConfigurablesModule.java
new file mode 100644
index 0000000..a90547d
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/ConfigurablesModule.java
@@ -0,0 +1,77 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.io.Serializable;
+
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.utils.Configurables;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.MembersInjector;
+import com.google.inject.TypeLiteral;
+import com.google.inject.matcher.AbstractMatcher;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.spi.TypeListener;
+
+public class ConfigurablesModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        Configurables configurables = new Configurables();
+        bind(Configurables.class).toInstance(configurables);
+
+        bindListener(new SubclassesOf(Configurable.class), new ConfigurableTypeListener(configurables));
+    }
+
+    private static class ConfigurableTypeListener implements TypeListener {
+
+        private final Configurables configurables;
+
+        public ConfigurableTypeListener(Configurables configurables) {
+            this.configurables = configurables;
+        }
+
+        @Override
+        public <I> void hear(TypeLiteral<I> type, TypeEncounter<I> encounter) {
+            MembersInjector<? super I> membersInjector = x -> {
+                Class<? super I> rawType = type.getRawType();
+                configurables.add(rawType.asSubclass(Configurable.class));
+            };
+            encounter.register(membersInjector);
+        }
+    }
+
+    private static class SubclassesOf extends AbstractMatcher<TypeLiteral<?>> implements Serializable {
+
+        private final Class<?> superclass;
+
+        public SubclassesOf(Class<?> superclass) {
+            this.superclass = checkNotNull(superclass, "superclass");
+        }
+
+        @Override
+        public boolean matches(TypeLiteral<?> type) {
+            return superclass.isAssignableFrom(type.getRawType());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
index 2aea749..50a5d4e 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/protocols/IMAPServerModule.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.modules.protocols;
 
+import java.util.List;
+
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.decode.ImapDecoder;
 import org.apache.james.imap.encode.ImapEncoder;
@@ -25,6 +27,7 @@ import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
 import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
 import org.apache.james.imapserver.netty.IMAPServerFactory;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.SubscriptionManager;
 import org.apache.james.mailbox.quota.QuotaManager;
@@ -35,6 +38,8 @@ import org.apache.james.utils.ConfigurationProvider;
 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.ImmutableSet;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
@@ -94,10 +99,19 @@ public class IMAPServerModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            imapServerFactory.setLog(LOGGER);
-            imapServerFactory.configure(configurationProvider.getConfiguration("imapserver"));
-            imapServerFactory.init();
+        public void initModule()  {
+            try {
+                imapServerFactory.setLog(LOGGER);
+                imapServerFactory.configure(configurationProvider.getConfiguration("imapserver"));
+                imapServerFactory.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(IMAPServerFactory.class);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index 22d8e59..8b301bf 100644
--- 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
@@ -19,20 +19,24 @@
 
 package org.apache.james.modules.protocols;
 
+import java.security.Security;
+import java.util.List;
+
 import org.apache.james.jmap.JMAPModule;
 import org.apache.james.jmap.JMAPServer;
 import org.apache.james.jmap.crypto.JamesSignatureHandler;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.utils.ConfigurationPerformer;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 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 {
 
@@ -61,15 +65,24 @@ public class JMAPServerModule<Id extends MailboxId> extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            signatureHandler.init();
-            server.configure(null);
-            registerPEMWithSecurityProvider();
+        public void initModule() {
+            try {
+                signatureHandler.init();
+                server.configure(null);
+                registerPEMWithSecurityProvider();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
         }
 
         private void registerPEMWithSecurityProvider() {
             Security.addProvider(new BouncyCastleProvider());
         }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(JMAPServer.class);
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index a7b7c83..22fbb65 100644
--- 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
@@ -19,12 +19,17 @@
 
 package org.apache.james.modules.protocols;
 
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
 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.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -52,10 +57,19 @@ public class LMTPServerModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            lmtpServerFactory.setLog(LOGGER);
-            lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
-            lmtpServerFactory.init();
+        public void initModule() {
+            try {
+                lmtpServerFactory.setLog(LOGGER);
+                lmtpServerFactory.configure(configurationProvider.getConfiguration("lmtpserver"));
+                lmtpServerFactory.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(LMTPServerFactory.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index b03eb70..539dba6 100644
--- 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
@@ -18,6 +18,9 @@
  ****************************************************************/
 package org.apache.james.modules.protocols;
 
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.managesieve.api.commands.CoreCommands;
 import org.apache.james.managesieve.core.CoreProcessor;
 import org.apache.james.managesieveserver.netty.ManageSieveServerFactory;
@@ -26,6 +29,8 @@ import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -54,10 +59,19 @@ public class ManageSieveServerModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            manageSieveServerFactory.setLog(LOGGER);
-            manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
-            manageSieveServerFactory.init();
+        public void initModule() {
+            try {
+                manageSieveServerFactory.setLog(LOGGER);
+                manageSieveServerFactory.configure(configurationProvider.getConfiguration("managesieveserver"));
+                manageSieveServerFactory.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(ManageSieveServerFactory.class);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index 2bbe6a8..4efd481 100644
--- 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
@@ -19,12 +19,17 @@
 
 package org.apache.james.modules.protocols;
 
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
 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.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -52,10 +57,19 @@ public class POP3ServerModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            pop3ServerFactory.setLog(LOGGER);
-            pop3ServerFactory.configure(configurationProvider.getConfiguration("pop3server"));
-            pop3ServerFactory.init();
+        public void initModule() {
+            try {
+                pop3ServerFactory.setLog(LOGGER);
+                pop3ServerFactory.configure(configurationProvider.getConfiguration("pop3server"));
+                pop3ServerFactory.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(POP3ServerFactory.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index 6275822..bb5f233 100644
--- 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
@@ -19,6 +19,9 @@
 
 package org.apache.james.modules.protocols;
 
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.smtpserver.SendMailHandler;
 import org.apache.james.smtpserver.netty.SMTPServerFactory;
 import org.apache.james.utils.ConfigurationPerformer;
@@ -26,6 +29,8 @@ import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -57,11 +62,20 @@ public class SMTPServerModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            smtpServerFactory.setLog(LOGGER);
-            smtpServerFactory.configure(configurationProvider.getConfiguration("smtpserver"));
-            smtpServerFactory.init();
-            sendMailHandler.init(null);
+        public void initModule() {
+            try {
+                smtpServerFactory.setLog(LOGGER);
+                smtpServerFactory.configure(configurationProvider.getConfiguration("smtpserver"));
+                smtpServerFactory.init();
+                sendMailHandler.init(null);
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(SMTPServerFactory.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index a608906..3974f8f 100644
--- 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
@@ -19,9 +19,12 @@
 
 package org.apache.james.modules.server;
 
+import java.util.List;
+
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.domainlist.api.DomainList;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailetcontainer.api.MailProcessor;
 import org.apache.james.mailetcontainer.api.MailetLoader;
 import org.apache.james.mailetcontainer.api.MatcherLoader;
@@ -38,6 +41,8 @@ import org.apache.mailet.MailetContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Provides;
@@ -84,9 +89,9 @@ public class CamelMailetContainerModule extends AbstractModule {
 
         @Inject
         public MailetModuleConfigurationPerformer(ConfigurationProvider configurationProvider,
-                                                CamelCompositeProcessor camelCompositeProcessor,
-                                                JamesMailSpooler jamesMailSpooler,
-                                                JamesMailetContext mailetContext) {
+                CamelCompositeProcessor camelCompositeProcessor, 
+                JamesMailSpooler jamesMailSpooler, 
+                JamesMailetContext mailetContext) {
             this.configurationProvider = configurationProvider;
             this.camelCompositeProcessor = camelCompositeProcessor;
             this.jamesMailSpooler = jamesMailSpooler;
@@ -94,18 +99,26 @@ public class CamelMailetContainerModule extends AbstractModule {
         }
 
         @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);
+        public void initModule() {
+            try {
+                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);
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
         }
-    }
 
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(CamelCompositeProcessor.class, JamesMailSpooler.class, JamesMailetContext.class);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index 5d3b49f..91eb004 100644
--- 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
@@ -18,13 +18,18 @@
  ****************************************************************/
 package org.apache.james.modules.server;
 
+import java.util.List;
+
 import org.apache.james.dnsservice.api.DNSService;
 import org.apache.james.dnsservice.dnsjava.DNSJavaService;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -53,10 +58,19 @@ public class DNSServiceModule extends AbstractModule {
             this.dnsService = dnsService;
         }
 
-        public void initModule() throws Exception {
-            dnsService.setLog(LOGGER);
-            dnsService.configure(configurationProvider.getConfiguration("dnsservice"));
-            dnsService.init();
+        public void initModule() {
+            try {
+                dnsService.setLog(LOGGER);
+                dnsService.configure(configurationProvider.getConfiguration("dnsservice"));
+                dnsService.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(DNSJavaService.class);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index f5ad703..cefbb8e 100644
--- 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
@@ -19,6 +19,8 @@
 
 package org.apache.james.modules.server;
 
+import java.util.List;
+
 import org.apache.james.adapter.mailbox.MailboxCopierManagement;
 import org.apache.james.adapter.mailbox.MailboxCopierManagementMBean;
 import org.apache.james.adapter.mailbox.MailboxManagerManagement;
@@ -26,6 +28,7 @@ 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.lifecycle.api.Configurable;
 import org.apache.james.mailbox.copier.MailboxCopier;
 import org.apache.james.mailbox.copier.MailboxCopierImpl;
 import org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean;
@@ -37,6 +40,8 @@ import org.apache.james.user.lib.UsersRepositoryManagement;
 import org.apache.james.utils.ConfigurationPerformer;
 import org.apache.james.utils.GuiceMailboxManagerResolver;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -90,13 +95,22 @@ public class JMXServerModule extends AbstractModule {
         }
 
         @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);
+        public void initModule() {
+            try {
+                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);
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of();
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index 8e91d64..6a1b31f 100644
--- 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
@@ -19,7 +19,10 @@
 
 package org.apache.james.modules.server;
 
+import java.util.List;
+
 import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.mailrepository.api.MailRepository;
 import org.apache.james.mailrepository.api.MailRepositoryStore;
 import org.apache.james.mailrepository.file.FileMailRepository;
@@ -29,6 +32,8 @@ import org.apache.james.utils.InMemoryMailRepositoryStore;
 import org.apache.james.utils.MailRepositoryProvider;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -82,9 +87,18 @@ public class MailStoreRepositoryModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            javaMailRepositoryStore.configure(configurationProvider.getConfiguration("mailrepositorystore"));
-            javaMailRepositoryStore.init();
+        public void initModule() {
+            try {
+                javaMailRepositoryStore.configure(configurationProvider.getConfiguration("mailrepositorystore"));
+                javaMailRepositoryStore.init();
+            } catch (Exception e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(InMemoryMailRepositoryStore.class);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/utils/Configurables.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/Configurables.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/Configurables.java
new file mode 100644
index 0000000..7566a9e
--- /dev/null
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/Configurables.java
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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 org.apache.james.lifecycle.api.Configurable;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
+
+public class Configurables {
+
+    private final Set<Class<? extends Configurable>> configurables;
+
+    public Configurables() {
+        this.configurables = Sets.newLinkedHashSet();
+    }
+
+    public void add(Class<? extends Configurable> configurable) {
+        configurables.add(configurable);
+    }
+
+    public Set<Class<? extends Configurable>> get() {
+        return ImmutableSet.copyOf(configurables);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index ae2ef87..449ec3c 100644
--- 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
@@ -19,9 +19,14 @@
 
 package org.apache.james.utils;
 
+import java.util.List;
+
+import org.apache.james.lifecycle.api.Configurable;
 
 public interface ConfigurationPerformer {
 
-    void initModule() throws Exception;
+    void initModule();
+
+    List<Class<? extends Configurable>> forClasses();
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/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
index b188774..b9ad337 100644
--- 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
@@ -20,22 +20,47 @@
 package org.apache.james.utils;
 
 import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.james.lifecycle.api.Configurable;
 
 import com.google.inject.Inject;
 
 public class ConfigurationsPerformer {
 
     private final Set<ConfigurationPerformer> configurationPerformers;
+    private final Configurables configurables;
 
     @Inject
-    public ConfigurationsPerformer(Set<ConfigurationPerformer> configurationPerformers) throws Exception {
+    public ConfigurationsPerformer(Set<ConfigurationPerformer> configurationPerformers, Configurables configurables) {
         this.configurationPerformers = configurationPerformers;
+        this.configurables = configurables;
     }
 
     public void initModules() throws Exception {
-        for(ConfigurationPerformer configurationPerformer : configurationPerformers) {
-            configurationPerformer.initModule();
-        }
+        
+        Set<ConfigurationPerformer> processed = processConfigurables();
+        
+        processOthers(processed);
+    }
+
+    private Set<ConfigurationPerformer> processConfigurables() {
+        return configurables.get().stream()
+            .flatMap(configurable -> configurationPerformerFor(configurable))
+            .distinct()
+            .peek(ConfigurationPerformer::initModule)
+            .collect(Collectors.toSet());
     }
 
+    private Stream<ConfigurationPerformer> configurationPerformerFor(Class<? extends Configurable> configurable) {
+        return configurationPerformers.stream()
+                .filter(x -> x.forClasses().contains(configurable));
+    }
+
+    private void processOthers(Set<ConfigurationPerformer> processed) {
+        configurationPerformers.stream()
+            .filter(x -> !processed.contains(x))
+            .forEach(ConfigurationPerformer::initModule);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
index 066f57a..cda5a3b 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/utils/InMemoryMailRepositoryStore.java
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
 import com.google.inject.Inject;
 
 @Singleton
-public class InMemoryMailRepositoryStore implements MailRepositoryStore {
+public class InMemoryMailRepositoryStore implements MailRepositoryStore, Configurable {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(InMemoryMailRepositoryStore.class);
 
@@ -69,6 +69,7 @@ public class InMemoryMailRepositoryStore implements MailRepositoryStore {
             .collect(Collectors.toList());
     }
 
+    @Override
     public void configure(HierarchicalConfiguration configuration) throws ConfigurationException {
         this.configuration = configuration;
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/test/java/org/apache/james/modules/ConfigurationsPerformerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/modules/ConfigurationsPerformerTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/ConfigurationsPerformerTest.java
new file mode 100644
index 0000000..023897b
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/modules/ConfigurationsPerformerTest.java
@@ -0,0 +1,221 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.lifecycle.api.Configurable;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationsPerformer;
+import org.junit.Test;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Scopes;
+import com.google.inject.multibindings.Multibinder;
+
+public class ConfigurationsPerformerTest {
+
+    @Test
+    public void initModulesShouldNotFailWhenBindingsInWrongOrder() throws Exception {
+        Injector injector = Guice.createInjector(new ConfigurablesModule(),
+                new UnorderedBindingsModule());
+
+        injector.getInstance(ConfigurationsPerformer.class).initModules();
+
+        assertThat(injector.getInstance(A.class).isConfigured()).isTrue();
+        assertThat(injector.getInstance(B.class).isConfigured()).isTrue();
+    }
+
+    private static class UnorderedBindingsModule extends ConfigurablesModule {
+
+        @Override
+        protected void configure() {
+            bind(B.class).in(Scopes.SINGLETON);
+            bind(A.class).in(Scopes.SINGLETON);
+            bind(C.class).in(Scopes.SINGLETON);
+    
+            Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(BConfigurationPerformer.class);
+            Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(AConfigurationPerformer.class);
+        }
+    }
+
+    private static class AConfigurationPerformer implements ConfigurationPerformer {
+
+        private final A a;
+
+        @Inject
+        private AConfigurationPerformer(A a) {
+            this.a = a;
+        }
+
+        @Override
+        public void initModule() {
+            try {
+                a.configure(null);
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(A.class);
+        }
+    }
+
+    private static class BConfigurationPerformer implements ConfigurationPerformer {
+
+        private final B b;
+
+        @Inject
+        private BConfigurationPerformer(B b) {
+            this.b = b;
+        }
+
+        @Override
+        public void initModule() {
+            try {
+                b.configure(null);
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(B.class);
+        }
+    }
+
+    private static class A implements Configurable {
+
+        @SuppressWarnings("unused")
+        private final C c;
+        private boolean configured;
+
+        @Inject
+        private A(C c) {
+            this.c = c;
+            this.configured = false;
+        }
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+            configured = true;
+        }
+
+        public boolean isConfigured() {
+            return configured;
+        }
+    }
+
+    private static class B implements Configurable {
+
+        private final A a;
+        @SuppressWarnings("unused")
+        private final C c;
+        private boolean configured;
+
+        @Inject
+        private B(A a, C c) {
+            this.a = a;
+            this.c = c;
+            this.configured = false;
+        }
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+            configured = a.isConfigured();
+        }
+
+        public boolean isConfigured() {
+            return configured;
+        }
+    }
+
+    private static class C {
+    }
+
+    @Test
+    public void initModulesShouldBePerformedOneTimeWhenConfigurableModuleContainsMultipleDependencies() throws Exception {
+        Injector injector = Guice.createInjector(new ConfigurablesModule(),
+                new DualResponsibilityConfigurationPerformerModule());
+
+        injector.getInstance(ConfigurationsPerformer.class).initModules();
+
+        assertThat(injector.getInstance(A.class).isConfigured()).isTrue();
+        assertThat(injector.getInstance(B.class).isConfigured()).isTrue();
+    }
+
+    private static class DualResponsibilityConfigurationPerformer implements ConfigurationPerformer {
+
+        private final A a;
+        private final B b;
+        private boolean configured;
+
+        @Inject
+        private DualResponsibilityConfigurationPerformer(A a, B b) {
+            this.a = a;
+            this.b = b;
+            this.configured = false;
+        }
+
+        @Override
+        public void initModule() {
+            if (configured) {
+                throw new RuntimeException("Already configured");
+            }
+
+            try {
+                a.configure(null);
+                b.configure(null);
+                configured = true;
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(A.class, B.class);
+        }
+    }
+
+    private static class DualResponsibilityConfigurationPerformerModule extends ConfigurablesModule {
+
+        @Override
+        protected void configure() {
+            bind(B.class).in(Scopes.SINGLETON);
+            bind(A.class).in(Scopes.SINGLETON);
+            bind(C.class).in(Scopes.SINGLETON);
+    
+            Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(DualResponsibilityConfigurationPerformer.class);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
new file mode 100644
index 0000000..97db32b
--- /dev/null
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/utils/ConfigurablesTest.java
@@ -0,0 +1,69 @@
+/****************************************************************
+ * 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 static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.james.lifecycle.api.Configurable;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConfigurablesTest {
+
+    private Configurables sut;
+
+    @Before
+    public void setup() {
+        sut = new Configurables();
+    }
+
+    @Test
+    public void addShouldNotStoreTwoTimesWhenSameConfigurable() {
+        sut.add(MyConfigurable.class);
+        sut.add(MyConfigurable.class);
+
+        assertThat(sut.get()).hasSize(1);
+    }
+
+    @Test
+    @SuppressWarnings("unchecked")
+    public void configurablesShouldKeepTheAddedElementsOrder() {
+        sut.add(MyConfigurable.class);
+        sut.add(MyConfigurable2.class);
+
+        assertThat(sut.get()).containsExactly(MyConfigurable.class, MyConfigurable2.class);
+    }
+
+    private static class MyConfigurable implements Configurable {
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        }
+    }
+
+    private static class MyConfigurable2 implements Configurable {
+
+        @Override
+        public void configure(HierarchicalConfiguration config) throws ConfigurationException {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
index 9663255..320e24f 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/data/MemoryDataModule.java
@@ -19,8 +19,12 @@
 
 package org.apache.james.modules.data;
 
+import java.util.List;
+
+import org.apache.commons.configuration.ConfigurationException;
 import org.apache.james.domainlist.api.DomainList;
 import org.apache.james.domainlist.memory.MemoryDomainList;
+import org.apache.james.lifecycle.api.Configurable;
 import org.apache.james.rrt.api.RecipientRewriteTable;
 import org.apache.james.rrt.memory.MemoryRecipientRewriteTable;
 import org.apache.james.sieverepository.api.SieveRepository;
@@ -32,6 +36,8 @@ import org.apache.james.utils.ConfigurationProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 import com.google.inject.Scopes;
@@ -74,11 +80,20 @@ public class MemoryDataModule extends AbstractModule {
         }
 
         @Override
-        public void initModule() throws Exception {
-            memoryDomainList.setLog(LOGGER);
-            memoryDomainList.configure(configurationProvider.getConfiguration("domainlist"));
-            memoryRecipientRewriteTable.setLog(LOGGER);
-            memoryRecipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+        public void initModule() {
+            try {
+                memoryDomainList.setLog(LOGGER);
+                memoryDomainList.configure(configurationProvider.getConfiguration("domainlist"));
+                memoryRecipientRewriteTable.setLog(LOGGER);
+                memoryRecipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable"));
+            } catch (ConfigurationException e) {
+                Throwables.propagate(e);
+            }
+        }
+
+        @Override
+        public List<Class<? extends Configurable>> forClasses() {
+            return ImmutableList.of(MemoryDomainList.class, MemoryRecipientRewriteTable.class);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/test/java/org/apache/james/A.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/A.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/A.java
deleted file mode 100644
index d234d92..0000000
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/A.java
+++ /dev/null
@@ -1,48 +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;
-
-import javax.inject.Inject;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.lifecycle.api.Configurable;
-
-public class A implements Configurable {
-
-    @SuppressWarnings("unused")
-    private final C c;
-    private String domain;
-
-    @Inject
-    private A(C c) {
-        this.c = c;
-    }
-
-    @Override
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        System.out.println("Configure A");
-        domain = "configured";
-    }
-
-    public String getDomain() {
-        return domain.toLowerCase();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/test/java/org/apache/james/B.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/B.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/B.java
deleted file mode 100644
index 2576d43..0000000
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/B.java
+++ /dev/null
@@ -1,46 +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;
-
-import javax.inject.Inject;
-
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.HierarchicalConfiguration;
-import org.apache.james.lifecycle.api.Configurable;
-
-public class B implements Configurable {
-
-    private final A a;
-    @SuppressWarnings("unused")
-    private final C c;
-
-    @Inject
-    private B(A a, C c) {
-        this.a = a;
-        this.c = c;
-    }
-
-    @Override
-    public void configure(HierarchicalConfiguration config) throws ConfigurationException {
-        System.out.println("Configure B");
-        System.out.println(a.getDomain());
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/test/java/org/apache/james/C.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/C.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/C.java
deleted file mode 100644
index c6f20df..0000000
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/C.java
+++ /dev/null
@@ -1,24 +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;
-
-public class C {
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
index 3ebd55d..2926711 100644
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJamesServerTest.java
@@ -38,8 +38,7 @@ public class MemoryJamesServerTest extends AbstractJamesServerTest<InMemoryId> {
         return new GuiceJamesServer<>(new TypeLiteral<InMemoryId>(){})
                 .combineWith(MemoryJamesServerMain.inMemoryServerModule)
                 .overrideWith(new TestFilesystemModule(temporaryFolder),
-                        new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT),
-                        new TestModule());
+                        new TestJMAPServerModule(GetMessageListMethod.DEFAULT_MAXIMUM_LIMIT));
     }
     
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/52153c42/server/container/guice/memory-guice/src/test/java/org/apache/james/TestModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/TestModule.java b/server/container/guice/memory-guice/src/test/java/org/apache/james/TestModule.java
deleted file mode 100644
index 1a8f4a8..0000000
--- a/server/container/guice/memory-guice/src/test/java/org/apache/james/TestModule.java
+++ /dev/null
@@ -1,81 +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;
-
-import javax.inject.Inject;
-
-import org.apache.james.utils.ConfigurationPerformer;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Scopes;
-import com.google.inject.multibindings.Multibinder;
-
-public class TestModule extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        bind(B.class).in(Scopes.SINGLETON);
-        bind(A.class).in(Scopes.SINGLETON);
-        bind(C.class).in(Scopes.SINGLETON);
-
-        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(BConfigurationPerformer.class);
-        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(AConfigurationPerformer.class);
-    }
-
-    public static class AConfigurationPerformer implements ConfigurationPerformer<A> {
-
-        private A a;
-
-        @Inject
-        private AConfigurationPerformer(A a) {
-            this.a = a;
-        }
-
-        @Override
-        public void initModule() throws Exception {
-            a.configure(null);
-        }
-
-        @Override
-        public Class<A> forClass() {
-            return A.class;
-        }
-    }
-
-    public static class BConfigurationPerformer implements ConfigurationPerformer<B> {
-
-        private B b;
-
-        @Inject
-        private BConfigurationPerformer(B b) {
-            this.b = b;
-        }
-
-        @Override
-        public void initModule() throws Exception {
-            b.configure(null);
-        }
-
-        @Override
-        public Class<B> forClass() {
-            return B.class;
-        }
-    }
-}


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


Mime
View raw message