Example usage for org.springframework.transaction.jta SimpleTransactionFactory SimpleTransactionFactory

List of usage examples for org.springframework.transaction.jta SimpleTransactionFactory SimpleTransactionFactory

Introduction

In this page you can find the example usage for org.springframework.transaction.jta SimpleTransactionFactory SimpleTransactionFactory.

Prototype

public SimpleTransactionFactory(TransactionManager transactionManager) 

Source Link

Document

Create a new SimpleTransactionFactory for the given TransactionManager.

Usage

From source file:org.springframework.jca.endpoint.AbstractMessageEndpointFactory.java

/**
 * Set the XA transaction manager to use for wrapping endpoint
 * invocations, enlisting the endpoint resource in each such transaction.
 * <p>The passed-in object may be a transaction manager which implements
 * Spring's {@link org.springframework.transaction.jta.TransactionFactory}
 * interface, or a plain {@link javax.transaction.TransactionManager}.
 * <p>If no transaction manager is specified, the endpoint invocation
 * will simply not be wrapped in an XA transaction. Check out your
 * resource provider's ActivationSpec documentation for local
 * transaction options of your particular provider.
 * @see #setTransactionName// ww  w .  j a va2  s. c  o  m
 * @see #setTransactionTimeout
 */
public void setTransactionManager(Object transactionManager) {
    if (transactionManager instanceof TransactionFactory) {
        this.transactionFactory = (TransactionFactory) transactionManager;
    } else if (transactionManager instanceof TransactionManager) {
        this.transactionFactory = new SimpleTransactionFactory((TransactionManager) transactionManager);
    } else {
        throw new IllegalArgumentException("Transaction manager [" + transactionManager
                + "] is neither a [org.springframework.transaction.jta.TransactionFactory} nor a "
                + "[javax.transaction.TransactionManager]");
    }
}