INT-3262 JDK8 Javadoc Commit

Increase receive timeout for `Jsr223TransformerTests#testInt3162ScriptExecutorThreadSafety`.

JIRA: https://jira.springsource.org/browse/INT-3262
JIRA: https://jira.springsource.org/browse/INT-3263
This commit is contained in:
Gary Russell
2014-01-15 19:14:53 +02:00
committed by Artem Bilan
parent 66efb34342
commit c45b708341
249 changed files with 2265 additions and 985 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -118,7 +118,7 @@ public abstract class AbstractInternetProtocolReceivingChannelAdapter
/**
* Creates a default task executor if none was supplied.
*
* @param threadName
* @param threadName The thread name.
*/
protected void checkTaskExecutor(final String threadName) {
if (this.active && this.taskExecutor == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -57,7 +57,7 @@ public abstract class AbstractInternetProtocolSendingMessageHandler extends Abst
/**
* @see Socket#setSoTimeout(int)
* @see DatagramSocket#setSoTimeout(int)
* @param timeout
* @param timeout The timeout.
*/
@Override
public void setSoTimeout(int timeout) {
@@ -67,7 +67,7 @@ public abstract class AbstractInternetProtocolSendingMessageHandler extends Abst
/**
* @see Socket#setReceiveBufferSize(int)
* @see DatagramSocket#setReceiveBufferSize(int)
* @param size
* @param size The receive buffer size.
*/
@Override
public void setSoReceiveBufferSize(int size) {
@@ -76,7 +76,7 @@ public abstract class AbstractInternetProtocolSendingMessageHandler extends Abst
/**
* @see Socket#setSendBufferSize(int)
* @see DatagramSocket#setSendBufferSize(int)
* @param size
* @param size The send buffer size.
*/
@Override
public void setSoSendBufferSize(int size) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2011 the original author or authors.
* Copyright 2001-2014 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.
@@ -28,21 +28,27 @@ public interface CommonSocketOptions {
/**
* @see Socket#setSoTimeout(int)
* @see DatagramSocket#setSoTimeout(int)
*
* @param soTimeout The timeout.
*/
void setSoTimeout(int soTimeout);
/**
* @see Socket#setReceiveBufferSize(int)
* @see DatagramSocket#setReceiveBufferSize(int)
*
* @param soReceiveBufferSize The receive buffer size.
*/
void setSoReceiveBufferSize(int soReceiveBufferSize);
/**
* @see Socket#setSendBufferSize(int)
* @see DatagramSocket#setSendBufferSize(int)
*
* @param soSendBufferSize The send buffer size.
*/
void setSoSendBufferSize(int soSendBufferSize);
/**
* On a multi-homed system, specifies the ip address of the network interface used to communicate.
* For inbound adapters and gateways, specifies the interface used to listed for incoming connections.
@@ -50,8 +56,8 @@ public interface CommonSocketOptions {
* specifies the interface to which multicast packets will be sent. For UDP unicast and multicast
* adapters, specifies which interface to which the acknowledgment socket will be bound. Does not
* apply to TCP outbound adapters and gateways.
*
* @param localAddress
*
* @param localAddress The local address.
*/
void setLocalAddress(String localAddress);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -132,6 +132,7 @@ public abstract class IpAdapterParserUtils {
* @param builder the bean definition builder to be configured
* @param element the XML element where the attribute should be defined
* @param attributeName the name of the attribute whose value will be
* @param trueFalse not used
* used to populate the property
*/
public static void addConstuctorValueIfAttributeDefined(BeanDefinitionBuilder builder,
@@ -143,9 +144,9 @@ public abstract class IpAdapterParserUtils {
}
/**
* @param element
* @param builder
* @param parserContext
* @param element The element.
* @param builder The builder.
* @param parserContext The parser context.
*/
public static void addHostAndPortToConstructor(Element element,
BeanDefinitionBuilder builder, ParserContext parserContext) {
@@ -160,9 +161,9 @@ public abstract class IpAdapterParserUtils {
}
/**
* @param element
* @param builder
* @param parserContext
* @param element The element.
* @param builder The builder.
* @param parserContext The parser context.
*/
public static void addPortToConstructor(Element element,
BeanDefinitionBuilder builder, ParserContext parserContext) {
@@ -172,8 +173,8 @@ public abstract class IpAdapterParserUtils {
/**
* Asserts that a port attribute is supplied.
* @param element
* @param parserContext
* @param element The element.
* @param parserContext The parser context.
* @return The value of the attribute.
* @throws BeanCreationException if attribute is not provided.
*/
@@ -188,7 +189,7 @@ public abstract class IpAdapterParserUtils {
/**
* Gets the multicast attribute, if present; if not returns 'false'.
* @param element
* @param element The element.
* @return The value of the attribute or false.
*/
static String getMulticast(Element element) {
@@ -202,8 +203,8 @@ public abstract class IpAdapterParserUtils {
/**
* Sets the common port attributes on the bean being built (timeout, receive buffer size,
* send buffer size).
* @param builder
* @param element
* @param builder The builder.
* @param element The element.
*/
static void addCommonSocketOptions(BeanDefinitionBuilder builder, Element element) {
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, SO_TIMEOUT);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -243,7 +243,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param localAddress
* @param localAddress The local addres..
* @see org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory#setLocalAddress(java.lang.String)
*/
public void setLocalAddress(String localAddress) {
@@ -252,7 +252,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soTimeout
* @param soTimeout The timeout.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoTimeout(int)
*/
public void setSoTimeout(int soTimeout) {
@@ -260,7 +260,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soReceiveBufferSize
* @param soReceiveBufferSize The receive buffer size.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoReceiveBufferSize(int)
*/
public void setSoReceiveBufferSize(int soReceiveBufferSize) {
@@ -268,7 +268,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soSendBufferSize
* @param soSendBufferSize The send buffer size.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoSendBufferSize(int)
*/
public void setSoSendBufferSize(int soSendBufferSize) {
@@ -276,7 +276,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soTcpNoDelay
* @param soTcpNoDelay The TCP no delay to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoTcpNoDelay(boolean)
*/
public void setSoTcpNoDelay(boolean soTcpNoDelay) {
@@ -284,7 +284,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soLinger
* @param soLinger The SO Linger to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoLinger(int)
*/
public void setSoLinger(int soLinger) {
@@ -292,7 +292,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soKeepAlive
* @param soKeepAlive The SO keepalive to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoKeepAlive(boolean)
*/
public void setSoKeepAlive(boolean soKeepAlive) {
@@ -300,7 +300,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param soTrafficClass
* @param soTrafficClass The SO traffic class to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSoTrafficClass(int)
*/
public void setSoTrafficClass(int soTrafficClass) {
@@ -315,7 +315,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param usingDirectBuffers
* @param usingDirectBuffers the usingDirectBuffers to set.
* @see org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory#setUsingDirectBuffers(boolean)
*/
public void setUsingDirectBuffers(boolean usingDirectBuffers) {
@@ -323,7 +323,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param taskExecutor
* @param taskExecutor The task executor.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setTaskExecutor(java.util.concurrent.Executor)
*/
public void setTaskExecutor(Executor taskExecutor) {
@@ -332,7 +332,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param deserializer
* @param deserializer The deserializer.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setDeserializer(org.springframework.core.serializer.Deserializer)
*/
public void setDeserializer(Deserializer<?> deserializer) {
@@ -341,7 +341,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param serializer
* @param serializer The serializer.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSerializer(org.springframework.core.serializer.Serializer)
*/
public void setSerializer(Serializer<?> serializer) {
@@ -350,7 +350,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param mapper
* @param mapper The mapper.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setMapper(org.springframework.integration.ip.tcp.connection.TcpMessageMapper)
*/
public void setMapper(TcpMessageMapper mapper) {
@@ -359,7 +359,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param singleUse
* @param singleUse The singleUse to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setSingleUse(boolean)
*/
public void setSingleUse(boolean singleUse) {
@@ -367,7 +367,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param backlog
* @param backlog The backlog.
* @see AbstractServerConnectionFactory#setBacklog(int)
*/
public void setBacklog(int backlog) {
@@ -375,7 +375,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param interceptorFactoryChain
* @param interceptorFactoryChain The interceptor factory chain.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setInterceptorFactoryChain(org.springframework.integration.ip.tcp.connection.TcpConnectionInterceptorFactoryChain)
*/
public void setInterceptorFactoryChain(
@@ -385,7 +385,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
}
/**
* @param lookupHost
* @param lookupHost The lookupHost to set.
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#setLookupHost(boolean)
*/
public void setLookupHost(boolean lookupHost) {
@@ -396,6 +396,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
*
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#start()
*/
@Override
public void start() {
this.connectionFactory.start();
}
@@ -404,6 +405,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
*
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#stop()
*/
@Override
public void stop() {
this.connectionFactory.stop();
}
@@ -412,6 +414,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
* @return phase
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#getPhase()
*/
@Override
public int getPhase() {
return this.connectionFactory.getPhase();
}
@@ -420,22 +423,26 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
* @return isAutoStartup
* @see org.springframework.integration.ip.tcp.connection.AbstractConnectionFactory#isAutoStartup()
*/
@Override
public boolean isAutoStartup() {
return this.connectionFactory.isAutoStartup();
}
/**
* @param callback
* @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();
}
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -459,7 +466,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
/**
* Rare property - not exposed through namespace
* @param tcpNioSupport
* @param tcpNioSupport The tcpNioSupport to set.
*/
public void setNioConnectionSupport(TcpNioConnectionSupport tcpNioSupport) {
Assert.notNull(tcpNioSupport, "TcpNioConnectionSupport may not be null");
@@ -472,6 +479,7 @@ public class TcpConnectionFactoryFactoryBean extends AbstractFactoryBean<Abstrac
this.socketFactorySupport = tcpSocketFactorySupport;
}
@Override
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2014 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.
@@ -23,11 +23,7 @@ import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import org.springframework.context.SmartLifecycle;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.ip.IpHeaders;
import org.springframework.integration.ip.tcp.connection.AbstractClientConnectionFactory;
@@ -35,6 +31,10 @@ import org.springframework.integration.ip.tcp.connection.AbstractConnectionFacto
import org.springframework.integration.ip.tcp.connection.TcpConnection;
import org.springframework.integration.ip.tcp.connection.TcpListener;
import org.springframework.integration.ip.tcp.connection.TcpSender;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.util.Assert;
/**
@@ -156,6 +156,7 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
}
}
@Override
public boolean onMessage(Message<?> message) {
String connectionId = (String) message.getHeaders().get(IpHeaders.CONNECTION_ID);
if (connectionId == null) {
@@ -192,10 +193,12 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
connectionFactory.registerSender(this);
}
@Override
public void addNewConnection(TcpConnection connection) {
// do nothing - no asynchronous multiplexing supported
}
@Override
public void removeDeadConnection(TcpConnection connection) {
// do nothing - no asynchronous multiplexing supported
}
@@ -203,6 +206,8 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
/**
* Specify the Spring Integration reply channel. If this property is not
* set the gateway will check for a 'replyChannel' header on the request.
*
* @param replyChannel The reply channel.
*/
public void setReplyChannel(MessageChannel replyChannel) {
this.setOutputChannel(replyChannel);
@@ -212,26 +217,32 @@ public class TcpOutboundGateway extends AbstractReplyProducingMessageHandler imp
return "ip:tcp-outbound-gateway";
}
@Override
public void start() {
this.connectionFactory.start();
}
@Override
public void stop() {
this.connectionFactory.stop();
}
@Override
public boolean isRunning() {
return this.connectionFactory.isRunning();
}
@Override
public int getPhase() {
return this.phase;
}
@Override
public boolean isAutoStartup() {
return this.autoStartup;
}
@Override
public void stop(Runnable callback) {
this.connectionFactory.stop(callback);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -48,6 +48,7 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
* true, a new connection is returned; otherwise a single connection is
* reused for all requests while the connection remains open.
*/
@Override
public TcpConnectionSupport getConnection() throws Exception {
this.checkActive();
return this.obtainConnection();
@@ -156,7 +157,8 @@ public abstract class AbstractClientConnectionFactory extends AbstractConnection
/**
* Force close the connection and null the field if it's
* a shared connection.
* @param connection
*
* @param connection The connection.
*/
public void forceClose(TcpConnection connection) {
if (this.theConnection == connection) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -44,9 +44,9 @@ import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.core.serializer.Deserializer;
import org.springframework.core.serializer.Serializer;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer;
import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
/**
@@ -137,7 +137,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
/**
* Sets socket attributes on the socket.
* @param socket The socket.
* @throws SocketException
* @throws SocketException Any SocketException.
*/
protected void setSocketAttributes(Socket socket) throws SocketException {
if (this.soTimeout >= 0) {
@@ -370,7 +370,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
/**
* If true, sockets created by this factory will be used once.
* @param singleUse
* @param singleUse The singleUse to set.
*/
public void setSingleUse(boolean singleUse) {
this.singleUse = singleUse;
@@ -425,6 +425,7 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
/**
* Creates a taskExecutor (if one was not provided).
* @return The executor.
*/
protected Executor getTaskExecutor() {
if (!this.active) {
@@ -515,9 +516,10 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
* Removes closed connections from the connections field, and from the connections parameter.
*
* @param selectionCount Number of IO Events, if 0 we were probably woken up by a close.
* @param selector The selector
* @param connections Map of connections
* @throws IOException
* @param selector The selector.
* @param server The server socket channel.
* @param connections Map of connections.
* @throws IOException Any IOException.
*/
protected void processNioSelections(int selectionCount, final Selector selector, ServerSocketChannel server,
Map<SocketChannel, TcpNioConnection> connections) throws IOException {
@@ -632,9 +634,10 @@ public abstract class AbstractConnectionFactory extends IntegrationObjectSupport
}
/**
* @param selector
* @param now
* @throws IOException
* @param selector The selector.
* @param server The server socket channel.
* @param now The current time.
* @throws IOException Any IOException.
*/
protected void doAccept(final Selector selector, ServerSocketChannel server, long now) throws IOException {
throw new UnsupportedOperationException("Nio server factory must override this method");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2014 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.
@@ -47,7 +47,8 @@ public abstract class AbstractServerConnectionFactory
/**
* The port on which the factory will listen.
* @param port
*
* @param port The port.
*/
public AbstractServerConnectionFactory(int port) {
super(port);
@@ -69,6 +70,7 @@ public abstract class AbstractServerConnectionFactory
* Not supported because the factory manages multiple connections and this
* method cannot discriminate.
*/
@Override
public TcpConnection getConnection() throws Exception {
throw new UnsupportedOperationException("Getting a connection from a server factory is not supported");
}
@@ -158,18 +160,20 @@ public abstract class AbstractServerConnectionFactory
/**
* The number of sockets in the connection backlog. Default 5;
* increase if you expect high connection rates.
* @param backlog
* @param backlog The backlog to set.
*/
public void setBacklog(int backlog) {
Assert.isTrue(backlog >= 0, "You cannot set backlog negative");
this.backlog = backlog;
}
@Override
public int beforeShutdown() {
this.shuttingDown = true;
return 0;
}
@Override
public int afterShutdown() {
this.stop();
return 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2014 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.
@@ -17,6 +17,7 @@ package org.springframework.integration.ip.tcp.connection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.Assert;
/**
@@ -38,7 +39,7 @@ public class ClientModeConnectionManager implements Runnable {
private volatile TcpConnection lastConnection;
/**
* @param clientConnectionFactory
* @param clientConnectionFactory The connection factory.
*/
public ClientModeConnectionManager(
AbstractConnectionFactory clientConnectionFactory) {
@@ -46,6 +47,7 @@ public class ClientModeConnectionManager implements Runnable {
this.clientConnectionFactory = clientConnectionFactory;
}
@Override
public void run() {
synchronized (this.clientConnectionFactory) {
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2014 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.
@@ -47,16 +47,16 @@ public interface TcpConnection extends Runnable {
/**
* Converts and sends the message.
* @param message The message
* @throws Exception
* @param message The message,
* @throws Exception Any Exception.
*/
void send(Message<?> message) throws Exception;
/**
* Uses the deserializer to obtain the message payload
* from the connection's input stream.
* @return The payload
* @throws Exception
* @return The payload.
* @throws Exception Any Exception.
*/
Object getPayload() throws Exception;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -44,6 +44,8 @@ public class TcpConnectionEventListeningMessageProducer extends MessageProducerS
* Set the list of event types (classes that extend TcpConnectionEvent) that
* this adapter should send to the message channel. By default, all event
* types will be sent.
*
* @param eventTypes The event types.
*/
public void setEventTypes(Class<? extends TcpConnectionEvent>[] eventTypes) {
Assert.notEmpty(eventTypes, "at least one event type is required");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2014 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.
@@ -171,6 +171,8 @@ public abstract class TcpConnectionSupport implements TcpConnection {
/**
* If we have been intercepted, propagate the close from the outermost interceptor;
* otherwise, just call close().
*
* @param isException true when this call is the result of an Exception.
*/
protected void closeConnection(boolean isException) {
if (!(this.listener instanceof TcpConnectionInterceptor)) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -21,12 +21,12 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.ip.IpHeaders;
import org.springframework.integration.mapping.InboundMessageMapper;
import org.springframework.integration.mapping.OutboundMessageMapper;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandlingException;
/**
* Maps incoming data from a {@link TcpConnection} to a {@link Message}.
@@ -54,6 +54,7 @@ public class TcpMessageMapper implements
private volatile boolean applySequence = false;
@Override
public Message<?> toMessage(TcpConnection connection) throws Exception {
Message<Object> message = null;
Object payload = connection.getPayload();
@@ -102,6 +103,7 @@ public class TcpMessageMapper implements
return null;
}
@Override
public Object fromMessage(Message<?> message) throws Exception {
if (this.stringToBytes) {
return getPayloadAsBytes(message);
@@ -146,14 +148,14 @@ public class TcpMessageMapper implements
/**
* Sets whether outbound String payloads are to be converted
* to byte[]. Default is true.
* @param stringToBytes
* @param stringToBytes The stringToBytes to set.
*/
public void setStringToBytes(boolean stringToBytes) {
this.stringToBytes = stringToBytes;
}
/**
* @param applySequence the applySequence to set
* @param applySequence The applySequence to set.
*/
public void setApplySequence(boolean applySequence) {
this.applySequence = applySequence;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -70,7 +70,7 @@ public class TcpNetClientConnectionFactory extends
* @param host The host.
* @param port The port.
* @return The Socket
* @throws IOException
* @throws IOException Any IOException.
*/
protected Socket createSocket(String host, int port) throws IOException {
return this.tcpSocketFactorySupport.getSocketFactory().createSocket(host, port);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2014 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.
@@ -41,21 +41,6 @@ public class TcpNetConnection extends TcpConnectionSupport {
private volatile long lastSend;
/**
* Constructs a TcpNetConnection for the socket.
* @param socket the socket
* @param server if true this connection was created as
* a result of an incoming request.
* @param lookupHost true if hostname lookup should be performed, otherwise the connection will
* be identified using the ip address.
* @deprecated Use {@link #TcpNetConnection(Socket, boolean, boolean, ApplicationEventPublisher, String)}
* TODO: Remove in 3.1/4.0
*/
@Deprecated
public TcpNetConnection(Socket socket, boolean server, boolean lookupHost) {
this(socket, server, lookupHost, null, null);
}
/**
* Constructs a TcpNetConnection for the socket.
* @param socket the socket

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -55,6 +55,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
* connection {@link TcpConnection#run()} using the task executor.
* I/O errors on the server socket/channel are logged and the factory is stopped.
*/
@Override
public void run() {
ServerSocket theServerSocket = null;
if (this.getListener() == null) {
@@ -133,7 +134,7 @@ public class TcpNetServerConnectionFactory extends AbstractServerConnectionFacto
* @param whichNic An InetAddress if binding to a specific network interface. Set to
* null when configured to bind to all interfaces.
* @return The Server Socket.
* @throws IOException
* @throws IOException Any IOException.
*/
protected ServerSocket createServerSocket(int port, int backlog, InetAddress whichNic) throws IOException {
ServerSocketFactory serverSocketFactory = this.tcpSocketFactorySupport.getServerSocketFactory();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -100,7 +100,7 @@ public class TcpNioClientConnectionFactory extends
/**
* When set to true, connections created by this factory attempt
* to use direct buffers where possible.
* @param usingDirectBuffers
* @param usingDirectBuffers The usingDirectBuffers to set.
* @see ByteBuffer
*/
public void setUsingDirectBuffers(boolean usingDirectBuffers) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -35,9 +35,9 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.core.serializer.Serializer;
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.ip.tcp.serializer.SoftEndOfStreamException;
import org.springframework.util.Assert;
/**
@@ -77,22 +77,13 @@ public class TcpNioConnection extends TcpConnectionSupport {
/**
* Constructs a TcpNetConnection for the SocketChannel.
* @param socketChannel the socketChannel
* @param server if true this connection was created as
* a result of an incoming request.
* @deprecated Use {@link #TcpNioConnection(SocketChannel, boolean, boolean, ApplicationEventPublisher, String)}
* TODO: Remove in 3.1/4.0
*/
@Deprecated
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost) throws Exception {
this(socketChannel, server, lookupHost, null, null);
}
/**
* Constructs a TcpNetConnection for the SocketChannel.
* @param socketChannel the socketChannel
* @param server if true this connection was created as
* @param socketChannel The socketChannel.
* @param server If true, this connection was created as
* a result of an incoming request.
* @param lookupHost true to perform reverse lookups.
* @param applicationEventPublisher The event publisher.
* @param connectionFactoryName The name of the connection factory creating this connection.
* @throws Exception Any Exception.
*/
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher,
@@ -128,10 +119,12 @@ public class TcpNioConnection extends TcpConnectionSupport {
super.close();
}
@Override
public boolean isOpen() {
return this.socketChannel.isOpen();
}
@Override
@SuppressWarnings("unchecked")
public void send(Message<?> message) throws Exception {
synchronized(this.socketChannel) {
@@ -149,14 +142,17 @@ public class TcpNioConnection extends TcpConnectionSupport {
}
}
@Override
public Object getPayload() throws Exception {
return this.getDeserializer().deserialize(this.channelInputStream);
}
@Override
public int getPort() {
return this.socketChannel.socket().getPort();
}
@Override
public Object getDeserializerStateKey() {
return this.channelInputStream;
}
@@ -164,6 +160,9 @@ public class TcpNioConnection extends TcpConnectionSupport {
/**
* Allocates a ByteBuffer of the requested length using normal or
* direct buffers, depending on the usingDirectBuffers field.
*
* @param length The buffer length.
* @return The buffer.
*/
protected ByteBuffer allocate(int length) {
ByteBuffer buffer;
@@ -183,6 +182,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
* and there is no more data; thus freeing the thread to work on other
* sockets.
*/
@Override
public void run() {
if (logger.isTraceEnabled()) {
logger.trace(this.getConnectionId() + " Nio message assembler running...");
@@ -357,6 +357,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
* Hence the count down latch.
*/
this.taskExecutor.execute(new Runnable() {
@Override
public void run() {
try {
TcpNioConnection.this.sendToPipe(rawBuffer);
@@ -448,7 +449,7 @@ public class TcpNioConnection extends TcpConnectionSupport {
/**
* If true, connection will attempt to use direct buffers where
* possible.
* @param usingDirectBuffers
* @param usingDirectBuffers the usingDirectBuffers to set.
*/
public void setUsingDirectBuffers(boolean usingDirectBuffers) {
this.usingDirectBuffers = usingDirectBuffers;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -40,7 +40,7 @@ public interface TcpNioConnectionSupport {
* @param connectionFactoryName the name of the connection factory creating this connection; used
* during event publishing, may be null, in which case "unknown" will be used.
* @return the TcpNioConnection
* @throws Exception
* @throws Exception Any exception.
*/
TcpNioConnection createNewConnection(SocketChannel socketChannel,
boolean server, boolean lookupHost,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -67,17 +67,6 @@ public class TcpNioSSLConnection extends TcpNioConnection {
private boolean needMoreNetworkData;
/**
* @deprecated Use {@link #TcpNioSSLConnection(SocketChannel, boolean, boolean, ApplicationEventPublisher, String, SSLEngine)}
* TODO: Remove in 3.1/4.0
*/
@Deprecated
public TcpNioSSLConnection(SocketChannel socketChannel, boolean server,
boolean lookupHost, SSLEngine sslEngine) throws Exception {
super(socketChannel, server, lookupHost, null, null);
this.sslEngine = sslEngine;
}
public TcpNioSSLConnection(SocketChannel socketChannel, boolean server, boolean lookupHost,
ApplicationEventPublisher applicationEventPublisher, String connectionFactoryName,
SSLEngine sslEngine) throws Exception {
@@ -85,7 +74,6 @@ public class TcpNioSSLConnection extends TcpNioConnection {
this.sslEngine = sslEngine;
}
/**
* Overrides super class method to perform decryption and/or participate
* in handshaking. Decrypted data is sent to the super class to be
@@ -229,6 +217,8 @@ public class TcpNioSSLConnection extends TcpNioConnection {
/**
* Initializes the SSLEngine and sets up the encryption/decryption buffers.
*
* @throws IOException Any IOException.
*/
public void init() throws IOException {
if (this.decoded == null) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -148,12 +148,10 @@ public class TcpNioServerConnectionFactory extends AbstractServerConnectionFacto
}
/**
* @param selector
* @param server
* @param now
* @throws IOException
* @throws SocketException
* @throws ClosedChannelException
* @param selector The selector.
* @param server The server socket channel.
* @param now The current time.
* @throws IOException Any IOException.
*/
@Override
protected void doAccept(final Selector selector, ServerSocketChannel server, long now) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -32,8 +32,8 @@ public interface TcpSSLContextSupport {
/**
* Gets an SSLContext.
* @return the SSLContext.
* @throws GeneralSecurityException
* @throws IOException
* @throws GeneralSecurityException Any GeneralSecurityException.
* @throws IOException Any IOException.
*/
SSLContext getSSLContext() throws GeneralSecurityException, IOException;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -15,7 +15,6 @@
*/
package org.springframework.integration.ip.tcp.serializer;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -24,6 +23,7 @@ import java.nio.ByteBuffer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Reads data in an InputStream to a byte[]; data must be preceded by
* a binary length (network byte order, not included in resulting byte[]).
@@ -75,7 +75,7 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
* Constructs the serializer using the supplied header size.
* Valid header sizes are {@link #HEADER_SIZE_INT} (default),
* {@link #HEADER_SIZE_UNSIGNED_BYTE} and {@link #HEADER_SIZE_UNSIGNED_SHORT}
* @param headerSize
* @param headerSize The header size.
*/
public ByteArrayLengthHeaderSerializer(int headerSize) {
if (headerSize != HEADER_SIZE_INT &&
@@ -92,7 +92,11 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
* IOException if the length field exceeds the maxMessageSize.
* Throws a {@link SoftEndOfStreamException} if the stream
* is closed between messages.
*
* @param inputStream The input stream.
* @throws IOException Any IOException.
*/
@Override
public byte[] deserialize(InputStream inputStream) throws IOException {
int messageLength = this.readHeader(inputStream);
if (logger.isDebugEnabled()) {
@@ -110,7 +114,11 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
/**
* Writes the byte[] to the output stream, preceded by a 4 byte
* length in network byte order (big endian).
*
* @param bytes The bytes.
* @param outputStream The output stream.
*/
@Override
public void serialize(byte[] bytes, OutputStream outputStream) throws IOException {
this.writeHeader(outputStream, bytes.length);
outputStream.write(bytes);
@@ -120,10 +128,12 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
/**
* Reads data from the socket and puts the data in buffer. Blocks until
* buffer is full or a socket timeout occurs.
*
* @param inputStream The input stream.
* @param buffer the buffer into which the data should be read
* @param header true if we are reading the header
* @return {@code < 0} if socket closed and not in the middle of a message
* @throws IOException
* @throws IOException Any IOException.
*/
protected int read(InputStream inputStream, byte[] buffer, boolean header)
throws IOException {
@@ -151,9 +161,9 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
/**
* Writes the header, according to the header format.
* @param outputStream
* @param length
* @throws IOException
* @param outputStream The output stream.
* @param length The length.
* @throws IOException Any IOException.
*/
protected void writeHeader(OutputStream outputStream, int length) throws IOException {
ByteBuffer lengthPart = ByteBuffer.allocate(this.headerSize);
@@ -185,9 +195,10 @@ public class ByteArrayLengthHeaderSerializer extends AbstractByteArraySerializer
/**
* Reads the header and returns the length of the data part.
* @param inputStream
* @return The length of the data part
* @throws IOException
*
* @param inputStream The input stream.
* @return The length of the data part.
* @throws IOException Any IOException.
* @throws SoftEndOfStreamException if socket closes
* before any length data read.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -34,7 +34,7 @@ import org.springframework.util.Assert;
* Serializes a {@link Map} as JSON. Deserializes JSON to
* a {@link Map}. The default {@link JacksonJsonObjectMapperProvider#newInstance()} can be
* overridden using {@link #setJsonObjectMapper(JsonObjectMapper)}.
* <p/>
* <p>
* The JSON deserializer can't delimit multiple JSON
* objects. Therefore another (de)serializer is used to
* apply structure to the stream. By default, this is a
@@ -86,6 +86,7 @@ public class MapJsonSerializer implements Serializer<Map<?, ?>>, Deserializer<Ma
this.packetSerializer = packetSerializer;
}
@Override
public Map<?, ?> deserialize(InputStream inputStream) throws IOException {
byte[] bytes = this.packetDeserializer.deserialize(inputStream);
try {
@@ -96,6 +97,7 @@ public class MapJsonSerializer implements Serializer<Map<?, ?>>, Deserializer<Ma
}
}
@Override
public void serialize(Map<?, ?> object, OutputStream outputStream) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2011 the original author or authors.
* Copyright 2001-2014 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.
@@ -29,11 +29,11 @@ import org.springframework.messaging.MessageHandler;
* A {@link MessageHandler} implementation that maps a Message into
* a UDP datagram packet and sends that to the specified multicast address
* (224.0.0.0 to 239.255.255.255) and port.
*
*
* The only difference between this and its super class is the
* ability to specify how many acknowledgments are required to
* determine success.
*
*
* @author Gary Russell
* @since 2.0
*/
@@ -42,7 +42,7 @@ public class MulticastSendingMessageHandler extends UnicastSendingMessageHandler
private int timeToLive = -1;
private String localAddress;
/**
* Constructs a MulticastSendingMessageHandler to send data to the multicast address/port.
* @param address The multicast address.
@@ -138,11 +138,12 @@ public class MulticastSendingMessageHandler extends UnicastSendingMessageHandler
this.setSocket(socket);
}
}
/**
* If acknowledge = true; how many acks needed for success.
* @param minAcksForSuccess
*
* @param minAcksForSuccess The minimum number of acks that will represent success.
*/
public void setMinAcksForSuccess(int minAcksForSuccess) {
this.setAckCounter(minAcksForSuccess);
@@ -150,12 +151,14 @@ public class MulticastSendingMessageHandler extends UnicastSendingMessageHandler
/**
* Set the underlying {@link MulticastSocket} time to live property.
*
* @param timeToLive {@link MulticastSocket#setTimeToLive(int)}
*/
public void setTimeToLive(int timeToLive) {
this.timeToLive = timeToLive;
}
@Override
public void setLocalAddress(String localAddress) {
this.localAddress = localAddress;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -26,11 +26,11 @@ import java.net.SocketTimeoutException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter;
import org.springframework.integration.ip.IpHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessagingException;
import org.springframework.integration.ip.AbstractInternetProtocolReceivingChannelAdapter;
import org.springframework.integration.ip.IpHeaders;
/**
* A channel adapter to receive incoming UDP packets. Packets can optionally be preceded by a
@@ -53,7 +53,7 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
/**
* Constructs a UnicastReceivingChannelAdapter that listens on the specified port.
* @param port
* @param port The port.
*/
public UnicastReceivingChannelAdapter(int port) {
super(port);
@@ -199,8 +199,8 @@ public class UnicastReceivingChannelAdapter extends AbstractInternetProtocolRece
/**
* Sets timeout and receive buffer size
*
* @param socket
* @throws SocketException
* @param socket The socket.
* @throws SocketException Any socket exception.
*/
protected void setSocketAttributes(DatagramSocket socket)
throws SocketException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -34,7 +34,7 @@ public class TestingUtilities {
* starting a test. Waits for up to 10 seconds by default.
* @param serverConnectionFactory The server connection factory.
* @param delay How long to wait in milliseconds; default 10000 (10 seconds) if null.
* @throws IllegalStateException
* @throws IllegalStateException If the server does not start listening in time.
*/
public static void waitListening(AbstractServerConnectionFactory serverConnectionFactory, Long delay)
throws IllegalStateException {
@@ -64,7 +64,7 @@ public class TestingUtilities {
* Waits for up to 10 seconds by default.
* @param serverConnectionFactory The server connection factory.
* @param delay How long to wait in milliseconds; default 10000 (10 seconds) if null.
* @throws IllegalStateException
* @throws IllegalStateException If the server doesn't stop listening in time.
*/
public static void waitStopListening(AbstractServerConnectionFactory serverConnectionFactory, Long delay)
throws IllegalStateException {