Skip to content

INT-4162: TCP/UDP DSL #1966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.context.Lifecycle;
import org.springframework.core.serializer.Deserializer;
import org.springframework.core.serializer.Serializer;
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
Expand Down Expand Up @@ -55,8 +55,8 @@
* @author Gary Russell
* @since 2.0.5
*/
public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<AbstractConnectionFactory> implements SmartLifecycle, BeanNameAware,
BeanFactoryAware, ApplicationEventPublisherAware {
public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<AbstractConnectionFactory>
implements Lifecycle, BeanNameAware, BeanFactoryAware, ApplicationEventPublisherAware {

private volatile AbstractConnectionFactory connectionFactory;

Expand Down Expand Up @@ -446,33 +446,6 @@ public void stop() {
this.connectionFactory.stop();
}

/**
* @return phase
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#getPhase()
*/
@Override
public int getPhase() {
return this.connectionFactory.getPhase();
}

/**
* @return isAutoStartup
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#isAutoStartup()
*/
@Override
public boolean isAutoStartup() {
return this.connectionFactory.isAutoStartup();
}

/**
* @param callback The Runnable to invoke.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#stop(java.lang.Runnable)
*/
@Override
public void stop(Runnable callback) {
this.connectionFactory.stop(callback);
}

@Override
public boolean isRunning() {
return this.connectionFactory.isRunning();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
/*
* Copyright 2016 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.integration.ip.dsl;

import java.util.concurrent.Executor;

import org.springframework.core.serializer.Deserializer;
import org.springframework.core.serializer.Serializer;
import org.springframework.integration.dsl.IntegrationComponentSpec;
import org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory;
import org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactoryChain;
import org.springframework.integration.ip.tcp.connection.TcpMessageMapper;
import org.springframework.integration.ip.tcp.connection.TcpSocketSupport;

/**
* An {@link IntegrationComponentSpec} for {@link AbstractConnectionFactory}s.
* @param <S> the target {@link AbstractConnectionFactorySpec} implementation type.
* @param <C> the target {@link AbstractConnectionFactory} implementation type.
*
* @author Gary Russell
* @since 5.0
*
*/
public abstract class AbstractConnectionFactorySpec
<S extends AbstractConnectionFactorySpec<S, C>, C extends AbstractConnectionFactory>
extends IntegrationComponentSpec<S, C> {

AbstractConnectionFactorySpec(C connectionFactory) {
this.target = connectionFactory;
}

@Override
public S id(String id) {
this.target.setBeanName(id);
return _this();
}

/**
* @param soTimeout the timeout socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoTimeout(int)
*/
public S soTimeout(int soTimeout) {
this.target.setSoTimeout(soTimeout);
return _this();
}

/**
* @param soReceiveBufferSize the receive buffer size socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoReceiveBufferSize(int)
*/
public S soReceiveBufferSize(int soReceiveBufferSize) {
this.target.setSoReceiveBufferSize(soReceiveBufferSize);
return _this();
}

/**
* @param soSendBufferSize the send buffer size socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoSendBufferSize(int)
*/
public S soSendBufferSize(int soSendBufferSize) {
this.target.setSoSendBufferSize(soSendBufferSize);
return _this();
}

/**
* @param soTcpNoDelay the TCP no delay socket option (disable Nagle's algorithm).
* @return the spec.
* @see AbstractConnectionFactory#setSoTcpNoDelay(boolean)
*/
public S soTcpNoDelay(boolean soTcpNoDelay) {
this.target.setSoTcpNoDelay(soTcpNoDelay);
return _this();
}

/**
* @param soLinger the linger socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoLinger(int)
*/
public S soLinger(int soLinger) {
this.target.setSoLinger(soLinger);
return _this();
}

/**
* @param soKeepAlive the keep alive socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoKeepAlive(boolean)
*/
public S soKeepAlive(boolean soKeepAlive) {
this.target.setSoKeepAlive(soKeepAlive);
return _this();
}

/**
* @param soTrafficClass the traffic class socket option.
* @return the spec.
* @see AbstractConnectionFactory#setSoTrafficClass(int)
*/
public S soTrafficClass(int soTrafficClass) {
this.target.setSoTrafficClass(soTrafficClass);
return _this();
}

/**
* @param taskExecutor the task executor.
* @return the spec.
* @see AbstractConnectionFactory#setTaskExecutor(Executor)
*/
public S taskExecutor(Executor taskExecutor) {
this.target.setTaskExecutor(taskExecutor);
return _this();
}

/**
* @param deserializer the deserializer.
* @return the spec.
* @see AbstractConnectionFactory#setDeserializer(Deserializer)
*/
public S deserializer(Deserializer<?> deserializer) {
this.target.setDeserializer(deserializer);
return _this();
}

/**
* @param serializer the serializer.
* @return the spec.
* @see AbstractConnectionFactory#setSerializer(Serializer)
*/
public S serializer(Serializer<?> serializer) {
this.target.setSerializer(serializer);
return _this();
}

/**
* @param mapper the message mapper.
* @return the spec.
* @see AbstractConnectionFactory#setMapper(TcpMessageMapper)
*/
public S mapper(TcpMessageMapper mapper) {
this.target.setMapper(mapper);
return _this();
}

/**
* @param leaveOpen true to leave the socket open for additional messages.
* @return the spec.
* @see AbstractConnectionFactory#setLeaveOpen(boolean)
*/
public S leaveOpen(boolean leaveOpen) {
this.target.setLeaveOpen(leaveOpen);
return _this();
}

/**
* @param interceptorFactoryChain the interceptor factory chain.
* @return the spec.
* @see AbstractConnectionFactory#setInterceptorFactoryChain(TcpConnectionInterceptorFactoryChain)
*/
public S interceptorFactoryChain(TcpConnectionInterceptorFactoryChain interceptorFactoryChain) {
this.target.setInterceptorFactoryChain(interceptorFactoryChain);
return _this();
}

/**
* @param lookupHost true to reverse lookup the host.
* @return the spec.
* @see AbstractConnectionFactory#setLookupHost(boolean)
*/
public S lookupHost(boolean lookupHost) {
this.target.setLookupHost(lookupHost);
return _this();
}

/**
* @param nioHarvestInterval the harvest interval when using NIO.
* @return the spec.
* @see AbstractConnectionFactory#setNioHarvestInterval(int)
*/
public S nioHarvestInterval(int nioHarvestInterval) {
this.target.setNioHarvestInterval(nioHarvestInterval);
return _this();
}

/**
* @param readDelay the read delay.
* @return the spec.
* @see AbstractConnectionFactory#setReadDelay(long)
*/
public S readDelay(long readDelay) {
this.target.setReadDelay(readDelay);
return _this();
}

/**
* @param tcpSocketSupport the {@link TcpSocketSupport}.
* @return the spec.
* @see AbstractConnectionFactory#setTcpSocketSupport(TcpSocketSupport)
*/
public S tcpSocketSupport(TcpSocketSupport tcpSocketSupport) {
this.target.setTcpSocketSupport(tcpSocketSupport);
return _this();
}

}
Loading