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:00 UTC
[1/3] james-project git commit: JAMES-2416 Share EntityManagerFactory
provider between guice products
Repository: james-project
Updated Branches:
refs/heads/master c94d35e22 -> b99d96654
JAMES-2416 Share EntityManagerFactory provider between guice products
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b99d9665
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b99d9665
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b99d9665
Branch: refs/heads/master
Commit: b99d96654dc085c953cac401c2f0f92f4de46acd
Parents: e8e9803
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Jun 7 18:33:50 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Jun 18 11:40:26 2018 +0200
----------------------------------------------------------------------
.../james/modules/data/JPAConfiguration.java | 107 +++++++++++++++++++
.../modules/data/JPAEntityManagerModule.java | 78 ++++++++++++++
.../java/org/apache/james/JPAConfiguration.java | 107 -------------------
.../james/modules/mailbox/JPAMailboxModule.java | 49 +--------
.../james/TestJPAConfigurationModule.java | 1 +
...JPAConfigurationModuleWithSqlValidation.java | 1 +
.../org/apache/james/JPAJamesServerMain.java | 6 +-
7 files changed, 191 insertions(+), 158 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b99d9665/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAConfiguration.java b/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAConfiguration.java
new file mode 100644
index 0000000..89e07fd
--- /dev/null
+++ b/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/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.modules.data;
+
+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/b99d9665/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java b/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
new file mode 100644
index 0000000..76f518f
--- /dev/null
+++ b/server/container/guice/jpa-common-guice/src/main/java/org/apache/james/modules/data/JPAEntityManagerModule.java
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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.data;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.inject.Singleton;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.backends.jpa.JPAConstants;
+import org.apache.james.utils.PropertiesProvider;
+
+import com.google.common.base.Joiner;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+public class JPAEntityManagerModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ }
+
+ @Provides
+ @Singleton
+ public EntityManagerFactory provideEntityManagerFactory(JPAConfiguration jpaConfiguration) {
+ HashMap<String, String> properties = new HashMap<>();
+
+ properties.put("openjpa.ConnectionDriverName", jpaConfiguration.getDriverName());
+ properties.put("openjpa.ConnectionURL", jpaConfiguration.getDriverURL());
+
+ List<String> connectionFactoryProperties = new ArrayList<>();
+ connectionFactoryProperties.add("TestOnBorrow=" + jpaConfiguration.isTestOnBorrow());
+ if (jpaConfiguration.getValidationQueryTimeoutSec() > 0) {
+ connectionFactoryProperties.add("ValidationTimeout=" + jpaConfiguration.getValidationQueryTimeoutSec() * 1000);
+ }
+ if (jpaConfiguration.getValidationQuery() != null) {
+ connectionFactoryProperties.add("ValidationSQL='" + jpaConfiguration.getValidationQuery() + "'");
+ }
+ properties.put("openjpa.ConnectionFactoryProperties", Joiner.on(", ").join(connectionFactoryProperties));
+
+ return Persistence.createEntityManagerFactory("Global", properties);
+ }
+
+ @Provides
+ @Singleton
+ JPAConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws FileNotFoundException, ConfigurationException {
+ PropertiesConfiguration dataSource = propertiesProvider.getConfiguration("james-database");
+ return JPAConfiguration.builder()
+ .driverName(dataSource.getString("database.driverClassName"))
+ .driverURL(dataSource.getString("database.url"))
+ .testOnBorrow(dataSource.getBoolean("datasource.testOnBorrow", false))
+ .validationQueryTimeoutSec(dataSource.getInt("datasource.validationQueryTimeoutSec", JPAConstants.VALIDATION_NO_TIMEOUT))
+ .validationQuery(dataSource.getString("datasource.validationQuery", null))
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/b99d9665/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAConfiguration.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAConfiguration.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAConfiguration.java
deleted file mode 100644
index 62e96c3..0000000
--- a/server/container/guice/jpa-guice/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/b99d9665/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
index fb8caba..91da90e 100644
--- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
+++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java
@@ -18,21 +18,10 @@
****************************************************************/
package org.apache.james.modules.mailbox;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
import javax.inject.Singleton;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.Persistence;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.JPAConfiguration;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthenticator;
import org.apache.james.adapter.mailbox.store.UserRepositoryAuthorizator;
-import org.apache.james.backends.jpa.JPAConstants;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.SubscriptionManager;
@@ -62,10 +51,9 @@ import org.apache.james.mailbox.store.mail.UidProvider;
import org.apache.james.mailbox.store.mail.model.DefaultMessageId;
import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater;
import org.apache.james.modules.Names;
+import org.apache.james.modules.data.JPAEntityManagerModule;
import org.apache.james.utils.MailboxManagerDefinition;
-import org.apache.james.utils.PropertiesProvider;
-import com.google.common.base.Joiner;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Provides;
@@ -79,6 +67,7 @@ public class JPAMailboxModule extends AbstractModule {
protected void configure() {
install(new JpaQuotaModule());
install(new JPAQuotaSearchModule());
+ install(new JPAEntityManagerModule());
bind(JPAMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
bind(OpenJPAMailboxManager.class).in(Scopes.SINGLETON);
@@ -131,38 +120,4 @@ public class JPAMailboxModule extends AbstractModule {
super("jpa-mailboxmanager", manager);
}
}
-
- @Provides
- @Singleton
- public EntityManagerFactory provideEntityManagerFactory(JPAConfiguration jpaConfiguration) {
- HashMap<String, String> properties = new HashMap<>();
-
- properties.put("openjpa.ConnectionDriverName", jpaConfiguration.getDriverName());
- properties.put("openjpa.ConnectionURL", jpaConfiguration.getDriverURL());
-
- List<String> connectionFactoryProperties = new ArrayList<>();
- connectionFactoryProperties.add("TestOnBorrow=" + jpaConfiguration.isTestOnBorrow());
- if (jpaConfiguration.getValidationQueryTimeoutSec() > 0) {
- connectionFactoryProperties.add("ValidationTimeout=" + jpaConfiguration.getValidationQueryTimeoutSec() * 1000);
- }
- if (jpaConfiguration.getValidationQuery() != null) {
- connectionFactoryProperties.add("ValidationSQL='" + jpaConfiguration.getValidationQuery() + "'");
- }
- properties.put("openjpa.ConnectionFactoryProperties", Joiner.on(", ").join(connectionFactoryProperties));
-
- return Persistence.createEntityManagerFactory("Global", properties);
- }
-
- @Provides
- @Singleton
- JPAConfiguration provideConfiguration(PropertiesProvider propertiesProvider) throws FileNotFoundException, ConfigurationException {
- PropertiesConfiguration dataSource = propertiesProvider.getConfiguration("james-database");
- return JPAConfiguration.builder()
- .driverName(dataSource.getString("database.driverClassName"))
- .driverURL(dataSource.getString("database.url"))
- .testOnBorrow(dataSource.getBoolean("datasource.testOnBorrow", false))
- .validationQueryTimeoutSec(dataSource.getInt("datasource.validationQueryTimeoutSec", JPAConstants.VALIDATION_NO_TIMEOUT))
- .validationQuery(dataSource.getString("datasource.validationQuery", null))
- .build();
- }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/b99d9665/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java
index 3fa53f6..e6694ab 100644
--- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java
+++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModule.java
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
import javax.inject.Singleton;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.modules.data.JPAConfiguration;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b99d9665/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
index 04e7c9d..b562c4a 100644
--- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
+++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.java
@@ -24,6 +24,7 @@ import java.io.FileNotFoundException;
import javax.inject.Singleton;
import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.modules.data.JPAConfiguration;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b99d9665/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 7a329f7..7defa50 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
@@ -19,9 +19,8 @@
package org.apache.james;
-import javax.persistence.EntityManagerFactory;
-
import org.apache.james.modules.data.JPADataModule;
+import org.apache.james.modules.data.JPAEntityManagerModule;
import org.apache.james.modules.protocols.ProtocolHandlerModule;
import org.apache.james.modules.protocols.SMTPServerModule;
import org.apache.james.modules.server.ActiveMQQueueModule;
@@ -34,7 +33,6 @@ 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;
@@ -52,8 +50,8 @@ public class JPAJamesServerMain {
new DefaultProcessorsConfigurationProviderModule());
public static final Module JPA_SERVER_MODULE = Modules.combine(
+ new JPAEntityManagerModule(),
new JPADataModule(),
- (binder) -> binder.bind(EntityManagerFactory.class).toProvider(OpenJPAPersistence::getEntityManagerFactory),
new ActiveMQQueueModule(),
new RawPostDequeueDecoratorModule(),
new ElasticSearchMetricReporterModule());
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/3] james-project git commit: JAMES-2416 Introduce jpa-smtp-mariaDB
guice product
Posted by ma...@apache.org.
JAMES-2416 Introduce jpa-smtp-mariaDB guice product
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e8e9803a
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e8e9803a
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e8e9803a
Branch: refs/heads/master
Commit: e8e9803a585d1c02e0af3e0e988035648226ec26
Parents: ff325c3
Author: Antoine Duprat <ad...@linagora.com>
Authored: Thu Jun 7 11:56:19 2018 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Jun 18 11:40:26 2018 +0200
----------------------------------------------------------------------
server/container/guice/jpa-smtp-mariadb/pom.xml | 133 +++++++++++++++++
.../sample-configuration/dnsservice.xml | 29 ++++
.../sample-configuration/domainlist.xml | 28 ++++
.../james-database.properties | 46 ++++++
.../sample-configuration/mailetcontainer.xml | 143 +++++++++++++++++++
.../mailrepositorystore.xml | 34 +++++
.../recipientrewritetable.xml | 27 ++++
.../sample-configuration/smtpserver.xml | 105 ++++++++++++++
.../sample-configuration/usersrepository.xml | 27 ++++
.../sample-configuration/webadmin.properties | 23 +++
.../org/apache/james/JPAJamesServerTest.java | 103 +++++++++++++
.../james/TestJPAConfigurationModule.java | 52 +++++++
.../src/test/resources/dnsservice.xml | 29 ++++
.../test/resources/fakemailrepositorystore.xml | 31 ++++
.../src/test/resources/keystore | Bin 0 -> 2245 bytes
.../src/test/resources/mailetcontainer.xml | 136 ++++++++++++++++++
.../src/test/resources/mailrepositorystore.xml | 31 ++++
.../src/test/resources/smtpserver.xml | 102 +++++++++++++
server/container/guice/pom.xml | 1 +
19 files changed, 1080 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/pom.xml b/server/container/guice/jpa-smtp-mariadb/pom.xml
new file mode 100644
index 0000000..19a1ba2
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/pom.xml
@@ -0,0 +1,133 @@
+<?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-mariadb-guice</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Apache James :: Server :: JPA + SMTP + mariaDB client - guice injection</name>
+ <description>An advanced email server - JPA backend for SMTP with guice injection</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-backends-jpa</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-jpa-smtp-common-guice</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>james-server-guice-common</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mariadb.jdbc</groupId>
+ <artifactId>mariadb-java-client</artifactId>
+ <version>2.2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>mariadb</artifactId>
+ <version>1.7.3</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-dependencies</id>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.build.directory}/${project.artifactId}.lib</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-jar</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ <configuration>
+ <finalName>${project.artifactId}</finalName>
+ <archive>
+ <manifest>
+ <addClasspath>true</addClasspath>
+ <classpathPrefix>${project.artifactId}.lib/</classpathPrefix>
+ <mainClass>org.apache.james.JPAJamesServerMain</mainClass>
+ <useUniqueVersions>false</useUniqueVersions>
+ </manifest>
+ </archive>
+ </configuration>
+ </execution>
+ <execution>
+ <id>test-jar</id>
+ <goals>
+ <goal>test-jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/dnsservice.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/domainlist.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/domainlist.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/domainlist.xml
new file mode 100644
index 0000000..8d00118
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/domainlist.xml
@@ -0,0 +1,28 @@
+<?xml version="1.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.
+ -->
+
+<domainlist class="org.apache.james.domainlist.jpa.JPADomainList">
+ <domainnames>
+ <domainname>james.apache.org</domainname>
+ </domainnames>
+ <autodetect>true</autodetect>
+ <autodetectIP>true</autodetectIP>
+ <defaultDomain>localhost</defaultDomain>
+</domainlist>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/james-database.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/james-database.properties b/server/container/guice/jpa-smtp-mariadb/sample-configuration/james-database.properties
new file mode 100644
index 0000000..209de00
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/james-database.properties
@@ -0,0 +1,46 @@
+# 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.
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+# See http://james.apache.org/server/3/config.html for usage
+
+# Use derby as default
+database.driverClassName=org.mariadb.jdbc.Driver
+database.url=jdbc:mariadb://localhost:3306/
+database.username=app
+database.password=app
+
+# Supported adapters are:
+# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
+vendorAdapter.database=mariaDB
+
+# Use streaming for Blobs
+# This is only supported on a limited set of databases atm. You should check if its supported by your DB before enable
+# it.
+#
+# See:
+# http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming
+#
+openjpa.streaming=false
+
+# Validate the data source before using it
+# datasource.testOnBorrow=true
+# datasource.validationQueryTimeoutSec=2
+# This is different per database. See https://stackoverflow.com/questions/10684244/dbcp-validationquery-for-different-databases#10684260
+# datasource.validationQuery=select 1
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailetcontainer.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailetcontainer.xml
new file mode 100644
index 0000000..909c5db
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailetcontainer.xml
@@ -0,0 +1,143 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="true">
+
+ <context>
+ <postmaster>postmaster@james.minet.net</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="true">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+ <!-- Hook on sievemanager@james.linagora.com
+ Mail send to this address will get interpreted with SIEVE Manage -->
+ <mailet match="RecipientIs=sievemanager@james.linagora.com" class="ToProcessor">
+ <processor>sieve-manager-check</processor>
+ </mailet>
+ <mailet match="HasMailAttribute=spamChecked" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="All" class="SetMailAttribute">
+ <spamChecked>true</spamChecked>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <mailet match="InSpammerBlacklist=query.bondedsender.org." class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ <!-- Check for delivery from a known spam server -->
+ <!-- This set of matchers/mailets redirect all emails from known -->
+ <!-- black holes, open relays, and spam servers to the spam processor -->
+ <!-- For this set to function properly, the spam processor must be configured. -->
+ <mailet match="InSpammerBlacklist=dnsbl.njabl.org." class="ToProcessor">
+ <processor>spam</processor>
+ <notice>550 Requested action not taken: rejected - see http://njabl.org/</notice>
+ </mailet>
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="true">
+ <mailet match="All" class="Bounce"/>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/error/</repositoryPath>
+ </mailet>
+ </processor>
+
+
+ <processor state="transport" enableJmx="true">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+ <name>X-WasSigned</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RecipientRewriteTable" />
+ <mailet match="RecipientIsLocal" class="LocalDelivery"/>
+ <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet>
+ <mailet match="SMTPAuthSuccessful" class="SetMailAttribute">
+ <RelayAllowed>true</RelayAllowed>
+ </mailet>
+ <mailet match="SentByMailet" class="SetMailAttribute">
+ <RelayAllowed>true</RelayAllowed>
+ </mailet>
+ <mailet match="HasMailAttribute=RelayAllowed" 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="true">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/spam/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="local-address-error" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/address-error/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
+ <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="true">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+ </processors>
+
+</mailetcontainer>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailrepositorystore.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailrepositorystore.xml
new file mode 100644
index 0000000..acca810
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/mailrepositorystore.xml
@@ -0,0 +1,34 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <!-- File based repositories. These repositories store all message data -->
+ <!-- in the file system. -->
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <!-- Set if the messages should be listed sorted. False by default -->
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/recipientrewritetable.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/recipientrewritetable.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/recipientrewritetable.xml
new file mode 100644
index 0000000..7e7f586
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/recipientrewritetable.xml
@@ -0,0 +1,27 @@
+<?xml version="1.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.
+ -->
+
+<!-- The default table for storing James' RecipientRewriteTable mappings. -->
+<recipientrewritetable class="org.apache.james.rrt.jpa.JPARecipientRewriteTable">
+ <recursiveMapping>true</recursiveMapping>
+ <mappingLimit>10</mappingLimit>
+ <mapping>some@domain=some</mapping>
+</recipientrewritetable>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/smtpserver.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/smtpserver.xml
new file mode 100644
index 0000000..c34fcd1
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/smtpserver.xml
@@ -0,0 +1,105 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:1465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="true" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="true">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <authorizedAddresses>0.0.0.0/0</authorizedAddresses>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/usersrepository.xml b/server/container/guice/jpa-smtp-mariadb/sample-configuration/usersrepository.xml
new file mode 100644
index 0000000..fc76107
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/usersrepository.xml
@@ -0,0 +1,27 @@
+<?xml version="1.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.
+ -->
+
+<usersrepository name="LocalUsers" class="org.apache.james.user.jpa.JPAUsersRepository">
+ <destination URL="file://users/"/>
+ <algorithm>MD5</algorithm>
+ <enableVirtualHosting>true</enableVirtualHosting>
+ <enableForwarding>true</enableForwarding>
+</usersrepository>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/sample-configuration/webadmin.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/sample-configuration/webadmin.properties b/server/container/guice/jpa-smtp-mariadb/sample-configuration/webadmin.properties
new file mode 100644
index 0000000..a9b5cc2
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/sample-configuration/webadmin.properties
@@ -0,0 +1,23 @@
+# 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.
+
+# This template file can be used as example for James Server configuration
+# DO NOT USE IT AS SUCH AND ADAPT IT TO YOUR NEEDS
+
+enabled=true
+port=8000
+host=localhost
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/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
new file mode 100644
index 0000000..bf781ce
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/JPAJamesServerTest.java
@@ -0,0 +1,103 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.channels.SocketChannel;
+import java.nio.charset.Charset;
+
+import javax.persistence.EntityManagerFactory;
+
+import org.apache.james.backends.jpa.JpaTestCluster;
+import org.apache.james.domainlist.jpa.model.JPADomain;
+import org.apache.james.mailrepository.jpa.JPAUrl;
+import org.apache.james.rrt.jpa.model.JPARecipientRewrite;
+import org.apache.james.server.core.configuration.Configuration;
+import org.apache.james.user.jpa.model.JPAUser;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+import org.testcontainers.containers.MariaDBContainer;
+
+public class JPAJamesServerTest {
+
+ private static final int SMTP_PORT = 1025;
+
+ private GuiceJamesServer server;
+ private SocketChannel socketChannel;
+
+ @Rule
+ public TemporaryFolder temporaryFolder = new TemporaryFolder();
+
+ @Rule
+ public MariaDBContainer<?> mariaDB = new MariaDBContainer<>();
+
+ @Before
+ public void setup() throws Exception {
+ server = createJamesServer(mariaDB.getJdbcUrl());
+ socketChannel = SocketChannel.open();
+ server.start();
+ }
+
+ @After
+ public void teardown() {
+ server.stop();
+ }
+
+ private org.apache.james.GuiceJamesServer createJamesServer(String mariaDBUrl) throws IOException {
+ Configuration configuration = Configuration.builder()
+ .workingDirectory(temporaryFolder.newFolder())
+ .configurationFromClasspath()
+ .build();
+
+ return new GuiceJamesServer(configuration)
+ .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS)
+ .overrideWith(
+ new TestJPAConfigurationModule(mariaDBUrl),
+ (binder) -> binder.bind(EntityManagerFactory.class)
+ .toInstance(JpaTestCluster.create(JPAUser.class, JPADomain.class, JPARecipientRewrite.class, JPAUrl.class)
+ .getEntityManagerFactory()));
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ server.stop();
+ }
+
+ @Test
+ public void connectSMTPServerShouldSendShabangOnConnect() throws Exception {
+ socketChannel.connect(new InetSocketAddress("127.0.0.1", SMTP_PORT));
+ assertThat(getServerConnectionResponse(socketChannel)).startsWith("220 JAMES Linagora's SMTP awesome Server");
+ }
+
+ private String getServerConnectionResponse(SocketChannel socketChannel) throws IOException {
+ ByteBuffer byteBuffer = ByteBuffer.allocate(1000);
+ socketChannel.read(byteBuffer);
+ byte[] bytes = byteBuffer.array();
+ return new String(bytes, Charset.forName("UTF-8"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/TestJPAConfigurationModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/TestJPAConfigurationModule.java b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/TestJPAConfigurationModule.java
new file mode 100644
index 0000000..1270b8f
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/java/org/apache/james/TestJPAConfigurationModule.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * 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 java.io.FileNotFoundException;
+
+import javax.inject.Singleton;
+
+import org.apache.commons.configuration.ConfigurationException;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+
+public class TestJPAConfigurationModule extends AbstractModule {
+
+ private static final String JDBC_EMBEDDED_DRIVER = org.mariadb.jdbc.Driver.class.getName();
+ private final String mariaDBUrl;
+
+ public TestJPAConfigurationModule(String mariaDBUrl) {
+ this.mariaDBUrl = mariaDBUrl;
+ }
+
+ @Override
+ protected void configure() {
+ }
+
+ @Provides
+ @Singleton
+ JPAConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException {
+ return JPAConfiguration.builder()
+ .driverName(JDBC_EMBEDDED_DRIVER)
+ .driverURL(mariaDBUrl)
+ .build();
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/dnsservice.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/dnsservice.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/dnsservice.xml
new file mode 100644
index 0000000..0978a00
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/dnsservice.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+ -->
+
+<dnsservice>
+ <servers>
+ <server>8.8.8.8</server>
+ <server>62.210.16.6</server>
+ </servers>
+ <autodiscover>false</autodiscover>
+ <authoritative>false</authoritative>
+ <maxcachesize>50000</maxcachesize>
+</dnsservice>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/fakemailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/fakemailrepositorystore.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/fakemailrepositorystore.xml
new file mode 100644
index 0000000..2d19a80
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/fakemailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.None">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/keystore
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/keystore b/server/container/guice/jpa-smtp-mariadb/src/test/resources/keystore
new file mode 100644
index 0000000..536a6c7
Binary files /dev/null and b/server/container/guice/jpa-smtp-mariadb/src/test/resources/keystore differ
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailetcontainer.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailetcontainer.xml
new file mode 100644
index 0000000..d0cfea7
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailetcontainer.xml
@@ -0,0 +1,136 @@
+<?xml version="1.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.
+ -->
+
+<mailetcontainer enableJmx="true">
+
+ <context>
+ <postmaster>postmaster@localhost</postmaster>
+ </context>
+
+ <spooler>
+ <threads>20</threads>
+ </spooler>
+
+ <processors>
+ <processor state="root" enableJmx="true">
+ <mailet match="All" class="PostmasterAlias"/>
+ <mailet match="RelayLimit=30" class="Null"/>
+
+ <mailet match="SMTPAuthSuccessful" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+
+ <mailet match="All" class="ToProcessor">
+ <processor>transport</processor>
+ </mailet>
+ </processor>
+
+ <processor state="error" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/error/</repositoryPath>
+ </mailet>
+ </processor>
+
+
+ <processor state="transport" enableJmx="true">
+ <mailet match="SMTPAuthSuccessful" class="SetMimeHeader">
+ <name>X-UserIsAuth</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="HasMailAttribute=org.apache.james.SMIMECheckSignature" class="SetMimeHeader">
+ <name>X-WasSigned</name>
+ <value>true</value>
+ </mailet>
+ <mailet match="All" class="RemoveMimeHeader">
+ <name>bcc</name>
+ </mailet>
+ <mailet match="All" class="RecipientRewriteTable">
+ <errorProcessor>rrt-error</errorProcessor>
+ </mailet>
+ <!-- <mailet match="HostIsLocal" class="ToProcessor">
+ <processor>local-address-error</processor>
+ <notice>550 - Requested action not taken: no such user here</notice>
+ </mailet> -->
+ <mailet match="All" class="RemoteDelivery">
+ <outgoingQueue>outgoing</outgoingQueue>
+ <delayTime>5 minutes</delayTime>
+ <delayTime>10 minutes</delayTime>
+ <delayTime>45 minutes</delayTime>
+ <delayTime>2 hours</delayTime>
+ <delayTime>3 hours</delayTime>
+ <delayTime>6 hours</delayTime>
+ <maxRetries>0</maxRetries>
+ <maxDnsProblemRetries>0</maxDnsProblemRetries>
+ <deliveryThreads>1</deliveryThreads>
+ <sendpartial>false</sendpartial>
+ <bounceProcessor>bounces</bounceProcessor>
+ </mailet>
+ <!-- mailet match="All" class="ToProcessor">
+ <processor>relay-denied</processor>
+ </mailet-->
+ </processor>
+
+ <processor state="local-address-error" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ <passThrough>true</passThrough>
+ <debug>true</debug>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/address-error/</repositoryPath>
+ </mailet>
+ </processor>
+
+ <processor state="relay-denied" enableJmx="true">
+ <mailet match="All" class="Bounce">
+ <attachment>none</attachment>
+ </mailet>
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/relay-denied/</repositoryPath>
+ <notice>Warning: You are sending an e-mail to a remote server. You must be authentified to perform such an operation</notice>
+ </mailet>
+ </processor>
+
+ <processor state="bounces" enableJmx="true">
+ <mailet match="All" class="DSNBounce">
+ <passThrough>false</passThrough>
+ </mailet>
+ </processor>
+
+ <processor state="rrt-error" enableJmx="false">
+ <mailet match="All" class="ToRepository">
+ <repositoryPath>file://var/mail/rrt-error/</repositoryPath>
+ <passThrough>true</passThrough>
+ </mailet>
+ <mailet match="IsSenderInRRTLoop" class="Null"/>
+ <mailet match="All" class="Bounce">
+ <notice>We were unable to deliver the attached message to the following recipients due to an address rewriting issue.</notice>
+ </mailet>
+ </processor>
+ </processors>
+
+</mailetcontainer>
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailrepositorystore.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailrepositorystore.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailrepositorystore.xml
new file mode 100644
index 0000000..3ca4a1d
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/mailrepositorystore.xml
@@ -0,0 +1,31 @@
+<?xml version="1.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.
+ -->
+
+<mailrepositorystore>
+ <mailrepositories>
+ <mailrepository class="org.apache.james.mailrepository.file.FileMailRepository">
+ <protocols>
+ <protocol>file</protocol>
+ </protocols>
+ <config FIFO="false" CACHEKEYS="true"/>
+ </mailrepository>
+ </mailrepositories>
+</mailrepositorystore>
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/jpa-smtp-mariadb/src/test/resources/smtpserver.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/jpa-smtp-mariadb/src/test/resources/smtpserver.xml b/server/container/guice/jpa-smtp-mariadb/src/test/resources/smtpserver.xml
new file mode 100644
index 0000000..2f83c8e
--- /dev/null
+++ b/server/container/guice/jpa-smtp-mariadb/src/test/resources/smtpserver.xml
@@ -0,0 +1,102 @@
+<?xml version="1.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.
+ -->
+
+<smtpservers>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-global</jmxName>
+ <bind>0.0.0.0:1025</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <authRequired>false</authRequired>
+ <verifyIdentity>true</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-TLS</jmxName>
+ <bind>0.0.0.0:10465</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+ <smtpserver enabled="true">
+ <jmxName>smtpserver-authenticated</jmxName>
+ <bind>0.0.0.0:1587</bind>
+ <connectionBacklog>200</connectionBacklog>
+ <tls socketTLS="false" startTLS="false">
+ <keystore>file://conf/keystore</keystore>
+ <secret>james72laBalle</secret>
+ <provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
+ <algorithm>SunX509</algorithm>
+ </tls>
+ <connectiontimeout>360</connectiontimeout>
+ <connectionLimit>0</connectionLimit>
+ <connectionLimitPerIP>0</connectionLimitPerIP>
+ <!--
+ Authorize only local users
+ -->
+ <authRequired>true</authRequired>
+ <!-- Trust authenticated users -->
+ <verifyIdentity>false</verifyIdentity>
+ <maxmessagesize>0</maxmessagesize>
+ <addressBracketsEnforcement>true</addressBracketsEnforcement>
+ <smtpGreeting>JAMES Linagora's SMTP awesome Server</smtpGreeting>
+ <handlerchain>
+ <handler class="org.apache.james.smtpserver.fastfail.ValidRcptHandler"/>
+ <handler class="org.apache.james.smtpserver.CoreCmdHandlerLoader"/>
+ </handlerchain>
+ </smtpserver>
+</smtpservers>
+
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/e8e9803a/server/container/guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml
index 52cd931..10319a4 100644
--- a/server/container/guice/pom.xml
+++ b/server/container/guice/pom.xml
@@ -45,6 +45,7 @@
<module>jpa-guice</module>
<module>jpa-smtp</module>
<module>jpa-smtp-common</module>
+ <module>jpa-smtp-mariadb</module>
<module>mailbox</module>
<module>mailbox-plugin-spamassassin</module>
<module>mailet</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/3] james-project git commit: JAMES-2416 Extract common JPA-SMTP
elements in a dedicated module
Posted by ma...@apache.org.
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