HHH-8633 register synch in OsgiJtaPlatform

Conflicts:
	hibernate-osgi/src/main/java/org/hibernate/osgi/OsgiJtaPlatform.java
This commit is contained in:
Brett Meyer 2013-10-22 22:13:16 -04:00
parent a97d8318d7
commit d3b7b9b717
1 changed files with 9 additions and 3 deletions

View File

@ -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.service.jta.platform.spi.JtaPlatform;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@ -67,13 +69,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