ChannelInterceptor default methods + deprecate adapter

This commit is contained in:
Rossen Stoyanchev
2018-05-23 21:48:19 -04:00
parent eed663ff7e
commit fbf25c536d
9 changed files with 42 additions and 41 deletions

View File

@@ -17,10 +17,8 @@
package org.springframework.messaging.simp.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -64,7 +62,6 @@ import org.springframework.messaging.simp.user.UserDestinationMessageHandler;
import org.springframework.messaging.simp.user.UserRegistryMessageHandler;
import org.springframework.messaging.support.AbstractSubscribableChannel;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
import org.springframework.messaging.support.ExecutorSubscribableChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -607,7 +604,7 @@ public class MessageBrokerConfigurationTests {
@Configuration
static class CustomConfig extends BaseTestMessageBrokerConfig {
private ChannelInterceptor interceptor = new ChannelInterceptorAdapter() {};
private ChannelInterceptor interceptor = new ChannelInterceptor() {};
@Override
protected void configureClientInboundChannel(ChannelRegistration registration) {

View File

@@ -88,7 +88,7 @@ public class ChannelInterceptorTests {
public void postSendInterceptorMessageWasSent() {
final AtomicBoolean preSendInvoked = new AtomicBoolean(false);
final AtomicBoolean completionInvoked = new AtomicBoolean(false);
this.channel.addInterceptor(new ChannelInterceptorAdapter() {
this.channel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
assertInput(message, channel, sent);
@@ -121,7 +121,7 @@ public class ChannelInterceptorTests {
};
final AtomicBoolean preSendInvoked = new AtomicBoolean(false);
final AtomicBoolean completionInvoked = new AtomicBoolean(false);
testChannel.addInterceptor(new ChannelInterceptorAdapter() {
testChannel.addInterceptor(new ChannelInterceptor() {
@Override
public void postSend(Message<?> message, MessageChannel channel, boolean sent) {
assertInput(message, channel, sent);
@@ -199,7 +199,7 @@ public class ChannelInterceptorTests {
}
private abstract static class AbstractTestInterceptor extends ChannelInterceptorAdapter {
private abstract static class AbstractTestInterceptor implements ChannelInterceptor {
private AtomicInteger counter = new AtomicInteger();

View File

@@ -186,8 +186,7 @@ public class ExecutorSubscribableChannelTests {
}
private abstract static class AbstractTestInterceptor extends ChannelInterceptorAdapter
implements ExecutorChannelInterceptor {
private abstract static class AbstractTestInterceptor implements ChannelInterceptor, ExecutorChannelInterceptor {
private AtomicInteger counter = new AtomicInteger();
@@ -209,7 +208,9 @@ public class ExecutorSubscribableChannelTests {
}
@Override
public void afterMessageHandled(Message<?> message, MessageChannel channel, MessageHandler handler, Exception ex) {
public void afterMessageHandled(Message<?> message, MessageChannel channel, MessageHandler handler,
Exception ex) {
this.afterHandledInvoked = true;
}
}