You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by ti...@apache.org on 2016/03/10 12:28:17 UTC

svn commit: r1734385 [1/2] - in /aries/trunk/tx-control: ./ tx-control-itests/ tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/ tx-control-provider-jdbc-common/ tx-control-provider-jdbc-common/src/ tx-control-provider-jdbc-common/src...

Author: timothyjward
Date: Thu Mar 10 11:27:48 2016
New Revision: 1734385

URL: http://svn.apache.org/viewvc?rev=1734385&view=rev
Log:
[tx-control] Add support for XA enlisted datasources

Added:
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/.gitignore
    aries/trunk/tx-control/tx-control-provider-jdbc-common/LICENSE
    aries/trunk/tx-control/tx-control-provider-jdbc-common/NOTICE
    aries/trunk/tx-control/tx-control-provider-jdbc-common/pom.xml
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java
    aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/.gitignore
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/LICENSE
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/NOTICE
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml
      - copied, changed from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Activator.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderImpl.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/XAConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/XADataSourceMapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/XAEnabledTxContextBindingConnection.java
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/control/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/control/jdbc/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/control/jdbc/xa/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/control/jdbc/xa/impl/
    aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/test/java/org/apache/aries/tx/control/jdbc/xa/impl/XAEnabledTxContextBindingConnectionTest.java
Removed:
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java
Modified:
    aries/trunk/tx-control/pom.xml
    aries/trunk/tx-control/tx-control-itests/pom.xml
    aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
    aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml
    aries/trunk/tx-control/tx-control-service-xa/pom.xml

Modified: aries/trunk/tx-control/pom.xml
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/pom.xml?rev=1734385&r1=1734384&r2=1734385&view=diff
==============================================================================
--- aries/trunk/tx-control/pom.xml (original)
+++ aries/trunk/tx-control/pom.xml Thu Mar 10 11:27:48 2016
@@ -45,7 +45,9 @@
 				<module>tx-control-service-common</module>
 				<module>tx-control-service-local</module>
 				<module>tx-control-service-xa</module>
+				<module>tx-control-provider-jdbc-common</module>
 				<module>tx-control-provider-jdbc-local</module>
+				<module>tx-control-provider-jdbc-xa</module>
 				<module>tx-control-itests</module>
 			</modules>
 		</profile>

Modified: 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=1734385&r1=1734384&r2=1734385&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-itests/pom.xml Thu Mar 10 11:27:48 2016
@@ -77,6 +77,12 @@
 			<version>0.0.1-SNAPSHOT</version>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.aries.tx-control</groupId>
+			<artifactId>tx-control-provider-jdbc-xa</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>

Modified: aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java?rev=1734385&r1=1734384&r2=1734385&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java (original)
+++ aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/AbstractTransactionTest.java Thu Mar 10 11:27:48 2016
@@ -32,8 +32,6 @@ import java.sql.Statement;
 import java.util.Hashtable;
 import java.util.Properties;
 
-import javax.inject.Inject;
-
 import org.apache.aries.itest.AbstractIntegrationTest;
 import org.h2.tools.Server;
 import org.junit.After;
@@ -55,10 +53,10 @@ import org.osgi.service.transaction.cont
 @ExamReactorStrategy(PerClass.class)
 public abstract class AbstractTransactionTest extends AbstractIntegrationTest {
 
+	private static final String TX_CONTROL_FILTER = "org.apache.aries.tx.control.itests.filter";
 	private static final String REMOTE_DB_PROPERTY = "org.apache.aries.tx.control.itests.remotedb";
 	private static final String CONFIGURED_PROVIDER_PROPERTY = "org.apache.aries.tx.control.itests.configured";
 
-	@Inject
 	protected TransactionControl txControl;
 
 	protected Connection connection;
@@ -67,8 +65,11 @@ public abstract class AbstractTransactio
 
 	@Before
 	public void setUp() throws Exception {
-		Properties jdbc = new Properties();
 		
+		txControl = context().getService(TransactionControl.class, 
+				System.getProperty(TX_CONTROL_FILTER), 5000);
+		
+		Properties jdbc = new Properties();
 		
 		boolean external = System.getProperties().containsKey(REMOTE_DB_PROPERTY);
 		
@@ -84,7 +85,7 @@ public abstract class AbstractTransactio
 		
 		jdbc.setProperty(DataSourceFactory.JDBC_URL, jdbcUrl);
 		
-		boolean configuredProvider = Boolean.getBoolean(CONFIGURED_PROVIDER_PROPERTY);
+		boolean configuredProvider = System.getProperties().containsKey(CONFIGURED_PROVIDER_PROPERTY);
 		
 		connection = configuredProvider ? configuredConnection(jdbc) : programaticConnection(jdbc);
 		
@@ -111,10 +112,18 @@ public abstract class AbstractTransactio
 	@SuppressWarnings({ "unchecked", "rawtypes" })
 	private Connection configuredConnection(Properties jdbc) throws IOException {
 		
+		String type = System.getProperty(CONFIGURED_PROVIDER_PROPERTY);
+		
 		jdbc.setProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, "org.h2.Driver");
 		ConfigurationAdmin cm = context().getService(ConfigurationAdmin.class, 5000);
 		
-		org.osgi.service.cm.Configuration config = cm.createFactoryConfiguration("org.apache.aries.tx.control.jdbc.local", null);
+		String pid = "local".equals(type) ? "org.apache.aries.tx.control.jdbc.local" 
+				: "org.apache.aries.tx.control.jdbc.xa";
+		
+		System.out.println("Configuring connection provider with pid " + pid);
+		
+		org.osgi.service.cm.Configuration config = cm.createFactoryConfiguration(
+				pid, null);
 		config.update((Hashtable)jdbc);
 		
 		return context().getService(JDBCConnectionProvider.class, 5000).getResource(txControl);
@@ -127,7 +136,7 @@ public abstract class AbstractTransactio
 				.execute("DROP TABLE TEST_TABLE"));
 		
 		
-		if(Boolean.getBoolean(CONFIGURED_PROVIDER_PROPERTY)) {
+		if(System.getProperties().containsKey(CONFIGURED_PROVIDER_PROPERTY)) {
 			clearConfiguration();
 		}
 		
@@ -227,7 +236,7 @@ public abstract class AbstractTransactio
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
 				mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
-				systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("true"),
+				systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("local"),
 				when(testSpecificOptions != null).useOptions(testSpecificOptions),
 				mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
 				mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject()
@@ -300,7 +309,57 @@ public abstract class AbstractTransactio
 				localJdbcResourceProviderWithH2(),
 				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
 				mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
-				systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("true"),
+				systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("local"),
+				when(testSpecificOptions != null).useOptions(testSpecificOptions),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject()
+				
+//				,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+				);
+	}
+	
+	@Configuration
+	public Option[] xaServerH2XATxConfiguration() {
+		String localRepo = System.getProperty("maven.repo.local");
+		if (localRepo == null) {
+			localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+		}
+		
+		Option testSpecificOptions = testSpecificOptions();
+		
+		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(),
+				xaTxControlService(),
+				xaJdbcResourceProviderWithH2(),
+				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
+				when(testSpecificOptions != null).useOptions(testSpecificOptions),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject()
+				
+//				,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+				);
+	}
+
+	@Configuration
+	public Option[] xaConfigAdminDrivenH2XATxConfiguration() {
+		String localRepo = System.getProperty("maven.repo.local");
+		if (localRepo == null) {
+			localRepo = System.getProperty("org.ops4j.pax.url.mvn.localRepository");
+		}
+		
+		Option testSpecificOptions = testSpecificOptions();
+		
+		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(),
+				xaTxControlService(),
+				xaJdbcResourceProviderWithH2(),
+				systemProperty(REMOTE_DB_PROPERTY).value(getRemoteDBPath()),
+				mavenBundle("org.apache.felix", "org.apache.felix.configadmin").versionAsInProject(),
+				systemProperty(CONFIGURED_PROVIDER_PROPERTY).value("xa"),
 				when(testSpecificOptions != null).useOptions(testSpecificOptions),
 				mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
 				mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject()
@@ -322,12 +381,14 @@ public abstract class AbstractTransactio
 	
 	public Option localTxControlService() {
 		return CoreOptions.composite(
+				systemProperty(TX_CONTROL_FILTER).value("(!(osgi.xa.enabled=*))"),
 				mavenBundle("org.apache.felix", "org.apache.felix.coordinator").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-service-local").versionAsInProject());
 	}
 
 	public Option xaTxControlService() {
 		return CoreOptions.composite(
+				systemProperty(TX_CONTROL_FILTER).value("(osgi.xa.enabled=true)"),
 				mavenBundle("org.apache.felix", "org.apache.felix.coordinator").versionAsInProject(),
 				mavenBundle("org.apache.aries.tx-control", "tx-control-service-xa").versionAsInProject());
 	}
@@ -338,6 +399,12 @@ public abstract class AbstractTransactio
 				mavenBundle("org.apache.aries.tx-control", "tx-control-provider-jdbc-local").versionAsInProject());
 	}
 
+	public Option xaJdbcResourceProviderWithH2() {
+		return CoreOptions.composite(
+				mavenBundle("com.h2database", "h2").versionAsInProject(),
+				mavenBundle("org.apache.aries.tx-control", "tx-control-provider-jdbc-xa").versionAsInProject());
+	}
+
 	protected Option testSpecificOptions() {
 		return null;
 	}

Added: aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java (added)
+++ aries/trunk/tx-control/tx-control-itests/src/test/java/org/apache/aries/tx/control/itests/XATransactionTest.java Thu Mar 10 11:27:48 2016
@@ -0,0 +1,304 @@
+/*
+ * 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.junit.Assert.fail;
+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.io.File;
+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 javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.apache.aries.itest.AbstractIntegrationTest;
+import org.h2.tools.Server;
+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.ops4j.pax.exam.util.Filter;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.osgi.service.transaction.control.TransactionControl;
+import org.osgi.service.transaction.control.TransactionRolledBackException;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProviderFactory;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class XATransactionTest extends AbstractIntegrationTest {
+
+	@Inject
+	@Filter("(osgi.xa.enabled=true)")
+	private TransactionControl txControl;
+	
+	@Inject
+	@Filter("(osgi.xa.enabled=true)")
+	private JDBCConnectionProviderFactory factory;
+	
+	protected Connection connection1;
+	protected Connection connection2;
+
+	private Server server1;
+	private Server server2;
+
+	@Before
+	public void setUp() throws Exception {
+		Properties jdbc = new Properties();
+		
+		server1 = Server.createTcpServer("-tcpPort", "0");
+		server1.start();
+
+		server2 = Server.createTcpServer("-tcpPort", "0");
+		server2.start();
+			
+		String jdbcUrl1 = "jdbc:h2:tcp://127.0.0.1:" + server1.getPort() + "/" + getRemoteDBPath("db1");
+		String jdbcUrl2 = "jdbc:h2:tcp://127.0.0.1:" + server2.getPort() + "/" + getRemoteDBPath("db2");
+		
+		jdbc.setProperty(DataSourceFactory.JDBC_URL, jdbcUrl1);
+		connection1 = programaticConnection(jdbc);
+		
+		jdbc.setProperty(DataSourceFactory.JDBC_URL, jdbcUrl2);
+		connection2 = programaticConnection(jdbc);
+		
+		txControl.required(() -> {
+				Statement s = connection1.createStatement();
+				try {
+					s.execute("DROP TABLE TEST_TABLE");
+				} catch (SQLException sqle) {}
+				s.execute("CREATE TABLE TEST_TABLE ( message varchar(255) )");
+				return null;
+			});
+		txControl.required(() -> {
+				Statement s = connection2.createStatement();
+				try {
+					s.execute("DROP TABLE TEST_TABLE");
+				} catch (SQLException sqle) {}
+				s.execute("CREATE TABLE TEST_TABLE ( idValue varchar(16) PRIMARY KEY )");
+				return null;
+			});
+	}
+
+	private Connection programaticConnection(Properties jdbc) {
+		
+		JDBCConnectionProviderFactory resourceProviderFactory = context()
+				.getService(JDBCConnectionProviderFactory.class, 5000);
+		
+		DataSourceFactory dsf = context().getService(DataSourceFactory.class, 5000);
+		
+		return resourceProviderFactory.getProviderFor(dsf, jdbc, null).getResource(txControl);
+	}
+
+	@After
+	public void tearDown() {
+
+		try {
+			txControl.required(() -> connection1.createStatement()
+					.execute("DROP TABLE TEST_TABLE"));
+		} catch (Exception e) {}
+		try {
+			txControl.required(() -> connection2.createStatement()
+					.execute("DROP TABLE TEST_TABLE"));
+		} catch (Exception e) {}
+		
+		
+		if(server1 != null) {
+			server1.stop();
+		}
+
+		if(server2 != null) {
+			server2.stop();
+		}
+
+		connection1 = null;
+		connection2 = null;
+	}
+
+	@Test
+	public void testTwoPhaseCommit() {
+		txControl.required(() -> {
+			connection1.createStatement()
+				.execute("Insert into TEST_TABLE values ( 'Hello World!' )");
+			
+			connection2.createStatement()
+				.execute("Insert into TEST_TABLE values ( 'Hello 1' )");
+			
+			return null;
+		});
+		
+		assertEquals("Hello World!", txControl.notSupported(() -> {
+			ResultSet rs = connection1.createStatement()
+					.executeQuery("Select * from TEST_TABLE");
+			rs.next();
+			return rs.getString(1);
+		}));
+
+		assertEquals("Hello 1", txControl.notSupported(() -> {
+			ResultSet rs = connection2.createStatement()
+					.executeQuery("Select * from TEST_TABLE");
+			rs.next();
+			return rs.getString(1);
+		}));
+	}
+
+	@Test
+	public void testTwoPhaseRollback() {
+		try {
+			txControl.required(() -> {
+				connection1.createStatement()
+					.execute("Insert into TEST_TABLE values ( 'Hello World!' )");
+				
+				connection2.createStatement()
+					.execute("Insert into TEST_TABLE values ( 'Hello 1' )");
+				
+				txControl.requiresNew(() -> {
+						connection2.createStatement()
+							.execute("Insert into TEST_TABLE values ( 'Hello 2' )");
+						return null;
+					});
+				
+				txControl.getCurrentContext().registerXAResource(new PoisonResource());
+				
+				return null;
+			});
+			fail("Should roll back");
+		} catch (TransactionRolledBackException trbe) {
+		}
+		
+		assertEquals(0, (int) txControl.notSupported(() -> {
+			ResultSet rs = connection1.createStatement()
+					.executeQuery("Select count(*) from TEST_TABLE");
+			rs.next();
+			return rs.getInt(1);
+		}));
+		
+		
+		assertEquals("1: Hello 2", txControl.notSupported(() -> {
+			Statement s = connection2.createStatement();
+			
+			ResultSet rs = s.executeQuery("Select count(*) from TEST_TABLE");
+			rs.next();
+			int count = rs.getInt(1);
+			
+			rs = s.executeQuery("Select idValue from TEST_TABLE ORDER BY idValue");
+			
+			rs.next();
+			return "" + count + ": " + rs.getString(1);
+		}));
+	}
+	
+	
+	@Configuration
+	public Option[] xaServerH2XATxConfiguration() {
+		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-xa").versionAsInProject(),
+				mavenBundle("com.h2database", "h2").versionAsInProject(),
+				mavenBundle("org.apache.aries.tx-control", "tx-control-provider-jdbc-xa").versionAsInProject(),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-api").versionAsInProject(),
+				mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject()
+				
+//				,CoreOptions.vmOption("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005")
+				);
+	}
+
+	private String getRemoteDBPath(String name) {
+		String fullResourceName = getClass().getName().replace('.', '/') + ".class";
+		
+		String resourcePath = getClass().getResource(getClass().getSimpleName() + ".class").getPath();
+		
+		File testClassesDir = new File(resourcePath.substring(0, resourcePath.length() - fullResourceName.length()));
+		
+		String dbPath = new File(testClassesDir.getParentFile(), "testdb/" + name).getAbsolutePath();
+		return dbPath;
+	}
+	
+	private static class PoisonResource implements XAResource {
+
+		@Override
+		public void commit(Xid arg0, boolean arg1) throws XAException {
+			throw new XAException(XAException.XA_RBOTHER);
+		}
+
+		@Override
+		public void end(Xid arg0, int arg1) throws XAException {
+		}
+
+		@Override
+		public void forget(Xid arg0) throws XAException {
+		}
+
+		@Override
+		public int getTransactionTimeout() throws XAException {
+			return 30;
+		}
+
+		@Override
+		public boolean isSameRM(XAResource arg0) throws XAException {
+			return false;
+		}
+
+		@Override
+		public int prepare(Xid arg0) throws XAException {
+			throw new XAException(XAException.XA_RBOTHER);
+		}
+
+		@Override
+		public Xid[] recover(int arg0) throws XAException {
+			return new Xid[0];
+		}
+
+		@Override
+		public void rollback(Xid arg0) throws XAException {
+		}
+
+		@Override
+		public boolean setTransactionTimeout(int arg0) throws XAException {
+			return false;
+		}
+
+		@Override
+		public void start(Xid arg0, int arg1) throws XAException {
+		}
+	}
+}

Added: aries/trunk/tx-control/tx-control-provider-jdbc-common/.gitignore
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/.gitignore?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-common/.gitignore (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-common/.gitignore Thu Mar 10 11:27:48 2016
@@ -0,0 +1 @@
+/target/

Added: aries/trunk/tx-control/tx-control-provider-jdbc-common/LICENSE
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/LICENSE?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-common/LICENSE (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-common/LICENSE Thu Mar 10 11:27:48 2016
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: aries/trunk/tx-control/tx-control-provider-jdbc-common/NOTICE
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/NOTICE?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-common/NOTICE (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-common/NOTICE Thu Mar 10 11:27:48 2016
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/pom.xml (from r1734384, 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-common/pom.xml?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/pom.xml&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-common/pom.xml Thu Mar 10 11:27:48 2016
@@ -8,56 +8,29 @@
 		<relativePath>../../parent/pom.xml</relativePath>
 	</parent>
 	<groupId>org.apache.aries.tx-control</groupId>
-	<artifactId>tx-control-provider-jdbc-local</artifactId>
-	<packaging>bundle</packaging>
-	<name>OSGi Transaction Control JDBC Resource Provider - Local Transactions</name>
+	<artifactId>tx-control-provider-jdbc-common</artifactId>
+	<packaging>jar</packaging>
+	<name>OSGi Transaction Control JDBC Resource Provider - Common Code</name>
 	<version>0.0.1-SNAPSHOT</version>
 
 	<description>
-        This bundle contains a JDBC resource provider for use with the OSGi Transaction Control Service that supports local transactions.
+        This jar contains a common code for building OSGi Transaction Control JDBCConnectionProvider 
+        implementations. It is not complete and should not be deployed at runtime, instead it should 
+        be repackaged inside a complete implementation.
     </description>
 
 	<scm>
 		<connection>
-            scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-common
         </connection>
 		<developerConnection>
-            scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-common
         </developerConnection>
 		<url>
-            http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common
         </url>
 	</scm>
 
-	<properties>
-		<aries.osgi.activator>
-			org.apache.aries.tx.control.jdbc.local.impl.Activator
-		</aries.osgi.activator>
-		<aries.osgi.export.pkg>
-			org.osgi.service.transaction.control.jdbc,
-			org.osgi.service.cm,
-			org.osgi.service.jdbc
-		</aries.osgi.export.pkg>
-		<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.dropwizard,
-			!javassist.*,
-			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)",
-			org.osgi.service.cm,
-			org.osgi.service.jdbc,
-			*
-		</aries.osgi.import.pkg>
-		<lastReleaseVersion>0.0.1-SNAPSHOT</lastReleaseVersion>
-	</properties>
-
 	<dependencies>
 		<dependency>
 			<groupId>org.slf4j</groupId>

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ConnectionWrapper.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/DriverDataSource.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapper.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/main/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapper.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/ScopedConnectionWrapperTest.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java (from r1734384, aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java)
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java?p2=aries/trunk/tx-control/tx-control-provider-jdbc-common/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/src/test/java/org/apache/aries/tx/control/jdbc/common/impl/TxConnectionWrapperTest.java&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
    (empty)

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=1734385&r1=1734384&r2=1734385&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 Thu Mar 10 11:27:48 2016
@@ -70,6 +70,12 @@
 			<scope>provided</scope>
 		</dependency>
 		<dependency>
+			<groupId>org.apache.aries.tx-control</groupId>
+			<artifactId>tx-control-provider-jdbc-common</artifactId>
+			<version>0.0.1-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.service.jdbc</artifactId>
 			<version>1.0.0</version>

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/.gitignore
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/.gitignore?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/.gitignore (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/.gitignore Thu Mar 10 11:27:48 2016
@@ -0,0 +1 @@
+/target/

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/LICENSE
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/LICENSE?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/LICENSE (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/LICENSE Thu Mar 10 11:27:48 2016
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/NOTICE
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/NOTICE?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/NOTICE (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/NOTICE Thu Mar 10 11:27:48 2016
@@ -0,0 +1,8 @@
+
+Apache Aries
+Copyright 2009-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Copied: aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml (from r1734384, 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-xa/pom.xml?p2=aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml&p1=aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml&r1=1734384&r2=1734385&rev=1734385&view=diff
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-local/pom.xml (original)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/pom.xml Thu Mar 10 11:27:48 2016
@@ -8,30 +8,30 @@
 		<relativePath>../../parent/pom.xml</relativePath>
 	</parent>
 	<groupId>org.apache.aries.tx-control</groupId>
-	<artifactId>tx-control-provider-jdbc-local</artifactId>
+	<artifactId>tx-control-provider-jdbc-xa</artifactId>
 	<packaging>bundle</packaging>
-	<name>OSGi Transaction Control JDBC Resource Provider - Local Transactions</name>
+	<name>OSGi Transaction Control JDBC Resource Provider - XA Transactions</name>
 	<version>0.0.1-SNAPSHOT</version>
 
 	<description>
-        This bundle contains a JDBC resource provider for use with the OSGi Transaction Control Service that supports local transactions.
+        This bundle contains a JDBC resource provider for use with the OSGi Transaction Control Service that supports XA and Local transactions.
     </description>
 
 	<scm>
 		<connection>
-            scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            scm:svn:http://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-xa
         </connection>
 		<developerConnection>
-            scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            scm:svn:https://svn.apache.org/repos/asf/aries/trunk/tx-control/tx-control-provider-jdbc-xa
         </developerConnection>
 		<url>
-            http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-local
+            http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa
         </url>
 	</scm>
 
 	<properties>
 		<aries.osgi.activator>
-			org.apache.aries.tx.control.jdbc.local.impl.Activator
+			org.apache.aries.tx.control.jdbc.xa.impl.Activator
 		</aries.osgi.activator>
 		<aries.osgi.export.pkg>
 			org.osgi.service.transaction.control.jdbc,
@@ -69,6 +69,12 @@
 			<version>0.0.1-SNAPSHOT</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.aries.tx-control</groupId>
+			<artifactId>tx-control-provider-jdbc-common</artifactId>
+			<version>0.0.1-SNAPSHOT</version>
+			<scope>provided</scope>
+		</dependency>
 		<dependency>
 			<groupId>org.osgi</groupId>
 			<artifactId>org.osgi.service.jdbc</artifactId>

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Activator.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Activator.java?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Activator.java (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/Activator.java Thu Mar 10 11:27:48 2016
@@ -0,0 +1,47 @@
+package org.apache.aries.tx.control.jdbc.xa.impl;
+
+import static org.osgi.framework.Constants.SERVICE_PID;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProviderFactory;
+
+public class Activator implements BundleActivator {
+
+	private ServiceRegistration<JDBCConnectionProviderFactory> reg;
+	private ServiceRegistration<ManagedServiceFactory> factoryReg;
+	
+	@Override
+	public void start(BundleContext context) throws Exception {
+		reg = context.registerService(JDBCConnectionProviderFactory.class, 
+				new JDBCConnectionProviderFactoryImpl(), getProperties());
+		
+		factoryReg = context.registerService(ManagedServiceFactory.class, 
+				new ManagedServiceFactoryImpl(context), getMSFProperties());
+	}
+
+	@Override
+	public void stop(BundleContext context) throws Exception {
+		reg.unregister();
+		factoryReg.unregister();
+	}
+
+	private Dictionary<String, Object> getProperties() {
+		Dictionary<String, Object> props = new Hashtable<>();
+		props.put("osgi.local.enabled", Boolean.TRUE);
+		props.put("osgi.xa.enabled", Boolean.TRUE);
+		return props;
+	}
+
+	private Dictionary<String, ?> getMSFProperties() {
+		Dictionary<String, Object> props = new Hashtable<>();
+		props.put(SERVICE_PID, "org.apache.aries.tx.control.jdbc.xa");
+		return props;
+	}
+
+}

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderFactoryImpl.java Thu Mar 10 11:27:48 2016
@@ -0,0 +1,181 @@
+package org.apache.aries.tx.control.jdbc.xa.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;
+
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+
+import org.apache.aries.tx.control.jdbc.common.impl.DriverDataSource;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.osgi.service.transaction.control.TransactionException;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProviderFactory;
+
+import com.zaxxer.hikari.HikariConfig;
+import com.zaxxer.hikari.HikariDataSource;
+
+public class JDBCConnectionProviderFactoryImpl implements JDBCConnectionProviderFactory {
+
+	@Override
+	public JDBCConnectionProvider getProviderFor(DataSourceFactory dsf, Properties jdbcProperties,
+			Map<String, Object> resourceProviderProperties) {
+
+		boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
+		boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
+		boolean useDriver = toBoolean(resourceProviderProperties, USE_DRIVER, false);
+		
+		checkEnlistment(xaEnabled, localEnabled, !useDriver);
+
+		DataSource unpooled;
+		try {
+			if (useDriver) {
+				unpooled = new DriverDataSource(dsf.createDriver(null), jdbcProperties.getProperty(JDBC_URL),
+						jdbcProperties);
+			} else if (xaEnabled) {
+				unpooled = new XADataSourceMapper(dsf.createXADataSource(jdbcProperties));
+			} else {
+				unpooled = dsf.createDataSource(jdbcProperties);
+			}
+		} catch (SQLException sqle) {
+			throw new TransactionException("Unable to create the JDBC resource provider", sqle);
+		}
+
+		DataSource toUse = poolIfNecessary(resourceProviderProperties, unpooled);
+
+		return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled);
+	}
+
+	@Override
+	public JDBCConnectionProvider getProviderFor(DataSource ds, Map<String, Object> resourceProviderProperties) {
+		boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
+		boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
+		
+		try {
+			checkEnlistment(xaEnabled, localEnabled, ds.isWrapperFor(XADataSource.class));
+			DataSource toUse = poolIfNecessary(resourceProviderProperties, xaEnabled ?
+					new XADataSourceMapper(ds.unwrap(XADataSource.class)) : ds);
+	
+			return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled);
+		} catch (SQLException sqle) {
+			throw new TransactionException("Unable to create the JDBC resource provider", sqle);
+		}
+	}
+
+	@Override
+	public JDBCConnectionProvider getProviderFor(Driver driver, Properties jdbcProperties, 
+			Map<String, Object> resourceProviderProperties) {
+		
+		boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, false);
+		boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
+		
+		checkEnlistment(xaEnabled, localEnabled, false);
+		
+		DataSource toUse = poolIfNecessary(resourceProviderProperties, 
+				new DriverDataSource(driver, jdbcProperties.getProperty(JDBC_URL), jdbcProperties));
+		
+		return new JDBCConnectionProviderImpl(toUse, xaEnabled, localEnabled);
+	}
+
+	@Override
+	public JDBCConnectionProvider getProviderFor(XADataSource ds, Map<String, Object> resourceProviderProperties) {
+		
+		boolean xaEnabled = toBoolean(resourceProviderProperties, XA_ENLISTMENT_ENABLED, true);
+		boolean localEnabled = toBoolean(resourceProviderProperties, LOCAL_ENLISTMENT_ENABLED, true);
+		
+		checkEnlistment(xaEnabled, localEnabled, true);
+		
+		DataSource unpooled = new XADataSourceMapper(ds);
+		
+		return new JDBCConnectionProviderImpl(poolIfNecessary(resourceProviderProperties, unpooled),
+				xaEnabled, localEnabled);
+	}
+
+	private void checkEnlistment(boolean xaEnabled, boolean localEnabled, boolean isXA) {
+		
+		if (!xaEnabled && !localEnabled) {
+			throw new TransactionException("The configuration supports neither local nor XA transactions");
+		} 
+		
+		if(xaEnabled && !isXA) {
+			throw new TransactionException("The configuration is XA enabled but the resource is not suitable for XA enlistment");
+		}
+	}
+
+	private DataSource poolIfNecessary(Map<String, Object> resourceProviderProperties, DataSource unpooled) {
+		DataSource toUse;
+
+		if (toBoolean(resourceProviderProperties, CONNECTION_POOLING_ENABLED, true)) {
+			HikariConfig hcfg = new HikariConfig();
+			hcfg.setDataSource(unpooled);
+
+			// Sizes
+			hcfg.setMaximumPoolSize(toInt(resourceProviderProperties, MAX_CONNECTIONS, 10));
+			hcfg.setMinimumIdle(toInt(resourceProviderProperties, MIN_CONNECTIONS, 10));
+
+			// Timeouts
+			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);
+
+		} else {
+			toUse = unpooled;
+		}
+		return toUse;
+	}
+
+	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) {
+			return Boolean.parseBoolean((String) o);
+		} else {
+			throw new IllegalArgumentException("The property " + key + " cannot be converted to a boolean");
+		}
+	}
+
+	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) {
+			return Integer.parseInt((String) o);
+		} else {
+			throw new IllegalArgumentException("The property " + key + " cannot be converted to an int");
+		}
+	}
+
+	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) {
+			return Long.parseLong((String) o);
+		} else {
+			throw new IllegalArgumentException("The property " + key + " cannot be converted to a long");
+		}
+	}
+
+}

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderImpl.java?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderImpl.java (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/JDBCConnectionProviderImpl.java Thu Mar 10 11:27:48 2016
@@ -0,0 +1,36 @@
+package org.apache.aries.tx.control.jdbc.xa.impl;
+
+import java.sql.Connection;
+import java.util.UUID;
+
+import javax.sql.DataSource;
+
+import org.osgi.service.transaction.control.TransactionControl;
+import org.osgi.service.transaction.control.TransactionException;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider;
+
+public class JDBCConnectionProviderImpl implements JDBCConnectionProvider {
+
+	private final UUID			uuid	= UUID.randomUUID();
+
+	private final DataSource dataSource;
+	
+	private final boolean xaEnabled;
+	
+	private final boolean localEnabled;
+	
+	public JDBCConnectionProviderImpl(DataSource dataSource, boolean xaEnabled,
+			boolean localEnabled) {
+		this.dataSource = dataSource;
+		this.xaEnabled = xaEnabled;
+		this.localEnabled = localEnabled;
+	}
+
+	@Override
+	public Connection getResource(TransactionControl txControl)
+			throws TransactionException {
+		return new XAEnabledTxContextBindingConnection(txControl, dataSource , uuid,
+				xaEnabled, localEnabled);
+	}
+
+}

Added: aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java?rev=1734385&view=auto
==============================================================================
--- aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java (added)
+++ aries/trunk/tx-control/tx-control-provider-jdbc-xa/src/main/java/org/apache/aries/tx/control/jdbc/xa/impl/ManagedServiceFactoryImpl.java Thu Mar 10 11:27:48 2016
@@ -0,0 +1,225 @@
+package org.apache.aries.tx.control.jdbc.xa.impl;
+
+import static java.util.Arrays.asList;
+import static java.util.Optional.ofNullable;
+import static org.osgi.framework.Constants.OBJECTCLASS;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATABASE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DATASOURCE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_DESCRIPTION;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_NETWORK_PROTOCOL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PASSWORD;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_PORT_NUMBER;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_ROLE_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_SERVER_NAME;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_URL;
+import static org.osgi.service.jdbc.DataSourceFactory.JDBC_USER;
+import static org.osgi.service.jdbc.DataSourceFactory.OSGI_JDBC_DRIVER_CLASS;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedServiceFactory;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
+
+public class ManagedServiceFactoryImpl implements ManagedServiceFactory {
+
+	private static final String DSF_TARGET_FILTER = "aries.dsf.target.filter";
+	private static final String JDBC_PROP_NAMES = "aries.jdbc.property.names";
+	private static final List<String> JDBC_PROPERTIES = asList(JDBC_DATABASE_NAME, JDBC_DATASOURCE_NAME,
+			JDBC_DESCRIPTION, JDBC_NETWORK_PROTOCOL, JDBC_PASSWORD, JDBC_PORT_NUMBER, JDBC_ROLE_NAME, JDBC_SERVER_NAME,
+			JDBC_URL, JDBC_USER);
+
+	private final Map<String, ManagedJDBCResourceProvider> managedInstances = new ConcurrentHashMap<>();
+
+	private final BundleContext context;
+
+	public ManagedServiceFactoryImpl(BundleContext context) {
+		this.context = context;
+	}
+
+	@Override
+	public String getName() {
+		return "Aries JDBCConnectionProvider (XA enabled) service";
+	}
+
+	@Override
+	public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException {
+
+		Map<String, Object> propsMap = new HashMap<>();
+
+		Enumeration<String> keys = properties.keys();
+		while (keys.hasMoreElements()) {
+			String key = keys.nextElement();
+			propsMap.put(key, properties.get(key));
+		}
+
+		Properties jdbcProps = getJdbcProps(propsMap);
+
+		try {
+			ManagedJDBCResourceProvider mjrp = new ManagedJDBCResourceProvider(context, jdbcProps, propsMap);
+			ofNullable(managedInstances.put(pid, mjrp)).ifPresent(ManagedJDBCResourceProvider::stop);
+			mjrp.start();
+		} catch (InvalidSyntaxException e) {
+			throw new ConfigurationException(DSF_TARGET_FILTER, "The target filter was invalid", e);
+		}
+	}
+
+	public void stop() {
+		managedInstances.values().forEach(ManagedJDBCResourceProvider::stop);
+	}
+
+	@SuppressWarnings("unchecked")
+	private Properties getJdbcProps(Map<String, Object> properties) throws ConfigurationException {
+
+		Object object = properties.getOrDefault(JDBC_PROP_NAMES, JDBC_PROPERTIES);
+		Collection<String> propnames;
+		if (object instanceof String) {
+			propnames = Arrays.asList(((String) object).split(","));
+		} else if (object instanceof String[]) {
+			propnames = Arrays.asList((String[]) object);
+		} else if (object instanceof Collection) {
+			propnames = (Collection<String>) object;
+		} else {
+			throw new ConfigurationException(JDBC_PROP_NAMES,
+					"The jdbc property names must be a String+ or comma-separated String");
+		}
+
+		Properties p = new Properties();
+
+		propnames.stream().filter(properties::containsKey)
+				.forEach(s -> p.setProperty(s, String.valueOf(properties.get(s))));
+
+		return p;
+	}
+
+	@Override
+	public void deleted(String pid) {
+		ofNullable(managedInstances.remove(pid))
+			.ifPresent(ManagedJDBCResourceProvider::stop);
+	}
+
+	private static class ManagedJDBCResourceProvider
+			implements ServiceTrackerCustomizer<DataSourceFactory, DataSourceFactory> {
+
+		private final BundleContext context;
+		private final Properties jdbcProperties;
+		private final Map<String, Object> providerProperties;
+		private final ServiceTracker<DataSourceFactory, DataSourceFactory> dsfTracker;
+
+		private final AtomicReference<DataSourceFactory> activeDsf = new AtomicReference<>();
+		private final AtomicReference<ServiceRegistration<JDBCConnectionProvider>> serviceReg = new AtomicReference<>();
+
+		public ManagedJDBCResourceProvider(BundleContext context, Properties jdbcProperties,
+				Map<String, Object> providerProperties) throws InvalidSyntaxException, ConfigurationException {
+			this.context = context;
+			this.jdbcProperties = jdbcProperties;
+			this.providerProperties = providerProperties;
+
+			String targetFilter = (String) providerProperties.get(DSF_TARGET_FILTER);
+			if (targetFilter == null) {
+				String driver = (String) providerProperties.get(OSGI_JDBC_DRIVER_CLASS);
+				if (driver == null) {
+					throw new ConfigurationException(OSGI_JDBC_DRIVER_CLASS,
+							"The configuration must specify either a target filter or a JDBC driver class");
+				}
+				targetFilter = "(" + OSGI_JDBC_DRIVER_CLASS + "=" + driver + ")";
+			}
+
+			targetFilter = "(&(" + OBJECTCLASS + "=" + DataSourceFactory.class.getName() + ")" + targetFilter + ")";
+
+			this.dsfTracker = new ServiceTracker<>(context, context.createFilter(targetFilter), this);
+		}
+
+		public void start() {
+			dsfTracker.open();
+		}
+
+		public void stop() {
+			dsfTracker.close();
+		}
+
+		@Override
+		public DataSourceFactory addingService(ServiceReference<DataSourceFactory> reference) {
+			DataSourceFactory service = context.getService(reference);
+
+			updateService(service);
+			return service;
+		}
+
+		private void updateService(DataSourceFactory service) {
+			boolean setDsf;
+			synchronized (this) {
+				setDsf = activeDsf.compareAndSet(null, service);
+			}
+
+			if (setDsf) {
+				try {
+					JDBCConnectionProvider provider = new JDBCConnectionProviderFactoryImpl().getProviderFor(service,
+							jdbcProperties, providerProperties);
+					ServiceRegistration<JDBCConnectionProvider> reg = context
+							.registerService(JDBCConnectionProvider.class, provider, getServiceProperties());
+					if (!serviceReg.compareAndSet(null, reg)) {
+						throw new IllegalStateException("Unable to set the JDBC connection provider registration");
+					}
+				} catch (Exception e) {
+					activeDsf.compareAndSet(service, null);
+				}
+			}
+		}
+
+		private Dictionary<String, ?> getServiceProperties() {
+			Hashtable<String, Object> props = new Hashtable<>();
+			providerProperties.keySet().stream().filter(s -> !JDBC_PASSWORD.equals(s))
+					.forEach(s -> props.put(s, providerProperties.get(s)));
+			return props;
+		}
+
+		@Override
+		public void modifiedService(ServiceReference<DataSourceFactory> reference, DataSourceFactory service) {
+		}
+
+		@Override
+		public void removedService(ServiceReference<DataSourceFactory> reference, DataSourceFactory service) {
+			boolean dsfLeft;
+			ServiceRegistration<JDBCConnectionProvider> oldReg = null;
+			synchronized (this) {
+				dsfLeft = activeDsf.compareAndSet(service, null);
+				if (dsfLeft) {
+					oldReg = serviceReg.getAndSet(null);
+				}
+			}
+
+			if (oldReg != null) {
+				try {
+					oldReg.unregister();
+				} catch (IllegalStateException ise) {
+
+				}
+			}
+
+			if (dsfLeft) {
+				DataSourceFactory newDSF = dsfTracker.getService();
+				if (newDSF != null) {
+					updateService(dsfTracker.getService());
+				}
+			}
+		}
+	}
+}