Deprecate PTM-based constructors in favor of generic TransactionManager

Closes gh-24612
This commit is contained in:
Juergen Hoeller 2020-03-11 14:52:03 +01:00
parent 6df80a8f70
commit 193f419520
1 changed files with 25 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,6 +29,7 @@ import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;
/** /**
* AOP Alliance MethodInterceptor for declarative transaction * AOP Alliance MethodInterceptor for declarative transaction
@ -65,13 +66,14 @@ public class TransactionInterceptor extends TransactionAspectSupport implements
/** /**
* Create a new TransactionInterceptor. * Create a new TransactionInterceptor.
* @param ptm the default transaction manager to perform the actual transaction management * @param ptm the default transaction manager to perform the actual transaction management
* @param attributes the transaction attributes in properties format * @param tas the attribute source to be used to find transaction attributes
* @since 5.2.5
* @see #setTransactionManager * @see #setTransactionManager
* @see #setTransactionAttributes(java.util.Properties) * @see #setTransactionAttributeSource
*/ */
public TransactionInterceptor(PlatformTransactionManager ptm, Properties attributes) { public TransactionInterceptor(TransactionManager ptm, TransactionAttributeSource tas) {
setTransactionManager(ptm); setTransactionManager(ptm);
setTransactionAttributes(attributes); setTransactionAttributeSource(tas);
} }
/** /**
@ -79,13 +81,30 @@ public class TransactionInterceptor extends TransactionAspectSupport implements
* @param ptm the default transaction manager to perform the actual transaction management * @param ptm the default transaction manager to perform the actual transaction management
* @param tas the attribute source to be used to find transaction attributes * @param tas the attribute source to be used to find transaction attributes
* @see #setTransactionManager * @see #setTransactionManager
* @see #setTransactionAttributeSource(TransactionAttributeSource) * @see #setTransactionAttributeSource
* @deprecated as of 5.2.5, in favor of
* {@link #TransactionInterceptor(TransactionManager, TransactionAttributeSource)}
*/ */
@Deprecated
public TransactionInterceptor(PlatformTransactionManager ptm, TransactionAttributeSource tas) { public TransactionInterceptor(PlatformTransactionManager ptm, TransactionAttributeSource tas) {
setTransactionManager(ptm); setTransactionManager(ptm);
setTransactionAttributeSource(tas); setTransactionAttributeSource(tas);
} }
/**
* Create a new TransactionInterceptor.
* @param ptm the default transaction manager to perform the actual transaction management
* @param attributes the transaction attributes in properties format
* @see #setTransactionManager
* @see #setTransactionAttributes(java.util.Properties)
* @deprecated as of 5.2.5, in favor of {@link #setTransactionAttributes(Properties)}
*/
@Deprecated
public TransactionInterceptor(PlatformTransactionManager ptm, Properties attributes) {
setTransactionManager(ptm);
setTransactionAttributes(attributes);
}
@Override @Override
@Nullable @Nullable