|
| 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