JAMES-2520 Use a probe to wrap started server state

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

Branch: refs/heads/master
Commit: 1091636363280d7f881cb3961982f92e8b60d511
Parents: 0785016
Author: Benoit Tellier <btell...@linagora.com>
Authored: Mon Aug 13 16:21:32 2018 +0700
Committer: Antoine Duprat <adup...@linagora.com>
Committed: Mon Aug 27 14:18:06 2018 +0200

----------------------------------------------------------------------
 .../smtp/host/CassandraJamesSmtpHostSystem.java |  2 +-
 .../apache/james/CassandraJamesServerMain.java  |  7 +++-
 .../org/apache/james/CassandraJmapTestRule.java |  2 +-
 .../james/JamesCapabilitiesServerTest.java      |  2 +-
 .../james/CassandraLdapJamesServerMain.java     |  7 +++-
 .../apache/james/CassandraLdapJmapTestRule.java |  2 +-
 .../java/org/apache/james/GuiceJamesServer.java | 31 ++++++++------
 .../java/org/apache/james/IsStartedProbe.java   | 43 ++++++++++++++++++++
 .../james/modules/IsStartedProbeModule.java     | 41 +++++++++++++++++++
 .../org/apache/james/JPAJamesServerMain.java    |  7 +++-
 .../org/apache/james/JPAJamesServerTest.java    |  2 +-
 .../JPAJamesServerWithSqlValidationTest.java    |  2 +-
 .../james/JamesCapabilitiesServerTest.java      |  2 +-
 .../org/apache/james/JPAJamesServerMain.java    |  7 +++-
 .../org/apache/james/JPAJamesServerTest.java    |  2 +-
 .../org/apache/james/JPAJamesServerTest.java    |  2 +-
 .../org/apache/james/MemoryJamesServerMain.java |  7 +++-
 .../org/apache/james/MemoryJmapTestRule.java    |  2 +-
 .../james/mailets/TemporaryJamesServer.java     |  2 +-
 .../jmap/cassandra/CassandraJmapExtension.java  |  2 +-
 .../cassandra/cucumber/CassandraStepdefs.java   |  2 +-
 .../james/jmap/memory/MemoryJmapExtension.java  |  2 +-
 .../jmap/memory/cucumber/MemoryStepdefs.java    |  2 +-
 23 files changed, 143 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index c640aaa..11c01fe 100644
--- 
a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ 
b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -113,7 +113,7 @@ public class CassandraJamesSmtpHostSystem extends 
ExternalSessionFactory impleme
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(
                 CassandraJamesServerMain.CASSANDRA_SERVER_CORE_MODULE,
                 SMTP_PROTOCOL_MODULE,

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
index 240cf8a..4a97ab3 100644
--- 
a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
+++ 
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java
@@ -115,8 +115,11 @@ public class CassandraJamesServerMain {
         PLUGINS);
 
     public static void main(String[] args) throws Exception {
-        Configuration configuration = 
Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        GuiceJamesServer server = new GuiceJamesServer(configuration)
+        Configuration configuration = Configuration.builder()
+            .useWorkingDirectoryEnvProperty()
+            .build();
+
+        GuiceJamesServer server = 
GuiceJamesServer.forConfiguration(configuration)
                     .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE, new 
JMXServerModule());
         server.start();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJmapTestRule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJmapTestRule.java
 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJmapTestRule.java
index 13c49e3..962f6a6 100644
--- 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJmapTestRule.java
+++ 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/CassandraJmapTestRule.java
@@ -61,7 +61,7 @@ public class CassandraJmapTestRule implements TestRule {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
             .overrideWith(binder -> 
binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
             .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index c55e634..5e60808 100644
--- 
a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ 
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -67,7 +67,7 @@ public class JamesCapabilitiesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
             .overrideWith((binder) -> 
binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
             .overrideWith(new TestElasticSearchModule(embeddedElasticSearch),

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/cassandra-ldap-guice/src/main/java/org/apache/james/CassandraLdapJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-ldap-guice/src/main/java/org/apache/james/CassandraLdapJamesServerMain.java
 
b/server/container/guice/cassandra-ldap-guice/src/main/java/org/apache/james/CassandraLdapJamesServerMain.java
index 488ac6f..25c9f64 100644
--- 
a/server/container/guice/cassandra-ldap-guice/src/main/java/org/apache/james/CassandraLdapJamesServerMain.java
+++ 
b/server/container/guice/cassandra-ldap-guice/src/main/java/org/apache/james/CassandraLdapJamesServerMain.java
@@ -34,8 +34,11 @@ public class CassandraLdapJamesServerMain {
         .with(new LdapUsersRepositoryModule());
 
     public static void main(String[] args) throws Exception {
-        Configuration configuration = 
Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        GuiceJamesServer server = new GuiceJamesServer(configuration)
+        Configuration configuration = Configuration.builder()
+            .useWorkingDirectoryEnvProperty()
+            .build();
+
+        GuiceJamesServer server = 
GuiceJamesServer.forConfiguration(configuration)
             .combineWith(cassandraLdapServerModule, new JMXServerModule());
 
         server.start();

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
 
b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
index b4b8fd0..58da40a 100644
--- 
a/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
+++ 
b/server/container/guice/cassandra-ldap-guice/src/test/java/org/apache/james/CassandraLdapJmapTestRule.java
@@ -58,7 +58,7 @@ public class CassandraLdapJmapTestRule implements TestRule {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             
.combineWith(CassandraLdapJamesServerMain.cassandraLdapServerModule)
             .overrideWith(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES))
             .overrideWith(guiceModuleTestRule.getModule())

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
index b43996c..fa37195 100644
--- 
a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
@@ -25,6 +25,7 @@ import java.util.Optional;
 import javax.annotation.PreDestroy;
 
 import org.apache.james.modules.CommonServicesModule;
+import org.apache.james.modules.IsStartedProbeModule;
 import org.apache.james.modules.MailetProcessingModule;
 import org.apache.james.onami.lifecycle.Stager;
 import org.apache.james.server.core.configuration.Configuration;
@@ -43,31 +44,37 @@ import com.google.inject.util.Modules;
 public class GuiceJamesServer {
 
     protected final Module module;
+    private final IsStartedProbe isStartedProbe;
     private Stager<PreDestroy> preDestroy;
     private GuiceProbeProvider guiceProbeProvider;
     private CleanupTasksPerformer cleanupTasksPerformer;
-    private boolean isStarted = false;
 
-    public GuiceJamesServer(Configuration configuration) {
-        this(Modules.combine(
-                        new CommonServicesModule(configuration),
-                        new MailetProcessingModule()));
+    public static GuiceJamesServer forConfiguration(Configuration 
configuration) {
+        IsStartedProbe isStartedProbe = new IsStartedProbe();
+
+        return new GuiceJamesServer(
+            isStartedProbe,
+            Modules.combine(
+                new IsStartedProbeModule(isStartedProbe),
+                new CommonServicesModule(configuration),
+                new MailetProcessingModule()));
     }
 
-    protected GuiceJamesServer(Module module) {
+    protected GuiceJamesServer(IsStartedProbe isStartedProbe, Module module) {
+        this.isStartedProbe = isStartedProbe;
         this.module = module;
     }
     
     public GuiceJamesServer combineWith(Module... modules) {
-        return new 
GuiceJamesServer(Modules.combine(Iterables.concat(Arrays.asList(module), 
Arrays.asList(modules))));
+        return new GuiceJamesServer(isStartedProbe, 
Modules.combine(Iterables.concat(Arrays.asList(module), 
Arrays.asList(modules))));
     }
 
     public GuiceJamesServer overrideWith(Module... overrides) {
-        return new GuiceJamesServer(Modules.override(module).with(overrides));
+        return new GuiceJamesServer(isStartedProbe, 
Modules.override(module).with(overrides));
     }
 
     public GuiceJamesServer overrideWith(List<Module> overrides) {
-        return new GuiceJamesServer(Modules.override(module).with(overrides));
+        return new GuiceJamesServer(isStartedProbe, 
Modules.override(module).with(overrides));
     }
 
     public void start() throws Exception {
@@ -76,19 +83,19 @@ public class GuiceJamesServer {
         injector.getInstance(ConfigurationsPerformer.class).initModules();
         guiceProbeProvider = injector.getInstance(GuiceProbeProvider.class);
         cleanupTasksPerformer = 
injector.getInstance(CleanupTasksPerformer.class);
-        isStarted = true;
+        isStartedProbe.notifyStarted();
     }
 
     public void stop() {
+        isStartedProbe.notifyStoped();
         
Optional.ofNullable(cleanupTasksPerformer).ifPresent(CleanupTasksPerformer::clean);
         if (preDestroy != null) {
             preDestroy.stage();
-            isStarted = false;
         }
     }
 
     public boolean isStarted() {
-        return isStarted;
+        return isStartedProbe.isStarted();
     }
 
     public <T extends GuiceProbe> T getProbe(Class<T> probe) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/guice-common/src/main/java/org/apache/james/IsStartedProbe.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/IsStartedProbe.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/IsStartedProbe.java
new file mode 100644
index 0000000..5cc4194
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/IsStartedProbe.java
@@ -0,0 +1,43 @@
+/****************************************************************
+ * 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 org.apache.james.utils.GuiceProbe;
+
+public class IsStartedProbe implements GuiceProbe {
+
+    private boolean isStarted;
+
+    public IsStartedProbe() {
+        isStarted = false;
+    }
+
+    public void notifyStarted() {
+        isStarted = true;
+    }
+
+    public void notifyStoped() {
+        isStarted = false;
+    }
+
+    public boolean isStarted() {
+        return isStarted;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/guice-common/src/main/java/org/apache/james/modules/IsStartedProbeModule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/guice-common/src/main/java/org/apache/james/modules/IsStartedProbeModule.java
 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/IsStartedProbeModule.java
new file mode 100644
index 0000000..6fd539b
--- /dev/null
+++ 
b/server/container/guice/guice-common/src/main/java/org/apache/james/modules/IsStartedProbeModule.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.modules;
+
+import org.apache.james.IsStartedProbe;
+import org.apache.james.utils.GuiceProbe;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+public class IsStartedProbeModule extends AbstractModule {
+    private final IsStartedProbe probe;
+
+    public IsStartedProbeModule(IsStartedProbe probe) {
+        this.probe = probe;
+    }
+
+    @Override
+    protected void configure() {
+        bind(IsStartedProbe.class).toInstance(probe);
+
+        Multibinder.newSetBinder(binder(), 
GuiceProbe.class).addBinding().toInstance(probe);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
index bd5f5cb..76580f5 100644
--- 
a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ 
b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -84,8 +84,11 @@ public class JPAJamesServerMain {
         new SpamAssassinListenerModule());
 
     public static void main(String[] args) throws Exception {
-        Configuration configuration = 
Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        GuiceJamesServer server = new GuiceJamesServer(configuration)
+        Configuration configuration = Configuration.builder()
+            .useWorkingDirectoryEnvProperty()
+            .build();
+
+        GuiceJamesServer server = 
GuiceJamesServer.forConfiguration(configuration)
                     .combineWith(JPA_SERVER_MODULE, PROTOCOLS,
                             new JMXServerModule(), 
                             new LuceneSearchMailboxModule());

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
index 220bfe1..b4acca6 100644
--- 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -66,7 +66,7 @@ public class JPAJamesServerTest extends 
AbstractJamesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, 
JPAJamesServerMain.PROTOCOLS)
             .overrideWith(new TestJPAConfigurationModule(), 
DOMAIN_LIST_CONFIGURATION_MODULE);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java
 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java
index 7a86bbc..7739338 100644
--- 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java
+++ 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java
@@ -32,7 +32,7 @@ public class JPAJamesServerWithSqlValidationTest extends 
JPAJamesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, 
JPAJamesServerMain.PROTOCOLS)
             .overrideWith(new TestJPAConfigurationModuleWithSqlValidation(), 
DOMAIN_LIST_CONFIGURATION_MODULE);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index b513fe8..12db521 100644
--- 
a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ 
b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -54,7 +54,7 @@ public class JamesCapabilitiesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE)
             .overrideWith(
                 new TestJPAConfigurationModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
 
b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
index 7defa50..af19662 100644
--- 
a/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ 
b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -57,8 +57,11 @@ public class JPAJamesServerMain {
         new ElasticSearchMetricReporterModule());
 
     public static void main(String[] args) throws Exception {
-        Configuration configuration = 
Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        GuiceJamesServer server = new GuiceJamesServer(configuration)
+        Configuration configuration = Configuration.builder()
+            .useWorkingDirectoryEnvProperty()
+            .build();
+
+        GuiceJamesServer server = 
GuiceJamesServer.forConfiguration(configuration)
                     .combineWith(JPA_SERVER_MODULE, PROTOCOLS);
         server.start();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
 
b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
index bf781ce..d8f7fde 100644
--- 
a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ 
b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -73,7 +73,7 @@ public class JPAJamesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
                 .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, 
JPAJamesServerMain.PROTOCOLS)
                 .overrideWith(
                         new TestJPAConfigurationModule(mariaDBUrl),

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
 
b/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
index 87962dd..7e192fe 100644
--- 
a/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
+++ 
b/server/container/guice/jpa-smtp/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -62,7 +62,7 @@ public class JPAJamesServerTest {
             .configurationFromClasspath()
             .build();
 
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
                 .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, 
JPAJamesServerMain.PROTOCOLS)
                 .overrideWith(
                         new TestJPAConfigurationModule(),

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
index 7c5b961..18a3f2f 100644
--- 
a/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
+++ 
b/server/container/guice/memory-guice/src/main/java/org/apache/james/MemoryJamesServerMain.java
@@ -102,8 +102,11 @@ public class MemoryJamesServerMain {
         WEBADMIN);
 
     public static void main(String[] args) throws Exception {
-        Configuration configuration = 
Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        new GuiceJamesServer(configuration)
+        Configuration configuration = Configuration.builder()
+            .useWorkingDirectoryEnvProperty()
+            .build();
+
+        GuiceJamesServer.forConfiguration(configuration)
             .combineWith(IN_MEMORY_SERVER_AGGREGATE_MODULE, new 
JMXServerModule())
             .start();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java
----------------------------------------------------------------------
diff --git 
a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java
 
b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java
index b1ac91e..d3d4588 100644
--- 
a/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java
+++ 
b/server/container/guice/memory-guice/src/test/java/org/apache/james/MemoryJmapTestRule.java
@@ -47,7 +47,7 @@ public class MemoryJmapTestRule implements TestRule {
             .workingDirectory(temporaryFolder.newFolder())
             .configurationFromClasspath()
             .build();
-        return new GuiceJamesServer(configuration)
+        return GuiceJamesServer.forConfiguration(configuration)
             
.combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
             .overrideWith(new TestJMAPServerModule(LIMIT_TO_10_MESSAGES))
             .overrideWith(binder -> 
binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
----------------------------------------------------------------------
diff --git 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
index 3337ef8..a1a7905 100644
--- 
a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
+++ 
b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/TemporaryJamesServer.java
@@ -145,7 +145,7 @@ public class TemporaryJamesServer {
         Configuration configuration = 
Configuration.builder().workingDirectory(workingDir).build();
         copyResources(Paths.get(workingDir, "conf"));
 
-        jamesServer = new GuiceJamesServer(configuration)
+        jamesServer = GuiceJamesServer.forConfiguration(configuration)
             .combineWith(serverBaseModule)
             .overrideWith((binder) -> 
binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))
             .overrideWith(additionalModules)

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
index 4c20a0f..e6095b2 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/CassandraJmapExtension.java
@@ -69,7 +69,7 @@ public class CassandraJmapExtension implements 
BeforeAllCallback, AfterAllCallba
             .configurationFromClasspath()
             .build();
         return new JamesWithSpamAssassin(
-                new GuiceJamesServer(configuration)
+            GuiceJamesServer.forConfiguration(configuration)
                     .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
                     .overrideWith(binder -> 
binder.bind(TextExtractor.class).to(PDFTextExtractor.class))
                     .overrideWith(new 
TestJMAPServerModule(LIMIT_TO_20_MESSAGES))

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
index d67daa7..633c1e3 100644
--- 
a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
+++ 
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraStepdefs.java
@@ -75,7 +75,7 @@ public class CassandraStepdefs {
             .configurationFromClasspath()
             .build();
 
-        mainStepdefs.jmapServer = new GuiceJamesServer(configuration)
+        mainStepdefs.jmapServer = 
GuiceJamesServer.forConfiguration(configuration)
             .combineWith(ALL_BUT_JMX_CASSANDRA_MODULE)
             .overrideWith(new TestJMAPServerModule(10))
             .overrideWith(new TestESMetricReporterModule())

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
index 7ff67b6..907c0bc 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/MemoryJmapExtension.java
@@ -63,7 +63,7 @@ public class MemoryJmapExtension implements 
BeforeEachCallback, AfterEachCallbac
             .build();
 
         return new JamesWithSpamAssassin(
-            new GuiceJamesServer(configuration)
+            GuiceJamesServer.forConfiguration(configuration)
                 
.combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
                 .overrideWith(new TestJMAPServerModule(LIMIT_TO_20_MESSAGES))
                 .overrideWith(binder -> 
binder.bind(PersistenceAdapter.class).to(MemoryPersistenceAdapter.class))

http://git-wip-us.apache.org/repos/asf/james-project/blob/10916363/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryStepdefs.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryStepdefs.java
 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryStepdefs.java
index 6e9ef3c..da4e493 100644
--- 
a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryStepdefs.java
+++ 
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryStepdefs.java
@@ -61,7 +61,7 @@ public class MemoryStepdefs {
             .build();
 
         mainStepdefs.messageIdFactory = new InMemoryMessageId.Factory();
-        mainStepdefs.jmapServer = new GuiceJamesServer(configuration)
+        mainStepdefs.jmapServer = 
GuiceJamesServer.forConfiguration(configuration)
                 
.combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE)
                 .overrideWith(new TestJMAPServerModule(LIMIT_TO_3_MESSAGES),
                         (binder) -> 
binder.bind(MessageId.Factory.class).toInstance(mainStepdefs.messageIdFactory))


---------------------------------------------------------------------
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