JAMES-2386 Datasource validation is configurable
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5e10c35d Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5e10c35d Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5e10c35d Branch: refs/heads/master Commit: 5e10c35d41ee10dd1717905314786a4937d0f71d Parents: bfa5e42 Author: Simon Levesque <si...@foilen.com> Authored: Tue May 1 07:30:13 2018 -0400 Committer: benwa <btell...@linagora.com> Committed: Tue May 8 09:16:07 2018 +0700 ---------------------------------------------------------------------- .../apache/james/backends/jpa/JPAConstants.java | 26 ++++++++++ .../destination/conf/james-database.properties | 8 ++- .../destination/conf/james-database.properties | 8 ++- .../resources/META-INF/spring/mailbox-jpa.xml | 3 ++ .../main/resources/james-database.properties | 22 ++++++++- .../main/resources/james-database.properties | 8 ++- .../java/org/apache/james/JPAConfiguration.java | 45 ++++++++++++++++- .../james/modules/mailbox/JPAMailboxModule.java | 18 ++++++- .../JPAJamesServerWithSqlValidationTest.java | 40 +++++++++++++++ ...JPAConfigurationModuleWithSqlValidation.java | 52 ++++++++++++++++++++ .../james-database.properties | 8 ++- .../java/org/apache/james/JPAConfiguration.java | 45 ++++++++++++++++- .../META-INF/org/apache/james/spring-server.xml | 3 ++ .../main/resources/OSGI-INF/blueprint/jdbc.xml | 3 ++ 14 files changed, 279 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConstants.java ---------------------------------------------------------------------- diff --git a/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConstants.java b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConstants.java new file mode 100644 index 0000000..f90b032 --- /dev/null +++ b/backends-common/jpa/src/main/java/org/apache/james/backends/jpa/JPAConstants.java @@ -0,0 +1,26 @@ +/**************************************************************** + * 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.backends.jpa; + +public class JPAConstants { + + public static final int VALIDATION_NO_TIMEOUT = -1; + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/dockerfiles/run/guice/jpa/destination/conf/james-database.properties ---------------------------------------------------------------------- diff --git a/dockerfiles/run/guice/jpa/destination/conf/james-database.properties b/dockerfiles/run/guice/jpa/destination/conf/james-database.properties index b3ac7eb..22770d0 100644 --- a/dockerfiles/run/guice/jpa/destination/conf/james-database.properties +++ b/dockerfiles/run/guice/jpa/destination/conf/james-database.properties @@ -37,4 +37,10 @@ vendorAdapter.database=DERBY # See: # http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming # -openjpa.streaming=false \ No newline at end of file +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/5e10c35d/dockerfiles/run/spring/destination/conf/james-database.properties ---------------------------------------------------------------------- diff --git a/dockerfiles/run/spring/destination/conf/james-database.properties b/dockerfiles/run/spring/destination/conf/james-database.properties index b3ac7eb..22770d0 100644 --- a/dockerfiles/run/spring/destination/conf/james-database.properties +++ b/dockerfiles/run/spring/destination/conf/james-database.properties @@ -37,4 +37,10 @@ vendorAdapter.database=DERBY # See: # http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming # -openjpa.streaming=false \ No newline at end of file +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/5e10c35d/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml index 53a014e..cb0f321 100644 --- a/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml +++ b/mailbox/jpa/src/main/resources/META-INF/spring/mailbox-jpa.xml @@ -78,6 +78,9 @@ <property name="url" value="${database.url}" /> <property name="username" value="${database.username}" /> <property name="password" value="${database.password}" /> + <property name="testOnBorrow" value="${datasource.testOnBorrow:false}" /> + <property name="validationQueryTimeout" value="${datasource.validationQueryTimeoutSec:-1}" /> + <property name="validationQuery" value="${datasource.validationQuery:#{null}}" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="dataSource" ref="datasource"/> http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/mailbox/jpa/src/main/resources/james-database.properties ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/main/resources/james-database.properties b/mailbox/jpa/src/main/resources/james-database.properties index 0821945..22770d0 100644 --- a/mailbox/jpa/src/main/resources/james-database.properties +++ b/mailbox/jpa/src/main/resources/james-database.properties @@ -14,13 +14,33 @@ # 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.apache.derby.jdbc.EmbeddedDriver database.url=jdbc:derby:../var/store/derby;create=true database.username=app database.password=app + +# Supported adapters are: +# DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE vendorAdapter.database=DERBY + +# 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/5e10c35d/server/app/src/main/resources/james-database.properties ---------------------------------------------------------------------- diff --git a/server/app/src/main/resources/james-database.properties b/server/app/src/main/resources/james-database.properties index b3ac7eb..22770d0 100644 --- a/server/app/src/main/resources/james-database.properties +++ b/server/app/src/main/resources/james-database.properties @@ -37,4 +37,10 @@ vendorAdapter.database=DERBY # See: # http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming # -openjpa.streaming=false \ No newline at end of file +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/5e10c35d/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 index c0f7d76..62e96c3 100644 --- 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 @@ -18,10 +18,13 @@ ****************************************************************/ 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(); } @@ -29,6 +32,10 @@ public class JPAConfiguration { 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; @@ -40,19 +47,41 @@ public class JPAConfiguration { 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); + 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) { + @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() { @@ -63,4 +92,16 @@ public class JPAConfiguration { 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/5e10c35d/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 896a1a9..eb3c310 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 @@ -19,7 +19,9 @@ 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; @@ -30,6 +32,7 @@ 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,6 +65,7 @@ import org.apache.james.modules.Names; 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; @@ -135,8 +139,17 @@ public class JPAMailboxModule extends AbstractModule { properties.put("openjpa.ConnectionDriverName", jpaConfiguration.getDriverName()); properties.put("openjpa.ConnectionURL", jpaConfiguration.getDriverURL()); - return Persistence.createEntityManagerFactory("Global", properties); + 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 @@ -146,6 +159,9 @@ public class JPAMailboxModule extends AbstractModule { 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/5e10c35d/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java new file mode 100644 index 0000000..5bdee09 --- /dev/null +++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java @@ -0,0 +1,40 @@ +/**************************************************************** + * 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.IOException; + +import org.apache.james.server.core.configuration.Configuration; + +public class JPAJamesServerWithSqlValidationTest extends JPAJamesServerTest { + + @Override + protected GuiceJamesServer createJamesServer() throws IOException { + Configuration configuration = Configuration.builder() + .workingDirectory(temporaryFolder.newFolder()) + .configurationFromClasspath() + .build(); + + return new GuiceJamesServer(configuration) + .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS) + .overrideWith(new TestJPAConfigurationModuleWithSqlValidation()); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/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 new file mode 100644 index 0000000..04e7c9d --- /dev/null +++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/TestJPAConfigurationModuleWithSqlValidation.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 TestJPAConfigurationModuleWithSqlValidation extends AbstractModule { + + private static final String JDBC_EMBEDDED_URL = "jdbc:derby:memory:mailboxintegration;create=true"; + private static final String JDBC_EMBEDDED_DRIVER = org.apache.derby.jdbc.EmbeddedDriver.class.getName(); + private static final String VALIDATION_SQL_QUERY = "VALUES 1"; + + @Override + protected void configure() { + } + + @Provides + @Singleton + JPAConfiguration provideConfiguration() throws FileNotFoundException, ConfigurationException { + return JPAConfiguration.builder() + .driverName(JDBC_EMBEDDED_DRIVER) + .driverURL(JDBC_EMBEDDED_URL) + .testOnBorrow(true) + .validationQueryTimeoutSec(2) + .validationQuery(VALIDATION_SQL_QUERY) + .build(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/server/container/guice/jpa-smtp/sample-configuration/james-database.properties ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-smtp/sample-configuration/james-database.properties b/server/container/guice/jpa-smtp/sample-configuration/james-database.properties index b3ac7eb..22770d0 100644 --- a/server/container/guice/jpa-smtp/sample-configuration/james-database.properties +++ b/server/container/guice/jpa-smtp/sample-configuration/james-database.properties @@ -37,4 +37,10 @@ vendorAdapter.database=DERBY # See: # http://openjpa.apache.org/builds/latest/docs/manual/ref_guide_mapping_jpa.html #7.11. LOB Streaming # -openjpa.streaming=false \ No newline at end of file +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/5e10c35d/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 index c0f7d76..62e96c3 100644 --- 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 @@ -18,10 +18,13 @@ ****************************************************************/ 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(); } @@ -29,6 +32,10 @@ public class JPAConfiguration { 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; @@ -40,19 +47,41 @@ public class JPAConfiguration { 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); + 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) { + @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() { @@ -63,4 +92,16 @@ public class JPAConfiguration { 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/5e10c35d/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml ---------------------------------------------------------------------- diff --git a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml index f98eae7..40f6008 100644 --- a/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml +++ b/server/container/spring/src/main/resources/META-INF/org/apache/james/spring-server.xml @@ -181,6 +181,9 @@ <property name="url" value="${database.url}"/> <property name="username" value="${database.username}"/> <property name="password" value="${database.password}"/> + <property name="testOnBorrow" value="${datasource.testOnBorrow:false}" /> + <property name="validationQueryTimeout" value="${datasource.validationQueryTimeoutSec:-1}" /> + <property name="validationQuery" value="${datasource.validationQuery:#{null}}" /> <!--The value for maxActive should always be larger than the number of spooler threads. The--> <!--reason is that a spooler thread normally requires 1 connection to process a mail, however--> <!--sometimes OpenJPA requires 1 connection to finish the processing on top of that. If--> http://git-wip-us.apache.org/repos/asf/james-project/blob/5e10c35d/server/data/data-jdbc/src/main/resources/OSGI-INF/blueprint/jdbc.xml ---------------------------------------------------------------------- diff --git a/server/data/data-jdbc/src/main/resources/OSGI-INF/blueprint/jdbc.xml b/server/data/data-jdbc/src/main/resources/OSGI-INF/blueprint/jdbc.xml index 31a20b0..2db7c88 100644 --- a/server/data/data-jdbc/src/main/resources/OSGI-INF/blueprint/jdbc.xml +++ b/server/data/data-jdbc/src/main/resources/OSGI-INF/blueprint/jdbc.xml @@ -36,6 +36,9 @@ <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> + <property name="testOnBorrow" value="${datasource.testOnBorrow:false}" /> + <property name="validationQueryTimeout" value="${datasource.validationQueryTimeoutSec:-1}" /> + <property name="validationQuery" value="${datasource.validationQuery:#{null}}" /> </bean> <service id="datasource" ref="dataSourceJames" interface="javax.sql.DataSource"> <service-properties> --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org