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 2018/01/24 18:39:46 UTC

[aries-tx-control] 01/03: Tx Control spec compliance ensure that passed in JDBC Resource providers are properly handled

This is an automated email from the ASF dual-hosted git repository.

timothyjward pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/aries-tx-control.git

commit 1a21dcc51e843bc80b1de9b52853fda40db60094
Author: Tim Ward <ti...@apache.org>
AuthorDate: Wed Jan 24 10:51:50 2018 -0500

    Tx Control spec compliance ensure that passed in JDBC Resource providers are properly handled
---
 .../jpa/xa/impl/JPAEntityManagerProviderFactoryImpl.java | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tx-control-providers/jpa/tx-control-provider-jpa-xa/src/main/java/org/apache/aries/tx/control/jpa/xa/impl/JPAEntityManagerProviderFactoryImpl.java b/tx-control-providers/jpa/tx-control-provider-jpa-xa/src/main/java/org/apache/aries/tx/control/jpa/xa/impl/JPAEntityManagerProviderFactoryImpl.java
index fec6bb8..218e66f 100644
--- a/tx-control-providers/jpa/tx-control-provider-jpa-xa/src/main/java/org/apache/aries/tx/control/jpa/xa/impl/JPAEntityManagerProviderFactoryImpl.java
+++ b/tx-control-providers/jpa/tx-control-provider-jpa-xa/src/main/java/org/apache/aries/tx/control/jpa/xa/impl/JPAEntityManagerProviderFactoryImpl.java
@@ -25,6 +25,7 @@ import static org.apache.aries.tx.control.jpa.xa.impl.XAJPADataSourceSetup.NON_J
 import static org.osgi.service.transaction.control.TransactionStatus.NO_TRANSACTION;
 import static org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory.LOCAL_ENLISTMENT_ENABLED;
 import static org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory.PRE_ENLISTED_DB_CONNECTION;
+import static org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory.TRANSACTIONAL_DB_CONNECTION;
 import static org.osgi.service.transaction.control.jpa.JPAEntityManagerProviderFactory.XA_ENLISTMENT_ENABLED;
 
 import java.io.ByteArrayOutputStream;
@@ -88,13 +89,16 @@ public class JPAEntityManagerProviderFactoryImpl implements InternalJPAEntityMan
 			new HashMap<>(jpaProperties);
 		jpaPropsToUse.put(TRANSACTION_TYPE, JTA.name());
 		
+		Map<String, Object> resourceProviderPropsToUse = resourceProviderProperties == null ? new HashMap<>() :
+			new HashMap<>(resourceProviderProperties);
+		
 		Function<ThreadLocal<TransactionControl>, AbstractJPAEntityManagerProvider> create;
-		if(jpaPropsToUse.containsKey("osgi.jdbc.provider")) {
-			create = handleJDBCResourceProvider(emfb, resourceProviderProperties, jpaPropsToUse);			
+		if(resourceProviderPropsToUse.containsKey(TRANSACTIONAL_DB_CONNECTION)) {
+			create = handleJDBCResourceProvider(emfb, resourceProviderPropsToUse, jpaPropsToUse);			
 		} else if(toBoolean(jpaPropsToUse, PRE_ENLISTED_DB_CONNECTION, false)) {
-			create = handlePreEnlistedConnection(emfb, resourceProviderProperties, jpaPropsToUse);
+			create = handlePreEnlistedConnection(emfb, resourceProviderPropsToUse, jpaPropsToUse);
 		} else {
-			create = handleNormalDataSource(emfb, resourceProviderProperties, jpaPropsToUse);
+			create = handleNormalDataSource(emfb, resourceProviderPropsToUse, jpaPropsToUse);
 		}
 			
 		return new DelayedJPAEntityManagerProvider(create);
@@ -104,12 +108,12 @@ public class JPAEntityManagerProviderFactoryImpl implements InternalJPAEntityMan
 			EntityManagerFactoryBuilder emfb, Map<String, Object> resourceProviderProperties,
 			Map<String, Object> jpaPropsToUse) {
 		Function<ThreadLocal<TransactionControl>, AbstractJPAEntityManagerProvider> create;
-		JDBCConnectionProvider provider = (JDBCConnectionProvider) jpaPropsToUse.get("osgi.jdbc.provider");
+		JDBCConnectionProvider provider = (JDBCConnectionProvider) resourceProviderProperties.get(TRANSACTIONAL_DB_CONNECTION);
 		
 		create = tx -> {
 				jpaPropsToUse.put(JTA_DATA_SOURCE, 
 					new ScopedConnectionDataSource(provider.getResource(tx.get())));
-				jpaPropsToUse.put(PRE_ENLISTED_DB_CONNECTION, Boolean.TRUE);
+				resourceProviderProperties.put(PRE_ENLISTED_DB_CONNECTION, Boolean.TRUE);
 				
 				return getProviderFor(emfb, jpaPropsToUse, resourceProviderProperties, tx, null); 
 			};

-- 
To stop receiving notification emails like this one, please contact
timothyjward@apache.org.