Author: timothyjward
Date: Wed Feb 17 16:51:21 2016
New Revision: 1730872

URL: http://svn.apache.org/viewvc?rev=1730872&view=rev
Log:
[tx-control] Add simple integration tests for the Local transaction control and 
JDBC resource provider

Added:
    aries/trunk/tx-control/tx-control-itests/
    aries/trunk/tx-control/tx-control-itests/.gitignore
    aries/trunk/tx-control/tx-control-itests/pom.xml
    aries/trunk/tx-control/tx-control-itests/src/
    aries/trunk/tx-control/tx-control-itests/src/test/
    aries/trunk/tx-control/tx-control-itests/src/test/java/
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/
    
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/
    
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/
    
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleTransactionTest.java
Modified:
    aries/trunk/tx-control/pom.xml
    aries/trunk/tx-control/tx-control-api/pom.xml
    aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
    
aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/JDBCConnectionProviderFactoryImpl.java
    aries/trunk/tx-control/tx-control-service-local/pom.xml

Modified: aries/trunk/tx-control/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/pom.xml?rev=1730872&r1=1730871&r2=1730872&view=diff
==============================================================================
--- aries/trunk/tx-control/pom.xml (original)
+++ aries/trunk/tx-control/pom.xml Wed Feb 17 16:51:21 2016
@@ -37,5 +37,6 @@
         <module>tx-control-api</module>
         <module>tx-control-service-local</module>
         <module>tx-control-provider-jdbc-local</module>
+        <module>tx-control-itests</module>
     </modules>
 </project>
\ No newline at end of file

Modified: aries/trunk/tx-control/tx-control-api/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-api/pom.xml?rev=1730872&r1=1730871&r2=1730872&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-api/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-api/pom.xml Wed Feb 17 16:51:21 2016
@@ -44,6 +44,7 @@
                        org.osgi.service.transaction.control.jpa,
                        *
                </aries.osgi.import.pkg>
+               <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
        </properties>
 
        <dependencies>
@@ -76,6 +77,13 @@
        <build>
                <plugins>
                        <plugin>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
                                <groupId>org.apache.aries.versioning</groupId>
                                
<artifactId>org.apache.aries.versioning.plugin</artifactId>
                                <executions>

Added: aries/trunk/tx-control/tx-control-itests/.gitignore
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/.gitignore?rev=1730872&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/.gitignore (added)
+++ aries/trunk/tx-control/tx-control-itests/.gitignore Wed Feb 17 16:51:21 2016
@@ -0,0 +1 @@
+/target/

Added: aries/trunk/tx-control/tx-control-itests/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/pom.xml?rev=1730872&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/pom.xml (added)
+++ aries/trunk/tx-control/tx-control-itests/pom.xml Wed Feb 17 16:51:21 2016
@@ -0,0 +1,217 @@
+<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/xsd/maven-4.0.0.xsd";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.aries</groupId>
+               <artifactId>parent</artifactId>
+               <version>2.0.1</version>
+               <relativePath>../../parent/pom.xml</relativePath>
+       </parent>
+       <groupId>org.apache.aries.tx-control</groupId>
+       <artifactId>org.apache.aries.tx-control-itests</artifactId>
+       <version>0.0.1-SNAPSHOT</version>
+       <name>Apache Aries Transaction Control iTests</name>
+       <description>
+        Integration tests using for the Transaction Control service
+    </description>
+
+       <scm>
+               <connection>
+            
scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-itests
+        </connection>
+               <developerConnection>
+            
scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-itests
+        </developerConnection>
+               <url>
+            
http://svn.apache.org/viewvc/aries/trunk/proxy/tx-control/tx-control-itests
+        </url>
+       </scm>
+
+
+       <properties>
+               <exam.version>3.4.0</exam.version>
+               <url.version>1.6.0</url.version>
+       </properties>
+
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.apache.felix.framework</artifactId>
+                       <scope>test</scope>
+                       <version>5.0.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.aries.tx-control</groupId>
+                       <artifactId>tx-control-api</artifactId>
+                       <scope>provided</scope>
+                       <version>0.0.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.aries.tx-control</groupId>
+                       <artifactId>tx-control-service-local</artifactId>
+                       <scope>test</scope>
+                       <version>0.0.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.felix</groupId>
+                       <artifactId>org.apache.felix.coordinator</artifactId>
+                       <scope>test</scope>
+                       <version>1.0.2</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.aries.tx-control</groupId>
+                       <artifactId>tx-control-provider-jdbc-local</artifactId>
+                       <scope>test</scope>
+                       <version>0.0.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.osgi</groupId>
+                       <artifactId>org.osgi.service.jdbc</artifactId>
+                       <version>1.0.0</version>
+               </dependency>
+               <dependency>
+                       <groupId>com.h2database</groupId>
+                       <artifactId>h2</artifactId>
+                       <version>1.4.191</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.apache.aries.testsupport</groupId>
+                       
<artifactId>org.apache.aries.testsupport.unit</artifactId>
+                       <version>2.0.0-SNAPSHOT</version>
+                       <scope>test</scope>
+               </dependency>
+
+               <!-- pax exam -->
+               <dependency>
+                       <groupId>org.slf4j</groupId>
+                       <artifactId>slf4j-api</artifactId>
+                       <version>1.7.7</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.exam</groupId>
+                       <artifactId>pax-exam</artifactId>
+                       <version>${exam.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.exam</groupId>
+                       <artifactId>pax-exam-container-forked</artifactId>
+                       <version>${exam.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.exam</groupId>
+                       <artifactId>pax-exam-junit4</artifactId>
+                       <version>${exam.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.exam</groupId>
+                       <artifactId>pax-exam-link-mvn</artifactId>
+                       <version>${exam.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.url</groupId>
+                       <artifactId>pax-url-aether</artifactId>
+                       <version>${url.version}</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>ch.qos.logback</groupId>
+                       <artifactId>logback-core</artifactId>
+                       <version>0.9.29</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>ch.qos.logback</groupId>
+                       <artifactId>logback-classic</artifactId>
+                       <version>0.9.29</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.tinybundles</groupId>
+                       <artifactId>tinybundles</artifactId>
+                       <version>2.0.0</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>javax.inject</groupId>
+                       <artifactId>javax.inject</artifactId>
+                       <version>1</version>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.logging</groupId>
+                       <artifactId>pax-logging-api</artifactId>
+                       <scope>test</scope>
+               </dependency>
+               <dependency>
+                       <groupId>org.ops4j.pax.logging</groupId>
+                       <artifactId>pax-logging-service</artifactId>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+
+       <build>
+               <plugins>
+                       <plugin>
+                               <artifactId>maven-compiler-plugin</artifactId>
+                               <version>3.1</version>
+                               <configuration>
+                                       <source>1.8</source>
+                                       <target>1.8</target>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-surefire-plugin</artifactId>
+                               <configuration>
+                                       <forkMode>pertest</forkMode>
+                               </configuration>
+                       </plugin>
+                       <plugin>
+                               <groupId>org.apache.servicemix.tooling</groupId>
+                               <artifactId>depends-maven-plugin</artifactId>
+                               <version>1.2</version>
+                               <executions>
+                                       <execution>
+                                               <id>generate-depends-file</id>
+                                               <goals>
+                                                       
<goal>generate-depends-file</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
+                       </plugin>
+               </plugins>
+       </build>
+
+       <profiles>
+               <profile>
+                       <id>ci-build-profile</id>
+                       <activation>
+                               <property>
+                                       <name>maven.repo.local</name>
+                               </property>
+                       </activation>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               
<groupId>org.apache.maven.plugins</groupId>
+                                               
<artifactId>maven-surefire-plugin</artifactId>
+                                               <configuration>
+                                                       <!-- when the local 
repo location has been specified, we need to pass 
+                                                               on this 
information to PAX mvn url -->
+                                                       
<argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine>
+                                               </configuration>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+
+</project>
\ No newline at end of file

Added: 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleTransactionTest.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleTransactionTest.java?rev=1730872&view=auto
==============================================================================
--- 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleTransactionTest.java
 (added)
+++ 
aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/SimpleTransactionTest.java
 Wed Feb 17 16:51:21 2016
@@ -0,0 +1,147 @@
+/*
+ * 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 WARRANTIESOR 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.aries.tx.control.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.ops4j.pax.exam.CoreOptions.junitBundles;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.CoreOptions.when;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Properties;
+
+import javax.inject.Inject;
+
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.osgi.service.transaction.control.TransactionControl;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProviderFactory;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class SimpleTransactionTest extends AbstractIntegrationTest {
+
+       @Inject
+       TransactionControl txControl;
+
+       @Inject
+       JDBCConnectionProviderFactory resourceProviderFactory;
+       
+       @Inject
+       DataSourceFactory dsf;
+       
+       Connection connection;
+
+       @Before
+       public void setUp() {
+               Properties jdbc = new Properties();
+               
+               jdbc.setProperty(DataSourceFactory.JDBC_URL, 
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
+               
+               connection = resourceProviderFactory.getProviderFor(dsf, jdbc, 
null).getResource(txControl);
+               
+               
+               txControl.required(() -> {
+                               Statement s = connection.createStatement();
+                               try {
+                                       s.execute("DROP TABLE TEST_TABLE");
+                               } catch (SQLException sqle) {}
+                                       s.execute("CREATE TABLE TEST_TABLE ( 
message varchar(255) )");
+                                       return null;
+                       });
+       }
+       
+       @After
+       public void tearDown() {
+
+               txControl.required(() -> connection.createStatement()
+                               .execute("DROP TABLE TEST_TABLE"));
+
+       }
+       
+       @Test
+       public void testTx() {
+               txControl.required(() -> connection.createStatement()
+                               .execute("Insert into TEST_TABLE values ( 
'Hello World!' )"));
+
+               assertEquals("Hello World!", txControl.notSupported(() -> {
+                       ResultSet rs = connection.createStatement()
+                                       .executeQuery("Select * from 
TEST_TABLE");
+                       rs.next();
+                       return rs.getString(1);
+               }));
+       }
+
+       @Test
+       public void testRollback() {
+               txControl.required(() -> {
+                       connection.createStatement().execute(
+                                       "Insert into TEST_TABLE values ( 'Hello 
World!' )");
+                       txControl.setRollbackOnly();
+                       return null;
+               });
+
+               assertEquals(Integer.valueOf(0), txControl.notSupported(() -> {
+                       ResultSet rs = connection.createStatement()
+                                       .executeQuery("Select count(*) from 
TEST_TABLE");
+                       rs.next();
+                       return rs.getInt(1);
+               }));
+       }
+
+       @Configuration
+       public Option[] configuration() {
+               String localRepo = System.getProperty("maven.repo.local");
+               if (localRepo == null) {
+                       localRepo = 
System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+               }
+               return options(junitBundles(), 
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"),
+                               when(localRepo != null)
+                                               
.useOptions(CoreOptions.vmOption("-Dorg.ops4j.pax.url.mvn.localRepository=" + 
localRepo)),
+                               mavenBundle("org.apache.aries.testsupport", 
"org.apache.aries.testsupport.unit").versionAsInProject(),
+                               mavenBundle("org.apache.felix", 
"org.apache.felix.coordinator").versionAsInProject(),
+                               mavenBundle("org.apache.aries.tx-control", 
"tx-control-service-local").versionAsInProject(),
+                               mavenBundle("com.h2database", 
"h2").versionAsInProject(),
+                               mavenBundle("org.apache.aries.tx-control", 
"tx-control-provider-jdbc-local").versionAsInProject(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-api").versionAsInProject(),
+                               mavenBundle("org.ops4j.pax.logging", 
"pax-logging-service").versionAsInProject()
+               /*
+                * vmOption
+                * 
("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+                * waitForFrameworkStartup(),
+                */
+               );
+       }
+
+}

Modified: aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml?rev=1730872&r1=1730871&r2=1730872&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml Wed Feb 17 
16:51:21 2016
@@ -40,17 +40,19 @@
                <aries.osgi.private.pkg>
                        org.apache.aries.tx.control.jdbc.*,
                        com.zaxxer.hikari,
+                       com.zaxxer.hikari.metrics,
                        com.zaxxer.hikari.pool,
                        com.zaxxer.hikari.util
                </aries.osgi.private.pkg>
                <aries.osgi.import.pkg>
                        !com.codahale.*,
-                       !com.zaxxer.hikari.metrics.*,
+                       !com.zaxxer.hikari.metrics.dropwizard,
                        !javassist.*,
-                       !javax.naming.*,
-                       
org.osgi.service.transaction.control.jdbc;version="[0.0.1,0.0.1]",
+                       
org.osgi.service.transaction.control;version="[0.0.1,0.0.2)",
+                       
org.osgi.service.transaction.control.jdbc;version="[0.0.1,0.0.2)",
                        *
                </aries.osgi.import.pkg>
+               <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
        </properties>
 
        <dependencies>

Modified: 
aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/JDBCConnectionProviderFactoryImpl.java
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/JDBCConnectionProviderFactoryImpl.java?rev=1730872&r1=1730871&r2=1730872&view=diff
==============================================================================
--- 
aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/JDBCConnectionProviderFactoryImpl.java
 (original)
+++ 
aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/local/impl/JDBCConnectionProviderFactoryImpl.java
 Wed Feb 17 16:51:21 2016
@@ -1,5 +1,6 @@
 package org.apache.aries.tx.control.jdbc.local.impl;
 
+import static java.util.Optional.ofNullable;
 import static java.util.concurrent.TimeUnit.HOURS;
 import static java.util.concurrent.TimeUnit.SECONDS;
 import static org.osgi.service.jdbc.DataSourceFactory.JDBC_URL;
@@ -32,7 +33,7 @@ public class JDBCConnectionProviderFacto
 
                DataSource unpooled;
                try {
-                       if 
(toBoolean(resourceProviderProperties.get(USE_DRIVER), false)) {
+                       if (toBoolean(resourceProviderProperties, USE_DRIVER, 
false)) {
                                unpooled = new 
DriverDataSource(dsf.createDriver(null), jdbcProperties.getProperty(JDBC_URL),
                                                jdbcProperties);
                        } else {
@@ -81,9 +82,9 @@ public class JDBCConnectionProviderFacto
        }
 
        private void checkEnlistment(Map<String, Object> 
resourceProviderProperties) {
-               if 
(toBoolean(resourceProviderProperties.get(XA_ENLISTMENT_ENABLED), false)) {
+               if (toBoolean(resourceProviderProperties, 
XA_ENLISTMENT_ENABLED, false)) {
                        throw new TransactionException("This Resource Provider 
does not support XA transactions");
-               } else if 
(!toBoolean(resourceProviderProperties.get(LOCAL_ENLISTMENT_ENABLED), true)) {
+               } else if (!toBoolean(resourceProviderProperties, 
LOCAL_ENLISTMENT_ENABLED, true)) {
                        throw new TransactionException(
                                        "This Resource Provider always enlists 
in local transactions as it does not support XA");
                }
@@ -92,18 +93,18 @@ public class JDBCConnectionProviderFacto
        private DataSource poolIfNecessary(Map<String, Object> 
resourceProviderProperties, DataSource unpooled) {
                DataSource toUse;
 
-               if 
(toBoolean(resourceProviderProperties.get(CONNECTION_POOLING_ENABLED), true)) {
+               if (toBoolean(resourceProviderProperties, 
CONNECTION_POOLING_ENABLED, true)) {
                        HikariConfig hcfg = new HikariConfig();
                        hcfg.setDataSource(unpooled);
 
                        // Sizes
-                       
hcfg.setMaximumPoolSize(toInt(resourceProviderProperties.get(MAX_CONNECTIONS), 
10));
-                       
hcfg.setMinimumIdle(toInt(resourceProviderProperties.get(MIN_CONNECTIONS), 10));
+                       
hcfg.setMaximumPoolSize(toInt(resourceProviderProperties, MAX_CONNECTIONS, 10));
+                       hcfg.setMinimumIdle(toInt(resourceProviderProperties, 
MIN_CONNECTIONS, 10));
 
                        // Timeouts
-                       
hcfg.setConnectionTimeout(toLong(resourceProviderProperties.get(CONNECTION_TIMEOUT),
 SECONDS.toMillis(30)));
-                       
hcfg.setIdleTimeout(toLong(resourceProviderProperties.get(IDLE_TIMEOUT), 
TimeUnit.MINUTES.toMillis(3)));
-                       
hcfg.setMaxLifetime(toLong(resourceProviderProperties.get(CONNECTION_LIFETIME), 
HOURS.toMillis(3)));
+                       
hcfg.setConnectionTimeout(toLong(resourceProviderProperties, 
CONNECTION_TIMEOUT, SECONDS.toMillis(30)));
+                       hcfg.setIdleTimeout(toLong(resourceProviderProperties, 
IDLE_TIMEOUT, TimeUnit.MINUTES.toMillis(3)));
+                       hcfg.setMaxLifetime(toLong(resourceProviderProperties, 
CONNECTION_LIFETIME, HOURS.toMillis(3)));
 
                        toUse = new HikariDataSource(hcfg);
 
@@ -113,37 +114,48 @@ public class JDBCConnectionProviderFacto
                return toUse;
        }
 
-       private boolean toBoolean(Object o, boolean defaultValue) {
+       private boolean toBoolean(Map<String, Object> props, String key, 
boolean defaultValue) {
+               Object o =  ofNullable(props)
+                       .map(m -> m.get(key))
+                       .orElse(defaultValue);
+               
                if (o instanceof Boolean) {
                        return ((Boolean) o).booleanValue();
-               } else if (o instanceof String) {
+               } else if(o instanceof String) {
                        return Boolean.parseBoolean((String) o);
-               } else if (o == null) {
-                       return defaultValue;
+               } else {
+                       throw new IllegalArgumentException("The property " + 
key + " cannot be converted to a boolean");
                }
-               throw new IllegalArgumentException("The value " + o + " cannot 
be converted to a boolean");
        }
 
-       private int toInt(Object o, int defaultValue) {
+       private int toInt(Map<String, Object> props, String key, int 
defaultValue) {
+               
+               Object o =  ofNullable(props)
+                               .map(m -> m.get(key))
+                               .orElse(defaultValue);
+               
                if (o instanceof Number) {
                        return ((Number) o).intValue();
-               } else if (o instanceof String) {
+               } else if(o instanceof String) {
                        return Integer.parseInt((String) o);
-               } else if (o == null) {
-                       return defaultValue;
+               } else {
+                       throw new IllegalArgumentException("The property " + 
key + " cannot be converted to an int");
                }
-               throw new IllegalArgumentException("The value " + o + " cannot 
be converted to an int");
        }
 
-       private long toLong(Object o, long defaultValue) {
+       private long toLong(Map<String, Object> props, String key, long 
defaultValue) {
+               
+               Object o =  ofNullable(props)
+                               .map(m -> m.get(key))
+                               .orElse(defaultValue);
+               
                if (o instanceof Number) {
                        return ((Number) o).longValue();
-               } else if (o instanceof String) {
+               } else if(o instanceof String) {
                        return Long.parseLong((String) o);
-               } else if (o == null) {
-                       return defaultValue;
+               } else {
+                       throw new IllegalArgumentException("The property " + 
key + " cannot be converted to a long");
                }
-               throw new IllegalArgumentException("The value " + o + " cannot 
be converted to a long");
        }
 
 }

Modified: aries/trunk/tx-control/tx-control-service-local/pom.xml
URL: 
http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-service-local/pom.xml?rev=1730872&r1=1730871&r2=1730872&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-service-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-service-local/pom.xml Wed Feb 17 16:51:21 
2016
@@ -40,9 +40,10 @@
             org.apache.aries.tx.control.service.local.*
         </aries.osgi.private.pkg>
                <aries.osgi.import.pkg>
-                       
org.osgi.service.transaction.control;version="[0.0.1,0.0.1]",
+                       
org.osgi.service.transaction.control;version="[0.0.1,0.0.2)",
                        *
                </aries.osgi.import.pkg>
+               <lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
        </properties>
 
        <dependencies>


Reply via email to