INT-2830 Resolve Class Tangle

* MessageGroupStore <-> MessageGroupCallback
  - Change callback to be an inner interface of the MGS.
* INT-2829 Fix Class Tangle in IP Module
  - 3 way tangle between TcpSender, TcpConnection, TcpMessageMapper
  - Clean up interfaces (remove setters); add top-level support classes for TcpConnection, TcpConnectionInterceptor.
* INT-2829 Remove TCP Package Tangle
  - tcp.connection <-> tcp.connection.support
  - Remove ...connection.support package - move classes to ...connection.
This commit is contained in:
Gary Russell
2013-01-03 12:53:29 -05:00
committed by Gunnar Hillert
parent f88a97332a
commit 91722b7a5f
43 changed files with 243 additions and 274 deletions

View File

@@ -70,7 +70,7 @@
ssl-context-support="sslContextSupport"
/>
<bean id="sslContextSupport" class="org.springframework.integration.ip.tcp.connection.support.DefaultTcpSSLContextSupport">
<bean id="sslContextSupport" class="org.springframework.integration.ip.tcp.connection.DefaultTcpSSLContextSupport">
<constructor-arg value="classpath:test.ks"/>
<constructor-arg value="test.truststore.ks"/>
<constructor-arg value="secret"/>
@@ -87,11 +87,11 @@
socket-factory-support="socketFactorySupport" />
<bean id="socketSupport" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.integration.ip.tcp.connection.support.TcpSocketSupport" />
<constructor-arg value="org.springframework.integration.ip.tcp.connection.TcpSocketSupport" />
</bean>
<bean id="socketFactorySupport" class="org.mockito.Mockito" factory-method="mock">
<constructor-arg value="org.springframework.integration.ip.tcp.connection.support.TcpSocketFactorySupport" />
<constructor-arg value="org.springframework.integration.ip.tcp.connection.TcpSocketFactorySupport" />
</bean>
<ip:tcp-inbound-channel-adapter id="testInTcp"

View File

@@ -50,16 +50,16 @@ import org.springframework.integration.ip.tcp.TcpOutboundGateway;
import org.springframework.integration.ip.tcp.TcpReceivingChannelAdapter;
import org.springframework.integration.ip.tcp.TcpSendingMessageHandler;
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
import org.springframework.integration.ip.tcp.connection.DefaultTcpNetSSLSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.DefaultTcpNioSSLConnectionSupport;
import org.springframework.integration.ip.tcp.connection.DefaultTcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.TcpNetClientConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpNetSSLSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSocketSupport;
import org.springframework.integration.ip.tcp.connection.TcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.TcpSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.TcpSocketSupport;
import org.springframework.integration.ip.udp.DatagramPacketMessageMapper;
import org.springframework.integration.ip.udp.MulticastReceivingChannelAdapter;
import org.springframework.integration.ip.udp.MulticastSendingMessageHandler;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -79,8 +79,8 @@ public class CachingClientConnectionFactoryTests {
public void testReuse() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn1");
TcpConnection mockConn2 = makeMockConnection("conn2");
TcpConnectionSupport mockConn1 = makeMockConnection("conn1");
TcpConnectionSupport mockConn2 = makeMockConnection("conn2");
when(factory.getConnection()).thenReturn(mockConn1).thenReturn(mockConn2);
CachingClientConnectionFactory cachingFactory = new CachingClientConnectionFactory(factory, 2);
cachingFactory.start();
@@ -99,8 +99,8 @@ public class CachingClientConnectionFactoryTests {
public void testReuseNoLimit() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn1");
TcpConnection mockConn2 = makeMockConnection("conn2");
TcpConnectionSupport mockConn1 = makeMockConnection("conn1");
TcpConnectionSupport mockConn2 = makeMockConnection("conn2");
when(factory.getConnection()).thenReturn(mockConn1).thenReturn(mockConn2);
CachingClientConnectionFactory cachingFactory = new CachingClientConnectionFactory(factory, 0);
cachingFactory.start();
@@ -119,8 +119,8 @@ public class CachingClientConnectionFactoryTests {
public void testReuseClosed() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn1");
TcpConnection mockConn2 = makeMockConnection("conn2");
TcpConnectionSupport mockConn1 = makeMockConnection("conn1");
TcpConnectionSupport mockConn2 = makeMockConnection("conn2");
when(factory.getConnection()).thenReturn(mockConn1)
.thenReturn(mockConn2).thenReturn(mockConn1)
.thenReturn(mockConn2);
@@ -147,8 +147,8 @@ public class CachingClientConnectionFactoryTests {
public void testLimit() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn1");
TcpConnection mockConn2 = makeMockConnection("conn2");
TcpConnectionSupport mockConn1 = makeMockConnection("conn1");
TcpConnectionSupport mockConn2 = makeMockConnection("conn2");
when(factory.getConnection()).thenReturn(mockConn1).thenReturn(mockConn2);
CachingClientConnectionFactory cachingFactory = new CachingClientConnectionFactory(factory, 2);
cachingFactory.setConnectionWaitTimeout(10);
@@ -167,8 +167,8 @@ public class CachingClientConnectionFactoryTests {
public void testStop() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn1");
TcpConnection mockConn2 = makeMockConnection("conn2");
TcpConnectionSupport mockConn1 = makeMockConnection("conn1");
TcpConnectionSupport mockConn2 = makeMockConnection("conn2");
int i = 3;
when(factory.getConnection()).thenReturn(mockConn1)
.thenReturn(mockConn2)
@@ -206,7 +206,7 @@ public class CachingClientConnectionFactoryTests {
public void testEnlargePool() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn = makeMockConnection("conn");
TcpConnectionSupport mockConn = makeMockConnection("conn");
when(factory.getConnection()).thenReturn(mockConn);
CachingClientConnectionFactory cachingFactory = new CachingClientConnectionFactory(factory, 2);
cachingFactory.start();
@@ -232,10 +232,10 @@ public class CachingClientConnectionFactoryTests {
public void testReducePool() throws Exception {
AbstractClientConnectionFactory factory = mock(AbstractClientConnectionFactory.class);
when(factory.isRunning()).thenReturn(true);
TcpConnection mockConn1 = makeMockConnection("conn", true);
TcpConnection mockConn2 = makeMockConnection("conn", true);
TcpConnection mockConn3 = makeMockConnection("conn", true);
TcpConnection mockConn4 = makeMockConnection("conn", true);
TcpConnectionSupport mockConn1 = makeMockConnection("conn", true);
TcpConnectionSupport mockConn2 = makeMockConnection("conn", true);
TcpConnectionSupport mockConn3 = makeMockConnection("conn", true);
TcpConnectionSupport mockConn4 = makeMockConnection("conn", true);
when(factory.getConnection()).thenReturn(mockConn1)
.thenReturn(mockConn2).thenReturn(mockConn3)
.thenReturn(mockConn4);
@@ -267,12 +267,12 @@ public class CachingClientConnectionFactoryTests {
verify(mockConn2).close();
}
private TcpConnection makeMockConnection(String name) {
private TcpConnectionSupport makeMockConnection(String name) {
return makeMockConnection(name, false);
}
private TcpConnection makeMockConnection(String name, boolean closeOk) {
TcpConnection mockConn1 = mock(TcpConnection.class);
private TcpConnectionSupport makeMockConnection(String name, boolean closeOk) {
TcpConnectionSupport mockConn1 = mock(TcpConnectionSupport.class);
when(mockConn1.getConnectionId()).thenReturn(name);
when(mockConn1.toString()).thenReturn(name);
when(mockConn1.isOpen()).thenReturn(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -68,8 +68,8 @@ public class FailoverClientConnectionFactoryTests {
List<AbstractClientConnectionFactory> factories = new ArrayList<AbstractClientConnectionFactory>();
factories.add(factory1);
factories.add(factory2);
TcpConnection conn1 = makeMockConnection();
TcpConnection conn2 = makeMockConnection();
TcpConnectionSupport conn1 = makeMockConnection();
TcpConnectionSupport conn2 = makeMockConnection();
when(factory1.getConnection()).thenReturn(conn1);
when(factory2.getConnection()).thenReturn(conn2);
when(factory1.isActive()).thenReturn(true);
@@ -94,8 +94,8 @@ public class FailoverClientConnectionFactoryTests {
List<AbstractClientConnectionFactory> factories = new ArrayList<AbstractClientConnectionFactory>();
factories.add(factory1);
factories.add(factory2);
TcpConnection conn1 = makeMockConnection();
TcpConnection conn2 = makeMockConnection();
TcpConnectionSupport conn1 = makeMockConnection();
TcpConnectionSupport conn2 = makeMockConnection();
when(factory1.getConnection()).thenReturn(conn1);
when(factory2.getConnection()).thenReturn(conn2);
when(factory1.isActive()).thenReturn(true);
@@ -116,8 +116,8 @@ public class FailoverClientConnectionFactoryTests {
List<AbstractClientConnectionFactory> factories = new ArrayList<AbstractClientConnectionFactory>();
factories.add(factory1);
factories.add(factory2);
TcpConnection conn1 = makeMockConnection();
TcpConnection conn2 = makeMockConnection();
TcpConnectionSupport conn1 = makeMockConnection();
TcpConnectionSupport conn2 = makeMockConnection();
when(factory1.getConnection()).thenReturn(conn1);
when(factory2.getConnection()).thenReturn(conn2);
when(factory1.isActive()).thenReturn(true);
@@ -165,7 +165,7 @@ public class FailoverClientConnectionFactoryTests {
List<AbstractClientConnectionFactory> factories = new ArrayList<AbstractClientConnectionFactory>();
factories.add(factory1);
factories.add(factory2);
TcpConnection conn1 = makeMockConnection();
TcpConnectionSupport conn1 = makeMockConnection();
doAnswer(new Answer<Object>() {
public Object answer(InvocationOnMock invocation) throws Throwable {
return null;
@@ -189,8 +189,8 @@ public class FailoverClientConnectionFactoryTests {
List<AbstractClientConnectionFactory> factories = new ArrayList<AbstractClientConnectionFactory>();
factories.add(factory1);
factories.add(factory2);
TcpConnection conn1 = makeMockConnection();
TcpConnection conn2 = makeMockConnection();
TcpConnectionSupport conn1 = makeMockConnection();
TcpConnectionSupport conn2 = makeMockConnection();
when(factory1.getConnection()).thenReturn(conn1);
when(factory2.getConnection()).thenReturn(conn2);
when(factory1.isActive()).thenReturn(true);
@@ -218,8 +218,8 @@ public class FailoverClientConnectionFactoryTests {
Mockito.verify(conn1, times(3)).send(message);
}
public TcpConnection makeMockConnection() {
TcpConnection connection = mock(TcpConnection.class);
public TcpConnectionSupport makeMockConnection() {
TcpConnectionSupport connection = mock(TcpConnectionSupport.class);
when(connection.isOpen()).thenReturn(true);
return connection;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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,7 @@ import org.springframework.integration.support.MessageBuilder;
* @since 2.0
*
*/
public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
public class HelloWorldInterceptor extends TcpConnectionInterceptorSupport {
Log logger = LogFactory.getLog(this.getClass());
@@ -47,9 +47,9 @@ public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
private volatile boolean pendingSend;
public HelloWorldInterceptor() {
public HelloWorldInterceptor() {
}
/**
* @param hello
* @param world
@@ -75,7 +75,7 @@ public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
throw new MessagingException("Negotiation error", e);
}
} else {
throw new MessagingException("Negotiation error, expected '" + hello +
throw new MessagingException("Negotiation error, expected '" + hello +
"' received '" + payload + "'");
}
} else {
@@ -84,7 +84,7 @@ public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
this.negotiated = true;
this.negotiationSemaphore.release();
} else {
throw new MessagingException("Negotiation error - expected '" + world +
throw new MessagingException("Negotiation error - expected '" + world +
"' received " + payload);
}
return true;
@@ -93,7 +93,7 @@ public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
try {
return super.onMessage(message);
} finally {
// on the server side, we don't want to close if we are expecting a response
// on the server side, we don't want to close if we are expecting a response
if (!(this.isServer() && this.hasRealSender()) && !this.pendingSend) {
this.checkDeferredClose();
}
@@ -144,6 +144,6 @@ public class HelloWorldInterceptor extends AbstractTcpConnectionInterceptor {
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -30,7 +30,7 @@ public class HelloWorldInterceptorFactory implements
public HelloWorldInterceptorFactory() {
}
/**
* @param hello
* @param world
@@ -41,9 +41,9 @@ public class HelloWorldInterceptorFactory implements
}
public TcpConnectionInterceptor getInterceptor() {
public TcpConnectionInterceptorSupport getInterceptor() {
return new HelloWorldInterceptor(hello, world);
}
}

View File

@@ -40,11 +40,6 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.integration.Message;
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpNetSSLSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSSLContextSupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSocketFactorySupport;
import org.springframework.integration.ip.tcp.connection.support.TcpSocketSupport;
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
import org.springframework.integration.ip.util.TestingUtilities;
import org.springframework.integration.message.GenericMessage;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2013 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.
@@ -63,7 +63,7 @@ public class TcpMessageMapperTests {
TcpMessageMapper mapper = new TcpMessageMapper();
Socket socket = SocketFactory.getDefault().createSocket();
TcpConnection connection = new AbstractTcpConnection(socket, false, false) {
TcpConnection connection = new TcpConnectionSupport(socket, false, false) {
public void run() {
}
public void send(Message<?> message) throws Exception {
@@ -115,7 +115,7 @@ public class TcpMessageMapperTests {
TcpMessageMapper mapper = new TcpMessageMapper();
mapper.setApplySequence(true);
Socket socket = SocketFactory.getDefault().createSocket();
TcpConnection connection = new AbstractTcpConnection(socket, false, false) {
TcpConnection connection = new TcpConnectionSupport(socket, false, false) {
public void run() {
}
public void send(Message<?> message) throws Exception {