From 1c1dd913dd1d7b490d029a04e127936867f234a3 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 22 Oct 2013 14:41:16 -0400 Subject: [PATCH] HHH-8633 register synch in OsgiJtaPlatform --- .../java/org/hibernate/osgi/OsgiJtaPlatform.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiJtaPlatform.java b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiJtaPlatform.java index c79318c3a5..80ab44a751 100644 --- a/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiJtaPlatform.java +++ b/hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiJtaPlatform.java @@ -26,6 +26,8 @@ import javax.transaction.Transaction; import javax.transaction.TransactionManager; import javax.transaction.UserTransaction; +import org.hibernate.TransactionException; +import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -71,13 +73,17 @@ public class OsgiJtaPlatform implements JtaPlatform { @Override public boolean canRegisterSynchronization() { - // TODO - return false; + return JtaStatusHelper.isActive( retrieveTransactionManager() ); } @Override public void registerSynchronization(Synchronization synchronization) { - // TODO + try { + retrieveTransactionManager().getTransaction().registerSynchronization( synchronization ); + } + catch (Exception e) { + throw new TransactionException( "Could not obtain transaction from OSGi services!" ); + } } @Override