You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2018/06/18 09:41:02 UTC

[3/3] james-project git commit: JAMES-2416 Extract common JPA-SMTP elements in a dedicated module

JAMES-2416 Extract common JPA-SMTP elements in a dedicated module


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

Branch: refs/heads/master
Commit: ff325c33b1af67067bf99c04e2268768cb83a942
Parents: c94d35e
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Jun 7 11:45:25 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Jun 18 11:40:26 2018 +0200

----------------------------------------------------------------------
 server/container/guice/jpa-smtp-common/pom.xml  |  82 ++++++++++++++
 .../java/org/apache/james/JPAConfiguration.java | 107 +++++++++++++++++++
 .../org/apache/james/JPAJamesServerMain.java    |  68 ++++++++++++
 .../src/main/resources/META-INF/persistence.xml |  40 +++++++
 .../main/resources/defaultMailetContainer.xml   |  81 ++++++++++++++
 .../src/main/resources/logback.xml              |  22 ++++
 server/container/guice/jpa-smtp/pom.xml         |  46 +-------
 .../java/org/apache/james/JPAConfiguration.java | 107 -------------------
 .../org/apache/james/JPAJamesServerMain.java    |  68 ------------
 .../src/main/resources/META-INF/persistence.xml |  40 -------
 .../main/resources/defaultMailetContainer.xml   |  81 --------------
 .../jpa-smtp/src/main/resources/logback.xml     |  22 ----
 server/container/guice/pom.xml                  |   6 ++
 13 files changed, 407 insertions(+), 363 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-common/pom.xml b/server/container/guice/jpa-smtp-common/pom.xml
new file mode 100644
index 0000000..b70cc20
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/pom.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.james</groupId>
+        <artifactId>james-server-guice</artifactId>
+        <version>3.1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>james-server-jpa-smtp-common-guice</artifactId>
+
+    <name>Apache James :: Server :: JPA + SMTP - common guice injection</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-data-jpa</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-es-resporter</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-smtp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-data</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-mailqueue</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-guice-webadmin-mailrepository</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>james-server-jpa-common-guice</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.internetitem</groupId>
+            <artifactId>logback-elasticsearch-appender</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAConfiguration.java b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAConfiguration.java
new file mode 100644
index 0000000..62e96c3
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAConfiguration.java
@@ -0,0 +1,107 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james;
+
+import org.apache.james.backends.jpa.JPAConstants;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+
+public class JPAConfiguration {
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    public static class Builder {
+        private String driverName;
+        private String driverURL;
+        private boolean testOnBorrow;
+        private int validationQueryTimeoutSec = JPAConstants.VALIDATION_NO_TIMEOUT;
+        private String validationQuery;
+
+
+        public Builder driverName(String driverName) {
+            this.driverName = driverName;
+            return this;
+        }
+
+        public Builder driverURL(String driverURL) {
+            this.driverURL = driverURL;
+            return this;
+        }
+
+        public Builder testOnBorrow(boolean testOnBorrow) {
+            this.testOnBorrow = testOnBorrow;
+            return this;
+        }
+
+        public Builder validationQueryTimeoutSec(int validationQueryTimeoutSec) {
+            this.validationQueryTimeoutSec = validationQueryTimeoutSec;
+            return this;
+        }
+
+        public Builder validationQuery(String validationQuery) {
+            this.validationQuery = validationQuery;
+            return this;
+        }
+
+        public JPAConfiguration build() {
+            Preconditions.checkNotNull(driverName);
+            Preconditions.checkNotNull(driverURL);
+            return new JPAConfiguration(driverName, driverURL, testOnBorrow, validationQueryTimeoutSec, validationQuery);
+        }
+    }
+
+    private final String driverName;
+    private final String driverURL;
+    private final boolean testOnBorrow;
+    private final int validationQueryTimeoutSec;
+    private final String validationQuery;
+
+    @VisibleForTesting
+    JPAConfiguration(String driverName, String driverURL, boolean testOnBorrow, int validationQueryTimeoutSec, String validationQuery) {
+        this.driverName = driverName;
+        this.driverURL = driverURL;
+        this.testOnBorrow = testOnBorrow;
+        this.validationQueryTimeoutSec = validationQueryTimeoutSec;
+        this.validationQuery = validationQuery;
+    }
+
+    public String getDriverName() {
+        return driverName;
+    }
+
+    public String getDriverURL() {
+        return driverURL;
+    }
+
+    public boolean isTestOnBorrow() {
+        return testOnBorrow;
+    }
+
+    public int getValidationQueryTimeoutSec() {
+        return validationQueryTimeoutSec;
+    }
+
+    public String getValidationQuery() {
+        return validationQuery;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/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
new file mode 100644
index 0000000..7a329f7
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/src/main/java/org/apache/james/JPAJamesServerMain.java
@@ -0,0 +1,68 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.james.modules.data.JPADataModule;
+import org.apache.james.modules.protocols.ProtocolHandlerModule;
+import org.apache.james.modules.protocols.SMTPServerModule;
+import org.apache.james.modules.server.ActiveMQQueueModule;
+import org.apache.james.modules.server.DataRoutesModules;
+import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
+import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
+import org.apache.james.modules.server.MailQueueRoutesModule;
+import org.apache.james.modules.server.MailRepositoriesRoutesModule;
+import org.apache.james.modules.server.NoJwtModule;
+import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
+import org.apache.james.modules.server.WebAdminServerModule;
+import org.apache.james.server.core.configuration.Configuration;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+public class JPAJamesServerMain {
+
+    public static final Module PROTOCOLS = Modules.combine(
+        new ProtocolHandlerModule(),
+        new SMTPServerModule(),
+        new WebAdminServerModule(),
+        new DataRoutesModules(),
+        new MailRepositoriesRoutesModule(),
+        new MailQueueRoutesModule(),
+        new NoJwtModule(),
+        new DefaultProcessorsConfigurationProviderModule());
+    
+    public static final Module JPA_SERVER_MODULE = Modules.combine(
+        new JPADataModule(),
+        (binder) -> binder.bind(EntityManagerFactory.class).toProvider(OpenJPAPersistence::getEntityManagerFactory),
+        new ActiveMQQueueModule(),
+        new RawPostDequeueDecoratorModule(),
+        new ElasticSearchMetricReporterModule());
+
+    public static void main(String[] args) throws Exception {
+        Configuration configuration = Configuration.builder().useWorkingDirectoryEnvProperty().build();
+        GuiceJamesServer server = new GuiceJamesServer(configuration)
+                    .combineWith(JPA_SERVER_MODULE, PROTOCOLS);
+        server.start();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp-common/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-common/src/main/resources/META-INF/persistence.xml b/server/container/guice/jpa-smtp-common/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..0656779
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.    
+-->
+
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+    version="2.0">
+
+    <persistence-unit name="Global" transaction-type="RESOURCE_LOCAL">
+        <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
+        <class>org.apache.james.mailrepository.jpa.JPAUrl</class>
+        <class>org.apache.james.user.jpa.model.JPAUser</class>
+        <class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
+        <properties>
+            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
+            <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
+            <property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
+            <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
+        </properties>
+
+    </persistence-unit>
+
+</persistence>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp-common/src/main/resources/defaultMailetContainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-common/src/main/resources/defaultMailetContainer.xml b/server/container/guice/jpa-smtp-common/src/main/resources/defaultMailetContainer.xml
new file mode 100644
index 0000000..8ce1d59
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/src/main/resources/defaultMailetContainer.xml
@@ -0,0 +1,81 @@
+<!--
+  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.
+ -->
+
+<processors>
+    <processor state="root" enableJmx="false">
+        <mailet match="All" class="PostmasterAlias"/>
+        <mailet match="RelayLimit=30" class="Null"/>
+        <mailet match="All" class="ToProcessor">
+            <processor>transport</processor>
+        </mailet>
+    </processor>
+
+    <processor state="error" enableJmx="false">
+        <mailet match="All" class="Bounce"/>
+        <mailet match="All" class="Null"/>
+    </processor>
+
+    <processor state="transport" enableJmx="false">
+        <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+            <name>X-UserIsAuth</name>
+            <value>true</value>
+        </mailet>
+        <mailet match="All" class="RemoveMimeHeader">
+            <name>bcc</name>
+        </mailet>
+        <mailet match="All" class="RecipientRewriteTable" />
+        <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
+            <outgoingQueue>outgoing</outgoingQueue>
+            <delayTime>5000, 100000, 500000</delayTime>
+            <maxRetries>25</maxRetries>
+            <maxDnsProblemRetries>0</maxDnsProblemRetries>
+            <deliveryThreads>10</deliveryThreads>
+            <sendpartial>true</sendpartial>
+            <bounceProcessor>bounces</bounceProcessor>
+        </mailet>
+        <mailet match="All" class="ToProcessor">
+            <processor>relay-denied</processor>
+        </mailet>
+    </processor>
+
+    <processor state="spam" enableJmx="false">
+        <mailet match="All" class="Null"/>
+    </processor>
+
+    <processor state="local-address-error" enableJmx="false">
+        <mailet match="All" class="Bounce">
+            <attachment>none</attachment>
+        </mailet>
+        <mailet match="All" class="Null"/>
+    </processor>
+
+    <processor state="relay-denied" enableJmx="false">
+        <mailet match="All" class="Bounce">
+            <attachment>none</attachment>
+        </mailet>
+        <mailet match="All" class="Null"/>
+    </processor>
+
+    <processor state="bounces" enableJmx="false">
+        <mailet match="All" class="DSNBounce">
+            <passThrough>false</passThrough>
+        </mailet>
+    </processor>
+
+</processors>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp-common/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-common/src/main/resources/logback.xml b/server/container/guice/jpa-smtp-common/src/main/resources/logback.xml
new file mode 100644
index 0000000..0e1ff22
--- /dev/null
+++ b/server/container/guice/jpa-smtp-common/src/main/resources/logback.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
+                <resetJUL>true</resetJUL>
+        </contextListener>
+
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+                <encoder>
+                        <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
+                        <immediateFlush>false</immediateFlush>
+                </encoder>
+        </appender>
+
+        <root level="WARN">
+                <appender-ref ref="CONSOLE" />
+        </root>
+
+        <logger name="org.apache.james" level="INFO"/>
+
+
+</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/pom.xml b/server/container/guice/jpa-smtp/pom.xml
index 07e5ce0..477f6b7 100644
--- a/server/container/guice/jpa-smtp/pom.xml
+++ b/server/container/guice/jpa-smtp/pom.xml
@@ -48,11 +48,7 @@
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-data-jpa</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-common</artifactId>
+            <artifactId>james-server-jpa-smtp-common-guice</artifactId>
         </dependency>
         <dependency>
             <groupId>${project.groupId}</groupId>
@@ -61,47 +57,11 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-es-resporter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-smtp</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-webadmin</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-webadmin-data</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-webadmin-mailqueue</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-guice-webadmin-mailrepository</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>james-server-jpa-common-guice</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-        </dependency>
-        <dependency>
             <groupId>com.h2database</groupId>
             <artifactId>h2</artifactId>
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>com.internetitem</groupId>
-            <artifactId>logback-elasticsearch-appender</artifactId>
-        </dependency>
-        <dependency>
             <groupId>com.jayway.awaitility</groupId>
             <artifactId>awaitility</artifactId>
             <scope>test</scope>
@@ -118,10 +78,6 @@
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>com.nurkiewicz.asyncretry</groupId>
-            <artifactId>asyncretry</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.derby</groupId>
             <artifactId>derby</artifactId>
             <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAConfiguration.java b/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAConfiguration.java
deleted file mode 100644
index 62e96c3..0000000
--- a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAConfiguration.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james;
-
-import org.apache.james.backends.jpa.JPAConstants;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-
-public class JPAConfiguration {
-
-    public static Builder builder() {
-        return new Builder();
-    }
-
-    public static class Builder {
-        private String driverName;
-        private String driverURL;
-        private boolean testOnBorrow;
-        private int validationQueryTimeoutSec = JPAConstants.VALIDATION_NO_TIMEOUT;
-        private String validationQuery;
-
-
-        public Builder driverName(String driverName) {
-            this.driverName = driverName;
-            return this;
-        }
-
-        public Builder driverURL(String driverURL) {
-            this.driverURL = driverURL;
-            return this;
-        }
-
-        public Builder testOnBorrow(boolean testOnBorrow) {
-            this.testOnBorrow = testOnBorrow;
-            return this;
-        }
-
-        public Builder validationQueryTimeoutSec(int validationQueryTimeoutSec) {
-            this.validationQueryTimeoutSec = validationQueryTimeoutSec;
-            return this;
-        }
-
-        public Builder validationQuery(String validationQuery) {
-            this.validationQuery = validationQuery;
-            return this;
-        }
-
-        public JPAConfiguration build() {
-            Preconditions.checkNotNull(driverName);
-            Preconditions.checkNotNull(driverURL);
-            return new JPAConfiguration(driverName, driverURL, testOnBorrow, validationQueryTimeoutSec, validationQuery);
-        }
-    }
-
-    private final String driverName;
-    private final String driverURL;
-    private final boolean testOnBorrow;
-    private final int validationQueryTimeoutSec;
-    private final String validationQuery;
-
-    @VisibleForTesting
-    JPAConfiguration(String driverName, String driverURL, boolean testOnBorrow, int validationQueryTimeoutSec, String validationQuery) {
-        this.driverName = driverName;
-        this.driverURL = driverURL;
-        this.testOnBorrow = testOnBorrow;
-        this.validationQueryTimeoutSec = validationQueryTimeoutSec;
-        this.validationQuery = validationQuery;
-    }
-
-    public String getDriverName() {
-        return driverName;
-    }
-
-    public String getDriverURL() {
-        return driverURL;
-    }
-
-    public boolean isTestOnBorrow() {
-        return testOnBorrow;
-    }
-
-    public int getValidationQueryTimeoutSec() {
-        return validationQueryTimeoutSec;
-    }
-
-    public String getValidationQuery() {
-        return validationQuery;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
deleted file mode 100644
index 7a329f7..0000000
--- a/server/container/guice/jpa-smtp/src/main/java/org/apache/james/JPAJamesServerMain.java
+++ /dev/null
@@ -1,68 +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.persistence.EntityManagerFactory;
-
-import org.apache.james.modules.data.JPADataModule;
-import org.apache.james.modules.protocols.ProtocolHandlerModule;
-import org.apache.james.modules.protocols.SMTPServerModule;
-import org.apache.james.modules.server.ActiveMQQueueModule;
-import org.apache.james.modules.server.DataRoutesModules;
-import org.apache.james.modules.server.DefaultProcessorsConfigurationProviderModule;
-import org.apache.james.modules.server.ElasticSearchMetricReporterModule;
-import org.apache.james.modules.server.MailQueueRoutesModule;
-import org.apache.james.modules.server.MailRepositoriesRoutesModule;
-import org.apache.james.modules.server.NoJwtModule;
-import org.apache.james.modules.server.RawPostDequeueDecoratorModule;
-import org.apache.james.modules.server.WebAdminServerModule;
-import org.apache.james.server.core.configuration.Configuration;
-import org.apache.openjpa.persistence.OpenJPAPersistence;
-
-import com.google.inject.Module;
-import com.google.inject.util.Modules;
-
-public class JPAJamesServerMain {
-
-    public static final Module PROTOCOLS = Modules.combine(
-        new ProtocolHandlerModule(),
-        new SMTPServerModule(),
-        new WebAdminServerModule(),
-        new DataRoutesModules(),
-        new MailRepositoriesRoutesModule(),
-        new MailQueueRoutesModule(),
-        new NoJwtModule(),
-        new DefaultProcessorsConfigurationProviderModule());
-    
-    public static final Module JPA_SERVER_MODULE = Modules.combine(
-        new JPADataModule(),
-        (binder) -> binder.bind(EntityManagerFactory.class).toProvider(OpenJPAPersistence::getEntityManagerFactory),
-        new ActiveMQQueueModule(),
-        new RawPostDequeueDecoratorModule(),
-        new ElasticSearchMetricReporterModule());
-
-    public static void main(String[] args) throws Exception {
-        Configuration configuration = Configuration.builder().useWorkingDirectoryEnvProperty().build();
-        GuiceJamesServer server = new GuiceJamesServer(configuration)
-                    .combineWith(JPA_SERVER_MODULE, PROTOCOLS);
-        server.start();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/resources/META-INF/persistence.xml b/server/container/guice/jpa-smtp/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index 0656779..0000000
--- a/server/container/guice/jpa-smtp/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.    
--->
-
-<persistence xmlns="http://java.sun.com/xml/ns/persistence"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
-    version="2.0">
-
-    <persistence-unit name="Global" transaction-type="RESOURCE_LOCAL">
-        <class>org.apache.james.domainlist.jpa.model.JPADomain</class>
-        <class>org.apache.james.mailrepository.jpa.JPAUrl</class>
-        <class>org.apache.james.user.jpa.model.JPAUser</class>
-        <class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
-        <properties>
-            <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
-            <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=cascade, JoinForeignKeyDeleteAction=cascade"/>
-            <property name="openjpa.jdbc.SchemaFactory" value="native(ForeignKeys=true)"/>
-            <property name="openjpa.jdbc.QuerySQLCache" value="false"/>
-        </properties>
-
-    </persistence-unit>
-
-</persistence>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/src/main/resources/defaultMailetContainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/resources/defaultMailetContainer.xml b/server/container/guice/jpa-smtp/src/main/resources/defaultMailetContainer.xml
deleted file mode 100644
index 8ce1d59..0000000
--- a/server/container/guice/jpa-smtp/src/main/resources/defaultMailetContainer.xml
+++ /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.
- -->
-
-<processors>
-    <processor state="root" enableJmx="false">
-        <mailet match="All" class="PostmasterAlias"/>
-        <mailet match="RelayLimit=30" class="Null"/>
-        <mailet match="All" class="ToProcessor">
-            <processor>transport</processor>
-        </mailet>
-    </processor>
-
-    <processor state="error" enableJmx="false">
-        <mailet match="All" class="Bounce"/>
-        <mailet match="All" class="Null"/>
-    </processor>
-
-    <processor state="transport" enableJmx="false">
-        <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
-            <name>X-UserIsAuth</name>
-            <value>true</value>
-        </mailet>
-        <mailet match="All" class="RemoveMimeHeader">
-            <name>bcc</name>
-        </mailet>
-        <mailet match="All" class="RecipientRewriteTable" />
-        <mailet match="SMTPAuthSuccessful" class="RemoteDelivery">
-            <outgoingQueue>outgoing</outgoingQueue>
-            <delayTime>5000, 100000, 500000</delayTime>
-            <maxRetries>25</maxRetries>
-            <maxDnsProblemRetries>0</maxDnsProblemRetries>
-            <deliveryThreads>10</deliveryThreads>
-            <sendpartial>true</sendpartial>
-            <bounceProcessor>bounces</bounceProcessor>
-        </mailet>
-        <mailet match="All" class="ToProcessor">
-            <processor>relay-denied</processor>
-        </mailet>
-    </processor>
-
-    <processor state="spam" enableJmx="false">
-        <mailet match="All" class="Null"/>
-    </processor>
-
-    <processor state="local-address-error" enableJmx="false">
-        <mailet match="All" class="Bounce">
-            <attachment>none</attachment>
-        </mailet>
-        <mailet match="All" class="Null"/>
-    </processor>
-
-    <processor state="relay-denied" enableJmx="false">
-        <mailet match="All" class="Bounce">
-            <attachment>none</attachment>
-        </mailet>
-        <mailet match="All" class="Null"/>
-    </processor>
-
-    <processor state="bounces" enableJmx="false">
-        <mailet match="All" class="DSNBounce">
-            <passThrough>false</passThrough>
-        </mailet>
-    </processor>
-
-</processors>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/jpa-smtp/src/main/resources/logback.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp/src/main/resources/logback.xml b/server/container/guice/jpa-smtp/src/main/resources/logback.xml
deleted file mode 100644
index 0e1ff22..0000000
--- a/server/container/guice/jpa-smtp/src/main/resources/logback.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration>
-
-        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
-                <resetJUL>true</resetJUL>
-        </contextListener>
-
-        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
-                <encoder>
-                        <pattern>%d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx</pattern>
-                        <immediateFlush>false</immediateFlush>
-                </encoder>
-        </appender>
-
-        <root level="WARN">
-                <appender-ref ref="CONSOLE" />
-        </root>
-
-        <logger name="org.apache.james" level="INFO"/>
-
-
-</configuration>

http://git-wip-us.apache.org/repos/asf/james-project/blob/ff325c33/server/container/guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index ab62bb7..52cd931 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -44,6 +44,7 @@
         <module>jpa-common-guice</module>
         <module>jpa-guice</module>
         <module>jpa-smtp</module>
+        <module>jpa-smtp-common</module>
         <module>mailbox</module>
         <module>mailbox-plugin-spamassassin</module>
         <module>mailet</module>
@@ -174,6 +175,11 @@
                 <version>${project.version}</version>
             </dependency>
             <dependency>
+                <groupId>${project.groupId}</groupId>
+                <artifactId>james-server-jpa-smtp-common-guice</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
                 <groupId>com.internetitem</groupId>
                 <artifactId>logback-elasticsearch-appender</artifactId>
                 <version>1.5</version>


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