@@ -21,8 +21,6 @@ import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.handler.AbstractMessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -34,8 +32,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractInternetProtocolSendingMessageHandler extends AbstractMessageHandler implements CommonSocketOptions {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private final SocketAddress destinationAddress;
|
||||
|
||||
private final String host;
|
||||
|
||||
@@ -49,4 +49,6 @@ public abstract class IpHeaders {
|
||||
@Deprecated
|
||||
public static final String CONNECTION_SEQ = IP + "connection_seq";
|
||||
|
||||
private IpHeaders() {}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class IpAdapterParserUtils {
|
||||
static final String SO_SEND_BUFFER_SIZE = "so-send-buffer-size";
|
||||
|
||||
static final String SO_KEEP_ALIVE = "so-keep-alive";
|
||||
|
||||
|
||||
static final String RECEIVE_BUFFER_SIZE = "receive-buffer-size";
|
||||
|
||||
static final String POOL_SIZE = "pool-size";
|
||||
@@ -64,18 +64,12 @@ public abstract class IpAdapterParserUtils {
|
||||
static final String MIN_ACKS_SUCCESS = "min-acks-for-success";
|
||||
|
||||
static final String TIME_TO_LIVE = "time-to-live";
|
||||
|
||||
|
||||
static final String USING_NIO = "using-nio";
|
||||
|
||||
|
||||
static final String USING_DIRECT_BUFFERS = "using-direct-buffers";
|
||||
|
||||
|
||||
static final String MESSAGE_FORMAT = "message-format";
|
||||
|
||||
static final String CUSTOM_SOCKET_READER_CLASS_NAME =
|
||||
"custom-socket-reader-class-name";
|
||||
|
||||
static final String CUSTOM_SOCKET_WRITER_CLASS_NAME =
|
||||
"custom-socket-writer-class-name";
|
||||
|
||||
static final String SO_LINGER = "so-linger";
|
||||
|
||||
@@ -88,9 +82,9 @@ public abstract class IpAdapterParserUtils {
|
||||
static final String TASK_EXECUTOR = "task-executor";
|
||||
|
||||
static final String TCP_CONNECTION_TYPE = "type";
|
||||
|
||||
|
||||
static final String SERIALIZER = "serializer";
|
||||
|
||||
|
||||
static final String DESERIALIZER = "deserializer";
|
||||
|
||||
static final String SINGLE_USE = "single-use";
|
||||
@@ -119,6 +113,8 @@ public abstract class IpAdapterParserUtils {
|
||||
|
||||
public static final String SCHEDULER = "scheduler";
|
||||
|
||||
private IpAdapterParserUtils() {}
|
||||
|
||||
/**
|
||||
* Adds a constructor-arg to the provided bean definition builder
|
||||
* with the value of the attribute whose name is provided if that
|
||||
|
||||
@@ -20,8 +20,6 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
@@ -53,8 +51,6 @@ import org.springframework.util.Assert;
|
||||
public class TcpSendingMessageHandler extends AbstractMessageHandler implements
|
||||
TcpSender, SmartLifecycle, ClientModeCapable {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private volatile AbstractConnectionFactory clientConnectionFactory;
|
||||
|
||||
private volatile AbstractConnectionFactory serverConnectionFactory;
|
||||
|
||||
@@ -34,9 +34,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
@@ -53,9 +50,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
|
||||
implements ConnectionFactory, Runnable, SmartLifecycle, BeanNameAware {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
implements ConnectionFactory, Runnable, SmartLifecycle {
|
||||
|
||||
protected static final int DEFAULT_REPLY_TIMEOUT = 10000;
|
||||
|
||||
|
||||
@@ -90,8 +90,9 @@ public abstract class AbstractTcpConnection implements TcpConnection {
|
||||
}
|
||||
|
||||
public void afterSend(Message<?> message) throws Exception {
|
||||
if (logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Message sent " + message);
|
||||
}
|
||||
if (this.singleUse) {
|
||||
// if (we're a server socket, or a send-only socket), and soLinger <> 0, close
|
||||
if ((this.isServer() || this.actualListener == null) && this.soLinger != 0) {
|
||||
|
||||
@@ -170,7 +170,7 @@ public abstract class AbstractTcpConnectionInterceptor implements TcpConnectionI
|
||||
return this.realSender;
|
||||
}
|
||||
TcpSender sender = this.getSender();
|
||||
while (sender != null && sender instanceof AbstractTcpConnectionInterceptor) {
|
||||
while (sender instanceof AbstractTcpConnectionInterceptor) {
|
||||
sender = ((AbstractTcpConnectionInterceptor) sender).getSender();
|
||||
}
|
||||
this.realSender = sender != null;
|
||||
|
||||
@@ -128,8 +128,9 @@ public class TcpNetConnection extends AbstractTcpConnection {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Message received " + message);
|
||||
}
|
||||
try {
|
||||
if (listener == null) {
|
||||
logger.warn("Unexpected message - no inbound adapter registered with connection " + message);
|
||||
|
||||
@@ -40,8 +40,9 @@ public class ByteArrayCrLfSerializer extends AbstractByteArraySerializer {
|
||||
byte[] buffer = new byte[this.maxMessageSize];
|
||||
int n = 0;
|
||||
int bite;
|
||||
if (logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Available to read:" + inputStream.available());
|
||||
}
|
||||
while (true) {
|
||||
bite = inputStream.read();
|
||||
// logger.debug("Read:" + (char) bite);
|
||||
@@ -49,8 +50,9 @@ public class ByteArrayCrLfSerializer extends AbstractByteArraySerializer {
|
||||
throw new SoftEndOfStreamException("Stream closed between payloads");
|
||||
}
|
||||
checkClosure(bite);
|
||||
if (n > 0 && bite == '\n' && buffer[n-1] == '\r')
|
||||
if (n > 0 && bite == '\n' && buffer[n-1] == '\r') {
|
||||
break;
|
||||
}
|
||||
buffer[n++] = (byte) bite;
|
||||
if (n >= this.maxMessageSize) {
|
||||
throw new IOException("CRLF not found before max message length: "
|
||||
|
||||
@@ -44,8 +44,9 @@ public class ByteArrayRawSerializer extends AbstractByteArraySerializer {
|
||||
byte[] buffer = new byte[this.maxMessageSize];
|
||||
int n = 0;
|
||||
int bite = 0;
|
||||
if (logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Available to read:" + inputStream.available());
|
||||
}
|
||||
while (bite >= 0) {
|
||||
bite = inputStream.read();
|
||||
if (bite < 0) {
|
||||
|
||||
@@ -49,8 +49,9 @@ public class ByteArrayStxEtxSerializer extends AbstractByteArraySerializer {
|
||||
if (bite < 0) {
|
||||
throw new SoftEndOfStreamException("Stream closed between payloads");
|
||||
}
|
||||
if (bite != STX)
|
||||
if (bite != STX) {
|
||||
throw new MessageMappingException("Expected STX to begin message");
|
||||
}
|
||||
byte[] buffer = new byte[this.maxMessageSize];
|
||||
int n = 0;
|
||||
while ((bite = inputStream.read()) != ETX) {
|
||||
|
||||
@@ -98,7 +98,16 @@ public class MulticastSendingMessageHandler extends UnicastSendingMessageHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
protected synchronized DatagramSocket getSocket() throws IOException {
|
||||
protected DatagramSocket getSocket() throws IOException {
|
||||
if (this.getTheSocket() == null) {
|
||||
synchronized (this) {
|
||||
createSocket();
|
||||
}
|
||||
}
|
||||
return this.getTheSocket();
|
||||
}
|
||||
|
||||
private void createSocket() throws IOException {
|
||||
if (this.getTheSocket() == null) {
|
||||
MulticastSocket socket;
|
||||
if (this.isAcknowledge()) {
|
||||
@@ -128,7 +137,6 @@ public class MulticastSendingMessageHandler extends UnicastSendingMessageHandler
|
||||
}
|
||||
this.setSocket(socket);
|
||||
}
|
||||
return this.getTheSocket();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -138,8 +138,9 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
|
||||
Message<byte[]> message = null;
|
||||
try {
|
||||
message = mapper.toMessage(packet);
|
||||
if (logger.isDebugEnabled())
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Received:" + message);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.error("Failed to map packet to message ", e);
|
||||
|
||||
@@ -239,8 +239,9 @@ public class UnicastSendingMessageHandler extends
|
||||
throw new MessageHandlingException(message, "failed to send UDP packet", e);
|
||||
}
|
||||
finally {
|
||||
if (countdownLatch != null)
|
||||
if (countdownLatch != null) {
|
||||
this.ackControl.remove(messageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,4 +42,5 @@ public abstract class RegexUtils {
|
||||
return out;
|
||||
}
|
||||
|
||||
private RegexUtils() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user