Deprecate TransactionSynchronizationAdapter

Closes gh-21725
This commit is contained in:
Juergen Hoeller
2020-06-17 11:02:31 +02:00
parent d36407d585
commit 17cab9660c
12 changed files with 49 additions and 42 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");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,6 @@ import org.springframework.context.event.EventListener;
import org.springframework.context.event.GenericApplicationListener;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.transaction.support.TransactionSynchronization;
import org.springframework.transaction.support.TransactionSynchronizationAdapter;
import org.springframework.transaction.support.TransactionSynchronizationManager;
/**
@@ -84,7 +83,7 @@ class ApplicationListenerMethodTransactionalAdapter extends ApplicationListenerM
}
private static class TransactionSynchronizationEventAdapter extends TransactionSynchronizationAdapter {
private static class TransactionSynchronizationEventAdapter implements TransactionSynchronization {
private final ApplicationListenerMethodAdapter listener;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -98,7 +98,7 @@ public class SimpleTransactionScope implements Scope {
}
private class CleanupSynchronization extends TransactionSynchronizationAdapter {
private class CleanupSynchronization implements TransactionSynchronization {
private final ScopedObjectsHolder scopedObjects;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,8 @@ package org.springframework.transaction.support;
import java.io.Flushable;
import org.springframework.core.Ordered;
/**
* Interface for transaction synchronization callbacks.
* Supported by AbstractPlatformTransactionManager.
@@ -29,13 +31,18 @@ import java.io.Flushable;
* <p>System synchronizations performed by Spring itself use specific order values,
* allowing for fine-grained interaction with their execution order (if necessary).
*
* <p>Implements the {@link Ordered} interface to enable the execution order of
* synchronizations to be controlled declaratively, as of 5.3. The default
* {@link #getOrder() order} is {@link Ordered#LOWEST_PRECEDENCE}, indicating
* late execution; return a lower value for earlier execution.
*
* @author Juergen Hoeller
* @since 02.06.2003
* @see TransactionSynchronizationManager
* @see AbstractPlatformTransactionManager
* @see org.springframework.jdbc.datasource.DataSourceUtils#CONNECTION_SYNCHRONIZATION_ORDER
*/
public interface TransactionSynchronization extends Flushable {
public interface TransactionSynchronization extends Ordered, Flushable {
/** Completion status in case of proper commit. */
int STATUS_COMMITTED = 0;
@@ -47,6 +54,11 @@ public interface TransactionSynchronization extends Flushable {
int STATUS_UNKNOWN = 2;
@Override
default int getOrder() {
return Ordered.LOWEST_PRECEDENCE;
}
/**
* Suspend this synchronization.
* Supposed to unbind resources from TransactionSynchronizationManager if managing any.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,10 @@ import org.springframework.core.Ordered;
*
* @author Juergen Hoeller
* @since 22.01.2004
* @deprecated as of 5.3, in favor of the default methods on the
* {@link TransactionSynchronization} interface
*/
@Deprecated
public abstract class TransactionSynchronizationAdapter implements TransactionSynchronization, Ordered {
@Override