Skip to content

Commit 65ec234

Browse files
garyrussellartembilan
authored andcommitted
INT-4162: TCP/UDP DSL
JIRA: https://jira.spring.io/browse/INT-4162 INT-4162: IP DSL - Phase I Connection Factories Phase 2 - Adapters/Gateways Phase 3 - UDP Polishing - PR Comments Remove unnecessary generics. More Polishing - PR Comments Checkstyle/Javadoc Fixes ComponentsRegistration Improvements Add ...Spec CTORs to avoid the issue described here: https://github.com/spring-projects/spring-integration-java-dsl/issues/137 Also other PR comments. Fix UDP Spec Inheritance Jdbc Lock Test Log Adjuster Fix Mongo Test Race Conditions * Fox typos in the `AbstractUdpOutboundChannelAdapterSpec` * Improve `IpIntegrationTests.testUdpInheritance()` * Change `fixed-rate` to `fixed-delay` in the `MongoDbInboundChannelAdapterIntegrationTests-context` to pursue single-threaded environment from poller for test
1 parent 4634829 commit 65ec234

30 files changed

+1758
-113
lines changed

spring-integration-ip/src/main/java/org/springframework/integration/ip/config/TcpConnectionFactoryFactoryBean.java

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.springframework.beans.factory.config.AbstractFactoryBean;
2525
import org.springframework.context.ApplicationEventPublisher;
2626
import org.springframework.context.ApplicationEventPublisherAware;
27-
import org.springframework.context.SmartLifecycle;
27+
import org.springframework.context.Lifecycle;
2828
import org.springframework.core.serializer.Deserializer;
2929
import org.springframework.core.serializer.Serializer;
3030
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
@@ -55,8 +55,8 @@
5555
* @author Gary Russell
5656
* @since 2.0.5
5757
*/
58-
public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<AbstractConnectionFactory> implements SmartLifecycle, BeanNameAware,
59-
BeanFactoryAware, ApplicationEventPublisherAware {
58+
public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<AbstractConnectionFactory>
59+
implements Lifecycle, BeanNameAware, BeanFactoryAware, ApplicationEventPublisherAware {
6060

6161
private volatile AbstractConnectionFactory connectionFactory;
6262

@@ -446,33 +446,6 @@ public void stop() {
446446
this.connectionFactory.stop();
447447
}
448448

449-
/**
450-
* @return phase
451-
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#getPhase()
452-
*/
453-
@Override
454-
public int getPhase() {
455-
return this.connectionFactory.getPhase();
456-
}
457-
458-
/**
459-
* @return isAutoStartup
460-
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#isAutoStartup()
461-
*/
462-
@Override
463-
public boolean isAutoStartup() {
464-
return this.connectionFactory.isAutoStartup();
465-
}
466-
467-
/**
468-
* @param callback The Runnable to invoke.
469-
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#stop(java.lang.Runnable)
470-
*/
471-
@Override
472-
public void stop(Runnable callback) {
473-
this.connectionFactory.stop(callback);
474-
}
475-
476449
@Override
477450
public boolean isRunning() {
478451
return this.connectionFactory.isRunning();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
/*
2+
* Copyright 2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.integration.ip.dsl;
18+
19+
import java.util.concurrent.Executor;
20+
21+
import org.springframework.core.serializer.Deserializer;
22+
import org.springframework.core.serializer.Serializer;
23+
import org.springframework.integration.dsl.IntegrationComponentSpec;
24+
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
25+
import org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactoryChain;
26+
import org.springframework.integration.ip.tcp.connection.TcpMessageMapper;
27+
import org.springframework.integration.ip.tcp.connection.TcpSocketSupport;
28+
29+
/**
30+
* An {@link IntegrationComponentSpec} for {@link AbstractConnectionFactory}s.
31+
* @param <S> the target {@link AbstractConnectionFactorySpec} implementation type.
32+
* @param <C> the target {@link AbstractConnectionFactory} implementation type.
33+
*
34+
* @author Gary Russell
35+
* @since 5.0
36+
*
37+
*/
38+
public abstract class AbstractConnectionFactorySpec
39+
<S extends AbstractConnectionFactorySpec<S, C>, C extends AbstractConnectionFactory>
40+
extends IntegrationComponentSpec<S, C> {
41+
42+
AbstractConnectionFactorySpec(C connectionFactory) {
43+
this.target = connectionFactory;
44+
}
45+
46+
@Override
47+
public S id(String id) {
48+
this.target.setBeanName(id);
49+
return _this();
50+
}
51+
52+
/**
53+
* @param soTimeout the timeout socket option.
54+
* @return the spec.
55+
* @see AbstractConnectionFactory#setSoTimeout(int)
56+
*/
57+
public S soTimeout(int soTimeout) {
58+
this.target.setSoTimeout(soTimeout);
59+
return _this();
60+
}
61+
62+
/**
63+
* @param soReceiveBufferSize the receive buffer size socket option.
64+
* @return the spec.
65+
* @see AbstractConnectionFactory#setSoReceiveBufferSize(int)
66+
*/
67+
public S soReceiveBufferSize(int soReceiveBufferSize) {
68+
this.target.setSoReceiveBufferSize(soReceiveBufferSize);
69+
return _this();
70+
}
71+
72+
/**
73+
* @param soSendBufferSize the send buffer size socket option.
74+
* @return the spec.
75+
* @see AbstractConnectionFactory#setSoSendBufferSize(int)
76+
*/
77+
public S soSendBufferSize(int soSendBufferSize) {
78+
this.target.setSoSendBufferSize(soSendBufferSize);
79+
return _this();
80+
}
81+
82+
/**
83+
* @param soTcpNoDelay the TCP no delay socket option (disable Nagle's algorithm).
84+
* @return the spec.
85+
* @see AbstractConnectionFactory#setSoTcpNoDelay(boolean)
86+
*/
87+
public S soTcpNoDelay(boolean soTcpNoDelay) {
88+
this.target.setSoTcpNoDelay(soTcpNoDelay);
89+
return _this();
90+
}
91+
92+
/**
93+
* @param soLinger the linger socket option.
94+
* @return the spec.
95+
* @see AbstractConnectionFactory#setSoLinger(int)
96+
*/
97+
public S soLinger(int soLinger) {
98+
this.target.setSoLinger(soLinger);
99+
return _this();
100+
}
101+
102+
/**
103+
* @param soKeepAlive the keep alive socket option.
104+
* @return the spec.
105+
* @see AbstractConnectionFactory#setSoKeepAlive(boolean)
106+
*/
107+
public S soKeepAlive(boolean soKeepAlive) {
108+
this.target.setSoKeepAlive(soKeepAlive);
109+
return _this();
110+
}
111+
112+
/**
113+
* @param soTrafficClass the traffic class socket option.
114+
* @return the spec.
115+
* @see AbstractConnectionFactory#setSoTrafficClass(int)
116+
*/
117+
public S soTrafficClass(int soTrafficClass) {
118+
this.target.setSoTrafficClass(soTrafficClass);
119+
return _this();
120+
}
121+
122+
/**
123+
* @param taskExecutor the task executor.
124+
* @return the spec.
125+
* @see AbstractConnectionFactory#setTaskExecutor(Executor)
126+
*/
127+
public S taskExecutor(Executor taskExecutor) {
128+
this.target.setTaskExecutor(taskExecutor);
129+
return _this();
130+
}
131+
132+
/**
133+
* @param deserializer the deserializer.
134+
* @return the spec.
135+
* @see AbstractConnectionFactory#setDeserializer(Deserializer)
136+
*/
137+
public S deserializer(Deserializer<?> deserializer) {
138+
this.target.setDeserializer(deserializer);
139+
return _this();
140+
}
141+
142+
/**
143+
* @param serializer the serializer.
144+
* @return the spec.
145+
* @see AbstractConnectionFactory#setSerializer(Serializer)
146+
*/
147+
public S serializer(Serializer<?> serializer) {
148+
this.target.setSerializer(serializer);
149+
return _this();
150+
}
151+
152+
/**
153+
* @param mapper the message mapper.
154+
* @return the spec.
155+
* @see AbstractConnectionFactory#setMapper(TcpMessageMapper)
156+
*/
157+
public S mapper(TcpMessageMapper mapper) {
158+
this.target.setMapper(mapper);
159+
return _this();
160+
}
161+
162+
/**
163+
* @param leaveOpen true to leave the socket open for additional messages.
164+
* @return the spec.
165+
* @see AbstractConnectionFactory#setLeaveOpen(boolean)
166+
*/
167+
public S leaveOpen(boolean leaveOpen) {
168+
this.target.setLeaveOpen(leaveOpen);
169+
return _this();
170+
}
171+
172+
/**
173+
* @param interceptorFactoryChain the interceptor factory chain.
174+
* @return the spec.
175+
* @see AbstractConnectionFactory#setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain)
176+
*/
177+
public S interceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) {
178+
this.target.setInterceptorFactoryChain(interceptorFactoryChain);
179+
return _this();
180+
}
181+
182+
/**
183+
* @param lookupHost true to reverse lookup the host.
184+
* @return the spec.
185+
* @see AbstractConnectionFactory#setLookupHost(boolean)
186+
*/
187+
public S lookupHost(boolean lookupHost) {
188+
this.target.setLookupHost(lookupHost);
189+
return _this();
190+
}
191+
192+
/**
193+
* @param nioHarvestInterval the harvest interval when using NIO.
194+
* @return the spec.
195+
* @see AbstractConnectionFactory#setNioHarvestInterval(int)
196+
*/
197+
public S nioHarvestInterval(int nioHarvestInterval) {
198+
this.target.setNioHarvestInterval(nioHarvestInterval);
199+
return _this();
200+
}
201+
202+
/**
203+
* @param readDelay the read delay.
204+
* @return the spec.
205+
* @see AbstractConnectionFactory#setReadDelay(long)
206+
*/
207+
public S readDelay(long readDelay) {
208+
this.target.setReadDelay(readDelay);
209+
return _this();
210+
}
211+
212+
/**
213+
* @param tcpSocketSupport the {@link TcpSocketSupport}.
214+
* @return the spec.
215+
* @see AbstractConnectionFactory#setTcpSocketSupport(TcpSocketSupport)
216+
*/
217+
public S tcpSocketSupport(TcpSocketSupport tcpSocketSupport) {
218+
this.target.setTcpSocketSupport(tcpSocketSupport);
219+
return _this();
220+
}
221+
222+
}

0 commit comments

Comments
 (0)