Skip to content

Commit 98765fe

Browse files
committed
Fix deprecation for TX; fix JMS tests; Moore-SR6
* Upgrade to Spring Data Moore-SR6 * Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder` for deprecations in the `TransactionInterceptor` * Fix `TransactionHandleMessageAdvice` and `TransactionInterceptorBuilder` consumers to expose new `TransactionManager`-based options and deprecate `PlatformTransactionManager`-based * Fix failing JMS tests to reuse an ActiveMQ Connection Factory with a `trustedPackaged(*)` **Cherry-pick to master**
1 parent 9dc55fd commit 98765fe

29 files changed

+333
-331
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ext {
9090
servletApiVersion = '4.0.1'
9191
smackVersion = '4.3.4'
9292
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.2.5.RELEASE'
93-
springDataVersion = 'Moore-SR5'
93+
springDataVersion = 'Moore-SR6'
9494
springSecurityVersion = '5.2.2.RELEASE'
9595
springRetryVersion = '1.2.5.RELEASE'
9696
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.2.5.RELEASE'

spring-integration-core/src/main/java/org/springframework/integration/dsl/ConsumerEndpointSpec.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.messaging.MessageHandler;
3333
import org.springframework.scheduling.TaskScheduler;
3434
import org.springframework.transaction.PlatformTransactionManager;
35+
import org.springframework.transaction.TransactionManager;
3536
import org.springframework.transaction.interceptor.TransactionInterceptor;
3637
import org.springframework.util.Assert;
3738

@@ -114,8 +115,23 @@ public S advice(Advice... advice) {
114115
* for the {@link MessageHandler}.
115116
* @param transactionManager the {@link PlatformTransactionManager} to use.
116117
* @return the spec.
118+
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager)}
117119
*/
120+
@Deprecated
118121
public S transactional(PlatformTransactionManager transactionManager) {
122+
return transactional((TransactionManager) transactionManager);
123+
}
124+
125+
/**
126+
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
127+
* {@code PlatformTransactionManager} and default
128+
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
129+
* for the {@link MessageHandler}.
130+
* @param transactionManager the {@link TransactionManager} to use.
131+
* @return the spec.
132+
* @since 5.2.5
133+
*/
134+
public S transactional(TransactionManager transactionManager) {
119135
return transactional(transactionManager, false);
120136
}
121137

@@ -130,8 +146,27 @@ public S transactional(PlatformTransactionManager transactionManager) {
130146
* {@link org.springframework.integration.transaction.TransactionHandleMessageAdvice}
131147
* extension.
132148
* @return the spec.
149+
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager, boolean)}
133150
*/
151+
@Deprecated
134152
public S transactional(PlatformTransactionManager transactionManager, boolean handleMessageAdvice) {
153+
return transactional((TransactionManager) transactionManager, handleMessageAdvice);
154+
}
155+
156+
/**
157+
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
158+
* {@code PlatformTransactionManager} and default
159+
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
160+
* for the {@link MessageHandler}.
161+
* @param transactionManager the {@link TransactionManager} to use.
162+
* @param handleMessageAdvice the flag to indicate the target {@link Advice} type:
163+
* {@code false} - regular {@link TransactionInterceptor}; {@code true} -
164+
* {@link org.springframework.integration.transaction.TransactionHandleMessageAdvice}
165+
* extension.
166+
* @return the spec.
167+
* @since 5.2.5
168+
*/
169+
public S transactional(TransactionManager transactionManager, boolean handleMessageAdvice) {
135170
return transactional(new TransactionInterceptorBuilder(handleMessageAdvice)
136171
.transactionManager(transactionManager)
137172
.build());

spring-integration-core/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import org.springframework.messaging.Message;
3232
import org.springframework.messaging.MessageChannel;
3333
import org.springframework.transaction.PlatformTransactionManager;
34+
import org.springframework.transaction.TransactionManager;
3435
import org.springframework.transaction.interceptor.TransactionInterceptor;
3536
import org.springframework.util.Assert;
3637

@@ -193,14 +194,29 @@ public DelayerEndpointSpec transactionalRelease(TransactionInterceptor transacti
193194

194195
/**
195196
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
196-
* {@code PlatformTransactionManager} and default
197+
* {@link PlatformTransactionManager} and default
197198
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
198199
* for the {@link org.springframework.messaging.MessageHandler}.
199200
* @param transactionManager the {@link PlatformTransactionManager} to use.
200201
* @return the spec.
201202
* @since 5.0.8
203+
* @deprecated since 5.2.5 in favor of {@link #transactionalRelease(TransactionManager)}
202204
*/
205+
@Deprecated
203206
public DelayerEndpointSpec transactionalRelease(PlatformTransactionManager transactionManager) {
207+
return transactionalRelease((TransactionManager) transactionManager);
208+
}
209+
210+
/**
211+
* Specify a {@link TransactionInterceptor} {@link Advice} with the provided
212+
* {@link TransactionManager} and default
213+
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
214+
* for the {@link org.springframework.messaging.MessageHandler}.
215+
* @param transactionManager the {@link TransactionManager} to use.
216+
* @return the spec.
217+
* @since 5.2.5
218+
*/
219+
public DelayerEndpointSpec transactionalRelease(TransactionManager transactionManager) {
204220
return transactionalRelease(
205221
new TransactionInterceptorBuilder()
206222
.transactionManager(transactionManager)

spring-integration-core/src/main/java/org/springframework/integration/dsl/PollerSpec.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.messaging.MessageChannel;
3333
import org.springframework.scheduling.Trigger;
3434
import org.springframework.transaction.PlatformTransactionManager;
35+
import org.springframework.transaction.TransactionManager;
3536
import org.springframework.transaction.interceptor.TransactionInterceptor;
3637
import org.springframework.util.ErrorHandler;
3738

@@ -144,13 +145,28 @@ public PollerSpec advice(Advice... advice) {
144145

145146
/**
146147
* Specify a {@link TransactionInterceptor} {@link Advice} with the
147-
* provided {@code PlatformTransactionManager} and default
148+
* provided {@link PlatformTransactionManager} and default
148149
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
149150
* for the {@code pollingTask}.
150151
* @param transactionManager the {@link PlatformTransactionManager} to use.
151152
* @return the spec.
153+
* @deprecated since 5.2.5 in favor of {@link #transactional(TransactionManager)}
152154
*/
155+
@Deprecated
153156
public PollerSpec transactional(PlatformTransactionManager transactionManager) {
157+
return transactional((TransactionManager) transactionManager);
158+
}
159+
160+
/**
161+
* Specify a {@link TransactionInterceptor} {@link Advice} with the
162+
* provided {@link TransactionManager} and default
163+
* {@link org.springframework.transaction.interceptor.DefaultTransactionAttribute}
164+
* for the {@code pollingTask}.
165+
* @param transactionManager the {@link TransactionManager} to use.
166+
* @return the spec.
167+
* @since 5.2.5
168+
*/
169+
public PollerSpec transactional(TransactionManager transactionManager) {
154170
return transactional(new TransactionInterceptorBuilder()
155171
.transactionManager(transactionManager)
156172
.build());

spring-integration-core/src/main/java/org/springframework/integration/transaction/TransactionHandleMessageAdvice.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.integration.handler.advice.HandleMessageAdvice;
2222
import org.springframework.transaction.PlatformTransactionManager;
23+
import org.springframework.transaction.TransactionManager;
2324
import org.springframework.transaction.interceptor.TransactionAttributeSource;
2425
import org.springframework.transaction.interceptor.TransactionInterceptor;
2526

@@ -46,12 +47,42 @@ public class TransactionHandleMessageAdvice extends TransactionInterceptor imple
4647
public TransactionHandleMessageAdvice() {
4748
}
4849

50+
/**
51+
* Create a new TransactionHandleMessageAdvice.
52+
* @param transactionManager the default transaction manager to perform the actual transaction management
53+
* @param transactionAttributeSource the attribute source to be used to find transaction attributes
54+
* @since 5.2.5
55+
* @see TransactionInterceptor
56+
*/
57+
public TransactionHandleMessageAdvice(TransactionManager transactionManager,
58+
TransactionAttributeSource transactionAttributeSource) {
59+
60+
super(transactionManager, transactionAttributeSource);
61+
}
62+
63+
/**
64+
* Create a new TransactionHandleMessageAdvice.
65+
* @param ptm the default transaction manager to perform the actual transaction management
66+
* @param attributes the attribute source to be used to find transaction attributes
67+
* @deprecated since 5.2.5 in favor of {@link #TransactionHandleMessageAdvice()}
68+
* and {@link #setTransactionManager(TransactionManager)}, {@link #setTransactionAttributes(Properties)}
69+
*/
70+
@Deprecated
4971
public TransactionHandleMessageAdvice(PlatformTransactionManager ptm, Properties attributes) {
50-
super(ptm, attributes);
72+
setTransactionManager(ptm);
73+
setTransactionAttributes(attributes);
5174
}
5275

76+
/**
77+
* Create a new TransactionHandleMessageAdvice.
78+
* @param ptm the default transaction manager to perform the actual transaction management
79+
* @param tas the attribute source to be used to find transaction attributes
80+
* @deprecated since 5.2.5 in favor of
81+
* {@link #TransactionHandleMessageAdvice(TransactionManager, TransactionAttributeSource)}
82+
*/
83+
@Deprecated
5384
public TransactionHandleMessageAdvice(PlatformTransactionManager ptm, TransactionAttributeSource tas) {
54-
super(ptm, tas);
85+
this((TransactionManager) ptm, tas);
5586
}
5687

5788
}

spring-integration-core/src/main/java/org/springframework/integration/transaction/TransactionInterceptorBuilder.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.integration.transaction;
1818

1919
import org.springframework.transaction.PlatformTransactionManager;
20+
import org.springframework.transaction.TransactionManager;
2021
import org.springframework.transaction.annotation.Isolation;
2122
import org.springframework.transaction.annotation.Propagation;
2223
import org.springframework.transaction.interceptor.DefaultTransactionAttribute;
@@ -91,11 +92,27 @@ public final TransactionInterceptorBuilder transactionAttribute(TransactionAttri
9192
return this;
9293
}
9394

94-
public TransactionInterceptorBuilder transactionManager(PlatformTransactionManager transactionManager) {
95+
/**
96+
* Provide a {@link TransactionManager} instance to use.
97+
* @param transactionManager the {@link TransactionManager} to use
98+
* @return the builder
99+
*/
100+
public TransactionInterceptorBuilder transactionManager(TransactionManager transactionManager) {
95101
this.transactionInterceptor.setTransactionManager(transactionManager);
96102
return this;
97103
}
98104

105+
/**
106+
* Provide a {@link PlatformTransactionManager} instance to use.
107+
* @param transactionManager the {@link PlatformTransactionManager} to use
108+
* @return the builder
109+
* @deprecated since 5.2.5 in favor of {@link #transactionManager(TransactionManager)}
110+
*/
111+
@Deprecated
112+
public TransactionInterceptorBuilder transactionManager(PlatformTransactionManager transactionManager) {
113+
return transactionManager((TransactionManager) transactionManager);
114+
}
115+
99116
public TransactionInterceptor build() {
100117
return this.transactionInterceptor;
101118
}

spring-integration-core/src/test/java/org/springframework/integration/transaction/TransactionInterceptorBuilderTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2019 the original author or authors.
2+
* Copyright 2016-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.test.context.junit4.SpringRunner;
2828
import org.springframework.transaction.PlatformTransactionManager;
29+
import org.springframework.transaction.TransactionManager;
2930
import org.springframework.transaction.annotation.Isolation;
3031
import org.springframework.transaction.annotation.Propagation;
3132
import org.springframework.transaction.interceptor.TransactionAttribute;
@@ -75,7 +76,7 @@ public PseudoTransactionManager transactionManager() {
7576
}
7677

7778
@Bean
78-
public TransactionInterceptor interceptor1(PlatformTransactionManager transactionManager) {
79+
public TransactionInterceptor interceptor1(TransactionManager transactionManager) {
7980
return new TransactionInterceptorBuilder()
8081
.propagation(Propagation.REQUIRES_NEW)
8182
.isolation(Isolation.SERIALIZABLE)

spring-integration-jms/src/test/java/org/springframework/integration/jms/ActiveMQMultiContextTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
*/
3636
public abstract class ActiveMQMultiContextTests {
3737

38-
protected static final ActiveMQConnectionFactory amqFactory =
38+
public static final ActiveMQConnectionFactory amqFactory =
3939
new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
4040

41-
protected static final CachingConnectionFactory connectionFactory =
41+
public static final CachingConnectionFactory connectionFactory =
4242
new CachingConnectionFactory(amqFactory);
4343

4444
@BeforeClass

spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/PipelineJmsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-integration-jms/src/test/java/org/springframework/integration/jms/request_reply/PipelineNamedReplyQueuesJmsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<beans xmlns="http://www.springframework.org/schema/beans"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xmlns:int="http://www.springframework.org/schema/integration"
5-
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
6-
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:int="http://www.springframework.org/schema/integration"
5+
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
6+
xmlns:util="http://www.springframework.org/schema/util"
7+
xsi:schemaLocation="http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
78
http://www.springframework.org/schema/integration/jms https://www.springframework.org/schema/integration/jms/spring-integration-jms.xsd
8-
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
9+
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
10+
http://www.springframework.org/schema/util https://www.springframework.org/schema/util/spring-util.xsd">
911

1012
<int:gateway default-request-channel="pipeline01" default-request-timeout="10000" default-reply-timeout="10000"/>
1113

1214
<int-jms:outbound-gateway request-channel="pipeline01"
13-
connection-factory="jmsConnectionFactory"
1415
receive-timeout="10000"
1516
request-destination-name="pipeline01-queue-01">
1617
<int-jms:reply-listener />
1718
</int-jms:outbound-gateway>
1819

1920
<int-jms:inbound-gateway request-channel="jmsIn"
2021
request-destination-name="pipeline01-queue-01"
21-
connection-factory="jmsConnectionFactory"
2222
concurrent-consumers="10"
2323
reply-timeout="10000"/>
2424

@@ -31,30 +31,19 @@
3131
</int:chain>
3232

3333
<int-jms:outbound-gateway request-channel="anotherGatewayChannel"
34-
connection-factory="jmsConnectionFactory"
3534
receive-timeout="10000"
3635
request-destination-name="pipeline01-queue-02">
3736
<int-jms:reply-listener />
3837
</int-jms:outbound-gateway>
3938

4039
<int-jms:inbound-gateway request-channel="anotherIn"
4140
request-destination-name="pipeline01-queue-02"
42-
connection-factory="jmsConnectionFactory"
4341
concurrent-consumers="10"
4442
reply-timeout="10000"/>
4543

4644
<int:transformer input-channel="anotherIn" expression="payload"/>
4745

48-
<bean id="jmsConnectionFactory"
49-
class="org.springframework.jms.connection.CachingConnectionFactory">
50-
<property name="targetConnectionFactory">
51-
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
52-
<property name="brokerURL" value="vm://localhost?broker.persistent=false"/>
53-
</bean>
54-
</property>
55-
<property name="sessionCacheSize" value="10"/>
56-
<property name="cacheProducers" value="true" />
57-
<property name="cacheConsumers" value="true" />
58-
</bean>
46+
<util:constant id="jmsConnectionFactory"
47+
static-field="org.springframework.integration.jms.ActiveMQMultiContextTests.connectionFactory"/>
5948

6049
</beans>

0 commit comments

Comments
 (0)