Skip to content

Commit 6575243

Browse files
committed
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
1 parent 12ef5cf commit 6575243

25 files changed

+1444
-85
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,232 @@
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+
protected C target;
43+
44+
public AbstractConnectionFactorySpec(C connectionFactory) {
45+
this.target = connectionFactory;
46+
}
47+
48+
@Override
49+
public S id(String id) {
50+
return super.id(id);
51+
}
52+
53+
/**
54+
* @param soTimeout the socket timeout option.
55+
* @return the spec.
56+
* @see AbstractConnectionFactory#setSoTimeout(int)
57+
*/
58+
public S soTimeout(int soTimeout) {
59+
this.target.setSoTimeout(soTimeout);
60+
return _this();
61+
}
62+
63+
/**
64+
* @param soReceiveBufferSize the socket receive buffer size option.
65+
* @return the spec.
66+
* @see AbstractConnectionFactory#setSoReceiveBufferSize(int)
67+
*/
68+
public S soReceiveBufferSize(int soReceiveBufferSize) {
69+
this.target.setSoReceiveBufferSize(soReceiveBufferSize);
70+
return _this();
71+
}
72+
73+
/**
74+
* @param soSendBufferSize the socket send buffer size option.
75+
* @return the spec.
76+
* @see AbstractConnectionFactory#setSoSendBufferSize(int)
77+
*/
78+
public S soSendBufferSize(int soSendBufferSize) {
79+
this.target.setSoSendBufferSize(soSendBufferSize);
80+
return _this();
81+
}
82+
83+
/**
84+
* @param soTcpNoDelay the socket TCP no delay option (disable Nagle's algorithm).
85+
* @return the spec.
86+
* @see AbstractConnectionFactory#setSoTcpNoDelay(boolean)
87+
*/
88+
public S soTcpNoDelay(boolean soTcpNoDelay) {
89+
this.target.setSoTcpNoDelay(soTcpNoDelay);
90+
return _this();
91+
}
92+
93+
/**
94+
* @param soLinger the socket linger option.
95+
* @return the spec.
96+
* @see AbstractConnectionFactory#setSoLinger(int)
97+
*/
98+
public S soLinger(int soLinger) {
99+
this.target.setSoLinger(soLinger);
100+
return _this();
101+
}
102+
103+
/**
104+
* @param soKeepAlive the socket keepalive option.
105+
* @return the spec.
106+
* @see AbstractConnectionFactory#setSoKeepAlive(boolean)
107+
*/
108+
public S soKeepAlive(boolean soKeepAlive) {
109+
this.target.setSoKeepAlive(soKeepAlive);
110+
return _this();
111+
}
112+
113+
/**
114+
* @param soTrafficClass the socket traffic class option.
115+
* @return the spec.
116+
* @see AbstractConnectionFactory#setSoTrafficClass(int)
117+
*/
118+
public S soTrafficClass(int soTrafficClass) {
119+
this.target.setSoTrafficClass(soTrafficClass);
120+
return _this();
121+
}
122+
123+
/**
124+
* @param taskExecutor the task excecutor.
125+
* @return the spec.
126+
* @see AbstractConnectionFactory#setTaskExecutor(Executor)
127+
*/
128+
public S taskExecutor(Executor taskExecutor) {
129+
this.target.setTaskExecutor(taskExecutor);
130+
return _this();
131+
}
132+
133+
/**
134+
* @param deserializer the deserializer.
135+
* @return the spec.
136+
* @see AbstractConnectionFactory#setDeserializer(Deserializer)
137+
*/
138+
public S deserializer(Deserializer<?> deserializer) {
139+
this.target.setDeserializer(deserializer);
140+
return _this();
141+
}
142+
143+
/**
144+
* @param serializer the serializer.
145+
* @return the spec.
146+
* @see AbstractConnectionFactory#setSerializer(Serializer)
147+
*/
148+
public S serializer(Serializer<?> serializer) {
149+
this.target.setSerializer(serializer);
150+
return _this();
151+
}
152+
153+
/**
154+
* @param mapper the message mapper.
155+
* @return the spec.
156+
* @see AbstractConnectionFactory#setMapper(TcpMessageMapper)
157+
*/
158+
public S mapper(TcpMessageMapper mapper) {
159+
this.target.setMapper(mapper);
160+
return _this();
161+
}
162+
163+
/**
164+
* @param keepOpen true to keep the socket open for additional messages; inverse
165+
* of {@link AbstractConnectionFactory#setSingleUse(boolean)}.
166+
* @return the spec.
167+
* @see AbstractConnectionFactory#setSingleUse(boolean)
168+
*/
169+
public S keepOpen(boolean keepOpen) {
170+
this.target.setSingleUse(!keepOpen);
171+
return _this();
172+
}
173+
174+
/**
175+
* @param interceptorFactoryChain the interceptor factory chain.
176+
* @return the spec.
177+
* @see AbstractConnectionFactory#setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain)
178+
*/
179+
public S interceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) {
180+
this.target.setInterceptorFactoryChain(interceptorFactoryChain);
181+
return _this();
182+
}
183+
184+
/**
185+
* @param lookupHost true to reverse lookup the host.
186+
* @return the spec.
187+
* @see AbstractConnectionFactory#setLookupHost(boolean)
188+
*/
189+
public S lookupHost(boolean lookupHost) {
190+
this.target.setLookupHost(lookupHost);
191+
return _this();
192+
}
193+
194+
/**
195+
* @param nioHarvestInterval the harvest interval when using NIO.
196+
* @return the spec.
197+
* @see AbstractConnectionFactory#setNioHarvestInterval(int)
198+
*/
199+
public S nioHarvestInterval(int nioHarvestInterval) {
200+
this.target.setNioHarvestInterval(nioHarvestInterval);
201+
return _this();
202+
}
203+
204+
/**
205+
* @param readDelay the read delay.
206+
* @return the spec.
207+
* @see AbstractConnectionFactory#setReadDelay(long)
208+
*/
209+
public S readDelay(long readDelay) {
210+
this.target.setReadDelay(readDelay);
211+
return _this();
212+
}
213+
214+
/**
215+
* @param tcpSocketSupport the {@link TcpSocketSupport}.
216+
* @return the spec.
217+
* @see AbstractConnectionFactory#setTcpSocketSupport(TcpSocketSupport)
218+
*/
219+
public S tcpSocketSupport(TcpSocketSupport tcpSocketSupport) {
220+
this.target.setTcpSocketSupport(tcpSocketSupport);
221+
return _this();
222+
}
223+
224+
@Override
225+
protected C doGet() {
226+
if (getId() != null) {
227+
this.target.setBeanName(getId());
228+
}
229+
return this.target;
230+
}
231+
232+
}

0 commit comments

Comments
 (0)