james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [05/23] james-project git commit: JAMES-2138 split webadmin modules to avoid confusion in protocols
Date Mon, 11 Sep 2017 02:36:49 GMT
JAMES-2138 split webadmin modules to avoid confusion in protocols

 - Brings consistency in the way we define Guice modules
    - Extraction of protocols, extraction of WebAdmin
    - Generalized alphabetic order sorting of Guice modules
 - Corrects the problem of WebAdmin probe injection
 - Adds Swagger routes to JPA and Memory


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

Branch: refs/heads/master
Commit: e9cb6e908f27a2eb53156e6e03a3611d41a793af
Parents: 9b3adc1
Author: Matthieu Baechler <matthieu@apache.org>
Authored: Mon Sep 4 10:55:34 2017 +0200
Committer: benwa <btellier@linagora.com>
Committed: Sat Sep 9 10:45:52 2017 +0700

----------------------------------------------------------------------
 .../smtp/host/CassandraJamesSmtpHostSystem.java |  3 +-
 .../apache/james/CassandraJamesServerMain.java  | 15 +++++----
 server/container/guice/jpa-guice/pom.xml        |  4 +++
 .../org/apache/james/JPAJamesServerMain.java    | 29 +++++++++-------
 server/container/guice/memory-guice/pom.xml     |  4 +++
 .../org/apache/james/MemoryJamesServerMain.java | 26 ++++++++++-----
 .../modules/server/SwaggerRoutesModule.java     | 35 ++++++++++++++++++++
 .../modules/server/SwaggerRoutesModules.java    | 35 --------------------
 8 files changed, 88 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/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 5dcb1ae..4909779 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
@@ -100,9 +100,10 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory
impleme
     public InMemoryDNSService getInMemoryDnsService() {
         return inMemoryDNSService;
     }
+
     protected GuiceJamesServer createJamesServer() {
         return new GuiceJamesServer()
-            .combineWith(CassandraJamesServerMain.cassandraServerModule, new SMTPServerModule(),
new ProtocolHandlerModule())
+            .combineWith(CassandraJamesServerMain.cassandraServerModule, CassandraJamesServerMain.protocols,
new ProtocolHandlerModule())
             .overrideWith(new CassandraJmapServerModule(folder::getRoot, embeddedElasticSearch,
cassandraHost, cassandraPort),
                 (binder) -> binder.bind(DNSService.class).toInstance(inMemoryDNSService));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/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 5421400..fc7b762 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
@@ -43,7 +43,7 @@ import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
-import org.apache.james.modules.server.SwaggerRoutesModules;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -51,18 +51,22 @@ import com.google.inject.util.Modules;
 
 public class CassandraJamesServerMain {
 
-    public static final Module protocols = Modules.combine(
+    public static final Module webadmin = Modules.combine(
         new CassandraRoutesModule(),
         new DataRoutesModules(),
+        new MailboxRoutesModule(),
+        new SwaggerRoutesModule(),
+        new WebAdminServerModule());
+
+    public static final Module protocols = Modules.combine(
         new IMAPServerModule(),
         new LMTPServerModule(),
-        new MailboxRoutesModule(),
         new ManageSieveServerModule(),
         new POP3ServerModule(),
         new ProtocolHandlerModule(),
         new SMTPServerModule(),
-        new SwaggerRoutesModules(),
-        new WebAdminServerModule());
+        new JMAPServerModule(),
+        webadmin);
 
     public static final Module cassandraServerModule = Modules.combine(
         new ActiveMQQueueModule(),
@@ -76,7 +80,6 @@ public class CassandraJamesServerMain {
         new CassandraUsersRepositoryModule(),
         new ElasticSearchMailboxModule(),
         new ElasticSearchMetricReporterModule(),
-        new JMAPServerModule(),
         new MailboxModule(),
         new TikaMailboxModule());
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/jpa-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/pom.xml b/server/container/guice/jpa-guice/pom.xml
index 99e7030..7104f98 100644
--- a/server/container/guice/jpa-guice/pom.xml
+++ b/server/container/guice/jpa-guice/pom.xml
@@ -113,6 +113,10 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-swagger</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
             <artifactId>james-server-jpa-common-guice</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/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 c3d89f5..e4a63b2 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
@@ -38,6 +38,7 @@ import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.NoJwtModule;
 import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -45,27 +46,31 @@ import com.google.inject.util.Modules;
 
 public class JPAJamesServerMain {
 
+    public static final Module webadmin = Modules.combine(
+        new WebAdminServerModule(),
+        new DataRoutesModules(),
+        new MailboxRoutesModule(),
+        new SwaggerRoutesModule());
+
     public static final Module protocols = Modules.combine(
         new IMAPServerModule(),
-        new ProtocolHandlerModule(),
-        new POP3ServerModule(),
-        new SMTPServerModule(),
         new LMTPServerModule(),
         new ManageSieveServerModule(),
-        new WebAdminServerModule(),
-        new DataRoutesModules(),
-        new MailboxRoutesModule());
+        new POP3ServerModule(),
+        new ProtocolHandlerModule(),
+        new SMTPServerModule(),
+        webadmin);
     
     public static final Module jpaServerModule = Modules.combine(
-        new JPAMailboxModule(),
-        new JPADataModule(),
-        new SieveFileRepositoryModule(),
         new ActiveMQQueueModule(),
-        new RawPostDequeueDecoratorModule(),
+        new DefaultProcessorsConfigurationProviderModule(),
+        new ElasticSearchMetricReporterModule(),
+        new JPADataModule(),
+        new JPAMailboxModule(),
         new MailboxModule(),
         new NoJwtModule(),
-        new DefaultProcessorsConfigurationProviderModule(),
-        new ElasticSearchMetricReporterModule());
+        new RawPostDequeueDecoratorModule(),
+        new SieveFileRepositoryModule());
 
     public static void main(String[] args) throws Exception {
         GuiceJamesServer server = new GuiceJamesServer()

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/memory-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index 5f07851..f2df5be 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -106,6 +106,10 @@
             <artifactId>james-server-guice-webadmin-mailbox</artifactId>
         </dependency>
         <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-swagger</artifactId>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/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 bfc412b..2cb650d 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
@@ -34,6 +34,7 @@ import org.apache.james.modules.server.DataRoutesModules;
 import org.apache.james.modules.server.JMXServerModule;
 import org.apache.james.modules.server.MailboxRoutesModule;
 import org.apache.james.modules.server.MemoryMailQueueModule;
+import org.apache.james.modules.server.SwaggerRoutesModule;
 import org.apache.james.modules.server.WebAdminServerModule;
 
 import com.google.inject.Module;
@@ -41,22 +42,29 @@ import com.google.inject.util.Modules;
 
 public class MemoryJamesServerMain {
 
-    public static final Module inMemoryServerModule = Modules.combine(
-            new JMAPServerModule(),
-            new IMAPServerModule(),
-            new ProtocolHandlerModule(),
-            new POP3ServerModule(),
-            new SMTPServerModule(),
-            new LMTPServerModule(),
-            new ManageSieveServerModule(),
+    public static final Module webadmin = Modules.combine(
             new WebAdminServerModule(),
             new DataRoutesModules(),
             new MailboxRoutesModule(),
+            new SwaggerRoutesModule());
+
+    public static final Module protocols = Modules.combine(
+            new IMAPServerModule(),
+            new JMAPServerModule(),
+            new LMTPServerModule(),
+            new ManageSieveServerModule(),
+            new POP3ServerModule(),
+            new ProtocolHandlerModule(),
+            new SMTPServerModule(),
+            webadmin);
+
+    public static final Module inMemoryServerModule = Modules.combine(
             new MemoryDataModule(),
             new MemoryDataJmapModule(),
             new MemoryMailboxModule(),
             new MemoryMailQueueModule(),
-            new MailboxModule());
+            new MailboxModule(),
+            protocols);
 
     public static void main(String[] args) throws Exception {
         new GuiceJamesServer()

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
new file mode 100644
index 0000000..bc25611
--- /dev/null
+++ b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModule.java
@@ -0,0 +1,35 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.modules.server;
+
+import org.apache.james.webadmin.Routes;
+import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+public class SwaggerRoutesModule extends AbstractModule {
+
+    @Override
+    protected void configure() {
+        Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(),
Routes.class);
+        routesMultibinder.addBinding().to(SwaggerRoutes.class);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/e9cb6e90/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
b/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
deleted file mode 100644
index a633c4f..0000000
--- a/server/container/guice/protocols/webadmin-swagger/src/main/java/org/apache/james/modules/server/SwaggerRoutesModules.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-
-package org.apache.james.modules.server;
-
-import org.apache.james.webadmin.Routes;
-import org.apache.james.webadmin.swagger.routes.SwaggerRoutes;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.multibindings.Multibinder;
-
-public class SwaggerRoutesModules extends AbstractModule {
-
-    @Override
-    protected void configure() {
-        Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(),
Routes.class);
-        routesMultibinder.addBinding().to(SwaggerRoutes.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