當前位置: 首頁>>代碼示例>>Java>>正文


Java JtaTransactionManager.getTransactionManager方法代碼示例

本文整理匯總了Java中org.springframework.transaction.jta.JtaTransactionManager.getTransactionManager方法的典型用法代碼示例。如果您正苦於以下問題:Java JtaTransactionManager.getTransactionManager方法的具體用法?Java JtaTransactionManager.getTransactionManager怎麽用?Java JtaTransactionManager.getTransactionManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.transaction.jta.JtaTransactionManager的用法示例。


在下文中一共展示了JtaTransactionManager.getTransactionManager方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRealTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
private String getRealTransactionManager() {
	if (txManager == null) {
		return null;
	}
	if (txManager instanceof SpringTxManagerProxy) {
		SpringTxManagerProxy springTxMgr = (SpringTxManagerProxy) txManager;
		PlatformTransactionManager platformTxMgr = springTxMgr.getRealTxManager();
		if (platformTxMgr == null) {
			return springTxMgr.getClass().getName();
		}
		if (platformTxMgr instanceof JtaTransactionManager) {
			JtaTransactionManager jtaTxMgr = (JtaTransactionManager) platformTxMgr;
			TransactionManager txMgr = jtaTxMgr.getTransactionManager();
			if (txMgr == null) {
				return jtaTxMgr.getClass().getName();
			}
			return txMgr.getClass().getName();
		} else {
			return platformTxMgr.getClass().getName();
		}
	} else {
		return txManager.getClass().getName();
	}
}
 
開發者ID:ibissource,項目名稱:iaf,代碼行數:25,代碼來源:IbisTransaction.java

示例2: setJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
/**
 * Set the Spring {@link JtaTransactionManager} or the JTA {@link TransactionManager}
 * to be used with Hibernate, if any. Allows for using a Spring-managed transaction
 * manager for Hibernate 4's session and cache synchronization, with the
 * "hibernate.transaction.jta.platform" automatically set to it. Also sets
 * "hibernate.transaction.factory_class" to {@link CMTTransactionFactory},
 * instructing Hibernate to interact with externally managed transactions.
 * <p>A passed-in Spring {@link JtaTransactionManager} needs to contain a JTA
 * {@link TransactionManager} reference to be usable here, except for the WebSphere
 * case where we'll automatically set {@code WebSphereExtendedJtaPlatform} accordingly.
 * <p>Note: If this is set, the Hibernate settings should not contain a JTA platform
 * setting to avoid meaningless double configuration.
 */
public LocalSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) {
	Assert.notNull(jtaTransactionManager, "Transaction manager reference must not be null");
	if (jtaTransactionManager instanceof JtaTransactionManager) {
		boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader());
		if (webspherePresent) {
			getProperties().put(AvailableSettings.JTA_PLATFORM,
					ConfigurableJtaPlatform.getJtaPlatformBasePackage() + "internal.WebSphereExtendedJtaPlatform");
		}
		else {
			JtaTransactionManager jtaTm = (JtaTransactionManager) jtaTransactionManager;
			if (jtaTm.getTransactionManager() == null) {
				throw new IllegalArgumentException(
						"Can only apply JtaTransactionManager which has a TransactionManager reference set");
			}
			getProperties().put(AvailableSettings.JTA_PLATFORM,
					new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(),
							jtaTm.getTransactionSynchronizationRegistry()).getJtaPlatformProxy());
		}
	}
	else if (jtaTransactionManager instanceof TransactionManager) {
		getProperties().put(AvailableSettings.JTA_PLATFORM,
				new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null).getJtaPlatformProxy());
	}
	else {
		throw new IllegalArgumentException(
				"Unknown transaction manager type: " + jtaTransactionManager.getClass().getName());
	}
	getProperties().put(AvailableSettings.TRANSACTION_STRATEGY, new CMTTransactionFactory());
	return this;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:44,代碼來源:LocalSessionFactoryBuilder.java

示例3: setJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
/**
 * Set the Spring {@link JtaTransactionManager} or the JTA {@link TransactionManager}
 * to be used with Hibernate, if any. Allows for using a Spring-managed transaction
 * manager for Hibernate 5's session and cache synchronization, with the
 * "hibernate.transaction.jta.platform" automatically set to it.
 * <p>A passed-in Spring {@link JtaTransactionManager} needs to contain a JTA
 * {@link TransactionManager} reference to be usable here, except for the WebSphere
 * case where we'll automatically set {@code WebSphereExtendedJtaPlatform} accordingly.
 * <p>Note: If this is set, the Hibernate settings should not contain a JTA platform
 * setting to avoid meaningless double configuration.
 */
public LocalSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) {
	Assert.notNull(jtaTransactionManager, "Transaction manager reference must not be null");
	if (jtaTransactionManager instanceof JtaTransactionManager) {
		boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader());
		if (webspherePresent) {
			getProperties().put(AvailableSettings.JTA_PLATFORM,
					"org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform");
		}
		else {
			JtaTransactionManager jtaTm = (JtaTransactionManager) jtaTransactionManager;
			if (jtaTm.getTransactionManager() == null) {
				throw new IllegalArgumentException(
						"Can only apply JtaTransactionManager which has a TransactionManager reference set");
			}
			getProperties().put(AvailableSettings.JTA_PLATFORM,
					new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(),
							jtaTm.getTransactionSynchronizationRegistry()));
		}
	}
	else if (jtaTransactionManager instanceof TransactionManager) {
		getProperties().put(AvailableSettings.JTA_PLATFORM,
				new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null));
	}
	else {
		throw new IllegalArgumentException(
				"Unknown transaction manager type: " + jtaTransactionManager.getClass().getName());
	}
	return this;
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:41,代碼來源:LocalSessionFactoryBuilder.java

示例4: setJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
/**
 * Set the Spring {@link JtaTransactionManager} or the JTA {@link TransactionManager}
 * to be used with Hibernate, if any. Allows for using a Spring-managed transaction
 * manager for Hibernate 4's session and cache synchronization, with the
 * "hibernate.transaction.jta.platform" automatically set to it. Also sets
 * "hibernate.transaction.factory_class" to {@link CMTTransactionFactory},
 * instructing Hibernate to interact with externally managed transactions.
 * <p>A passed-in Spring {@link JtaTransactionManager} needs to contain a JTA
 * {@link TransactionManager} reference to be usable here, except for the WebSphere
 * case where we'll automatically set {@link WebSphereExtendedJtaPlatform} accordingly.
 * <p>Note: If this is set, the Hibernate settings should not contain a JTA platform
 * setting to avoid meaningless double configuration.
 */
public LocalSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) {
	Assert.notNull(jtaTransactionManager, "Transaction manager reference must not be null");
	if (jtaTransactionManager instanceof JtaTransactionManager) {
		boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader());
		if (webspherePresent) {
			getProperties().put(AvailableSettings.JTA_PLATFORM, new WebSphereExtendedJtaPlatform());
		}
		else {
			JtaTransactionManager jtaTm = (JtaTransactionManager) jtaTransactionManager;
			if (jtaTm.getTransactionManager() == null) {
				throw new IllegalArgumentException(
						"Can only apply JtaTransactionManager which has a TransactionManager reference set");
			}
			getProperties().put(AvailableSettings.JTA_PLATFORM,
					new ConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction()));
		}
	}
	else if (jtaTransactionManager instanceof TransactionManager) {
		getProperties().put(AvailableSettings.JTA_PLATFORM,
				new ConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null));
	}
	else {
		throw new IllegalArgumentException(
				"Unknown transaction manager type: " + jtaTransactionManager.getClass().getName());
	}
	getProperties().put(AvailableSettings.TRANSACTION_STRATEGY, new CMTTransactionFactory());
	return this;
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:42,代碼來源:LocalSessionFactoryBuilder.java

示例5: setJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
/**
 * Set the Spring {@link JtaTransactionManager} or the JTA {@link TransactionManager}
 * to be used with Hibernate, if any. Allows for using a Spring-managed transaction
 * manager for Hibernate 5's session and cache synchronization, with the
 * "hibernate.transaction.jta.platform" automatically set to it.
 * <p>A passed-in Spring {@link JtaTransactionManager} needs to contain a JTA
 * {@link TransactionManager} reference to be usable here, except for the WebSphere
 * case where we'll automatically set {@code WebSphereExtendedJtaPlatform} accordingly.
 * <p>Note: If this is set, the Hibernate settings should not contain a JTA platform
 * setting to avoid meaningless double configuration.
 */
public HibernateSpringSessionFactoryBuilder setJtaTransactionManager(Object jtaTransactionManager) {
    Assert.notNull(jtaTransactionManager, "Transaction manager reference must not be null");

    if (jtaTransactionManager instanceof JtaTransactionManager) {
        boolean webspherePresent = ClassUtils.isPresent("com.ibm.wsspi.uow.UOWManager", getClass().getClassLoader());
        if (webspherePresent) {
            getProperties().put(AvailableSettings.JTA_PLATFORM,
                    "org.hibernate.engine.transaction.jta.platform.internal.WebSphereExtendedJtaPlatform");
        } else {
            JtaTransactionManager jtaTm = (JtaTransactionManager) jtaTransactionManager;
            if (jtaTm.getTransactionManager() == null) {
                throw new IllegalArgumentException(
                        "Can only apply JtaTransactionManager which has a TransactionManager reference set");
            }
            getProperties().put(AvailableSettings.JTA_PLATFORM,
                    new HibernateConfigurableJtaPlatform(jtaTm.getTransactionManager(), jtaTm.getUserTransaction(),
                            jtaTm.getTransactionSynchronizationRegistry()));
        }
    } else if (jtaTransactionManager instanceof TransactionManager) {
        getProperties().put(AvailableSettings.JTA_PLATFORM,
                new HibernateConfigurableJtaPlatform((TransactionManager) jtaTransactionManager, null, null));
    } else {
        throw new IllegalArgumentException(
                "Unknown transaction manager type: " + jtaTransactionManager.getClass().getName());
    }

    // Hibernate 5.1/5.2: manually enforce connection release mode AFTER_STATEMENT (the JTA default)
    try {
        // Try Hibernate 5.2
        AvailableSettings.class.getField("CONNECTION_HANDLING");
        getProperties().put("hibernate.connection.handling_mode", "DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT");
    } catch (NoSuchFieldException ex) {
        // Try Hibernate 5.1
        try {
            AvailableSettings.class.getField("ACQUIRE_CONNECTIONS");
            getProperties().put("hibernate.connection.release_mode", "AFTER_STATEMENT");
        } catch (NoSuchFieldException ex2) {
            // on Hibernate 5.0.x or lower - no need to change the default there
        }
    }

    return this;
}
 
開發者ID:baomidou,項目名稱:hibernate-plus,代碼行數:55,代碼來源:HibernateSpringSessionFactoryBuilder.java

示例6: XADiskSessionFactory

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
@Autowired
public XADiskSessionFactory(JtaTransactionManager jtaTransactionManager, StandaloneFileSystemConfiguration standaloneFileSystemConfiguration) throws InterruptedException {
    this.transactionManager = jtaTransactionManager.getTransactionManager();
    this.standaloneFileSystemConfiguration = standaloneFileSystemConfiguration;
    xaSessionMap = Collections.synchronizedMap(new WeakHashMap<Transaction, XASession>());
}
 
開發者ID:nielspeter,項目名稱:spring-xadisk,代碼行數:7,代碼來源:XADiskSessionFactory.java

示例7: setJtaTransactionManager

import org.springframework.transaction.jta.JtaTransactionManager; //導入方法依賴的package包/類
public static void setJtaTransactionManager(JtaTransactionManager jtaTransactionManager) {
    sTransactionManager = jtaTransactionManager.getTransactionManager();
    sUserTransaction = jtaTransactionManager.getUserTransaction();
}
 
開發者ID:adrobisch,項目名稱:brainslug,代碼行數:5,代碼來源:SpringHibernateJtaPlatform.java


注:本文中的org.springframework.transaction.jta.JtaTransactionManager.getTransactionManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。