List of usage examples for org.hibernate.engine.transaction.jta.platform.internal AbstractJtaPlatform injectServices
@Override
public void injectServices(ServiceRegistryImplementor serviceRegistry)
From source file:org.umbrew.hibernate.search.database.worker.backend.DatabaseBackendQueueProcessor.java
License:Open Source License
private synchronized void intializeTransactionManagerHolder() { // TODO Bootstrap the programmatically created JPA EntityManagerFactory so that it has the expected // Hibernate services in it's ServiceRegistry if (TransactionManagerHolder.getTransactionManager() == null) { try {/*from ww w. j a va 2s . c o m*/ // Prepare access to the AbstractJtaPlatform's locateTransactionManager() method Class<?> jtaPlatformClass = Class.forName(jtaPlatform); Method locateTransactionManagerMethod = jtaPlatformClass .getDeclaredMethod("locateTransactionManager"); locateTransactionManagerMethod.setAccessible(true); // Instantiate the current AbstractJtaPlatform... AbstractJtaPlatform jtaPlatformInstance = (AbstractJtaPlatform) jtaPlatformClass.newInstance(); jtaPlatformInstance.injectServices( ((EntityManagerFactoryImpl) EntityManagerFactoryHolder.getEntityManagerFactory()) .getSessionFactory().getServiceRegistry()); // ...and use that to obtain the JTA TransactionManager TransactionManager jtaTransactionManager = (TransactionManager) locateTransactionManagerMethod .invoke(jtaPlatformInstance); TransactionManagerHolder.setTransactionManager(jtaTransactionManager); } catch (Exception e) { throw new RuntimeException(e); } } }