001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.transaction.jta; 018 019import javax.transaction.NotSupportedException; 020import javax.transaction.SystemException; 021import javax.transaction.Transaction; 022 023import org.springframework.lang.Nullable; 024 025/** 026 * Strategy interface for creating JTA {@link javax.transaction.Transaction} 027 * objects based on specified transactional characteristics. 028 * 029 * <p>The default implementation, {@link SimpleTransactionFactory}, simply 030 * wraps a standard JTA {@link javax.transaction.TransactionManager}. 031 * This strategy interface allows for more sophisticated implementations 032 * that adapt to vendor-specific JTA extensions. 033 * 034 * @author Juergen Hoeller 035 * @since 2.5 036 * @see javax.transaction.TransactionManager#getTransaction() 037 * @see SimpleTransactionFactory 038 * @see JtaTransactionManager 039 */ 040public interface TransactionFactory { 041 042 /** 043 * Create an active Transaction object based on the given name and timeout. 044 * @param name the transaction name (may be {@code null}) 045 * @param timeout the transaction timeout (may be -1 for the default timeout) 046 * @return the active Transaction object (never {@code null}) 047 * @throws NotSupportedException if the transaction manager does not support 048 * a transaction of the specified type 049 * @throws SystemException if the transaction manager failed to create the 050 * transaction 051 */ 052 Transaction createTransaction(@Nullable String name, int timeout) throws NotSupportedException, SystemException; 053 054 /** 055 * Determine whether the underlying transaction manager supports XA transactions 056 * managed by a resource adapter (i.e. without explicit XA resource enlistment). 057 * <p>Typically {@code false}. Checked by 058 * {@link org.springframework.jca.endpoint.AbstractMessageEndpointFactory} 059 * in order to differentiate between invalid configuration and valid 060 * ResourceAdapter-managed transactions. 061 * @see javax.resource.spi.ResourceAdapter#endpointActivation 062 * @see javax.resource.spi.endpoint.MessageEndpointFactory#isDeliveryTransacted 063 */ 064 boolean supportsResourceAdapterManagedTransactions(); 065 066}