From 4832130ef2d930aa715b43b94456311e3196cdc6 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 14 Aug 2013 16:10:37 -0400 Subject: [PATCH] INT-3082 (S)FTP Remove Deprecated 'cache-sessions' The 'cache-sessions' attribute was deprecated in 2.1 in favor of using a configured CachingConnectionFactory to provide more flexibility, such as setting the cache size. Remove the attribute from the schemas. Update tests. Add docs. Update Migration Guide on the project Wiki. --- ...RemoteFileInboundChannelAdapterParser.java | 10 +++---- ...stractRemoteFileOutboundGatewayParser.java | 11 +++----- ...emoteFileOutboundChannelAdapterParser.java | 24 +++++++---------- .../remote/session/CachingSessionFactory.java | 24 +++++++++++++++++ .../session/SessionFactoryFactoryBean.java | 26 +++++++++++++++---- .../ftp/config/spring-integration-ftp-3.0.xsd | 8 ------ ...boundChannelAdapterParserTests-context.xml | 9 ++++--- .../FtpInboundChannelAdapterParserTests.java | 5 ++-- ...boundChannelAdapterParserTests-context.xml | 1 - ...OutboundChannelAdapterParserTests-fail.xml | 1 - .../FtpOutboundGatewayParserTests-context.xml | 9 ++++--- ...FtpsOutboundChannelAdapterParserTests.java | 5 ++-- .../config/spring-integration-sftp-3.0.xsd | 8 ------ ...annelAdapterParserCachingTests-context.xml | 16 ++++-------- ...boundChannelAdapterParserCachingTests.java | 18 ++++--------- ...annelAdapterParserCachingTests-context.xml | 13 ++++------ ...boundChannelAdapterParserCachingTests.java | 10 ++----- ...boundChannelAdapterParserTests-context.xml | 6 ++++- ...SftpOutboundGatewayParserTests-context.xml | 11 ++++---- src/reference/docbook/ftp.xml | 20 +++++++++----- src/reference/docbook/sftp.xml | 20 +++++++++----- src/reference/docbook/whats-new.xml | 19 ++++++++++++-- 22 files changed, 148 insertions(+), 126 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileInboundChannelAdapterParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileInboundChannelAdapterParser.java index bcae8b9279..811fa53248 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileInboundChannelAdapterParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileInboundChannelAdapterParser.java @@ -16,15 +16,15 @@ package org.springframework.integration.file.config; +import org.w3c.dom.Element; + import org.springframework.beans.BeanMetadataElement; import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.config.ExpressionFactoryBean; import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.springframework.integration.file.remote.session.SessionFactoryFactoryBean; import org.springframework.util.StringUtils; -import org.w3c.dom.Element; /** * Abstract base class for parsing remote file inbound channel adapters. @@ -41,11 +41,7 @@ public abstract class AbstractRemoteFileInboundChannelAdapterParser extends Abst BeanDefinitionBuilder synchronizerBuilder = BeanDefinitionBuilder.genericBeanDefinition( this.getInboundFileSynchronizerClassname()); - BeanDefinitionBuilder sessionFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SessionFactoryFactoryBean.class); - sessionFactoryBuilder.addConstructorArgReference(element.getAttribute("session-factory")); - sessionFactoryBuilder.addConstructorArgValue(element.getAttribute("cache-sessions")); - - synchronizerBuilder.addConstructorArgValue(sessionFactoryBuilder.getBeanDefinition()); + synchronizerBuilder.addConstructorArgReference(element.getAttribute("session-factory")); // configure the InboundFileSynchronizer properties IntegrationNamespaceUtils.setValueIfAttributeDefined(synchronizerBuilder, element, "remote-directory"); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java index 1094015306..c869b02ac3 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/AbstractRemoteFileOutboundGatewayParser.java @@ -15,13 +15,13 @@ */ package org.springframework.integration.file.config; +import org.w3c.dom.Element; + import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.xml.ParserContext; import org.springframework.integration.config.xml.AbstractConsumerEndpointParser; import org.springframework.integration.config.xml.IntegrationNamespaceUtils; -import org.springframework.integration.file.remote.session.SessionFactoryFactoryBean; import org.springframework.util.StringUtils; -import org.w3c.dom.Element; /** * @author Gary Russell @@ -41,12 +41,7 @@ public abstract class AbstractRemoteFileOutboundGatewayParser extends AbstractCo protected BeanDefinitionBuilder parseHandler(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(getGatewayClassName()); - // build the SessionFactory and provide it as a constructor argument - BeanDefinitionBuilder sessionFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SessionFactoryFactoryBean.class); - sessionFactoryBuilder.addConstructorArgReference(element.getAttribute("session-factory")); - sessionFactoryBuilder.addConstructorArgValue(element.getAttribute("cache-sessions")); - - builder.addConstructorArgValue(sessionFactoryBuilder.getBeanDefinition()); + builder.addConstructorArgReference(element.getAttribute("session-factory")); builder.addConstructorArgValue(element.getAttribute("command")); builder.addConstructorArgValue(element.getAttribute(EXPRESSION_ATTRIBUTE)); diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java b/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java index 7ac68143e0..919c79114a 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/config/RemoteFileOutboundChannelAdapterParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2013 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. @@ -30,26 +30,22 @@ import org.springframework.integration.config.xml.AbstractOutboundChannelAdapter import org.springframework.integration.config.xml.IntegrationNamespaceUtils; import org.springframework.integration.file.DefaultFileNameGenerator; import org.springframework.integration.file.remote.handler.FileTransferringMessageHandler; -import org.springframework.integration.file.remote.session.SessionFactoryFactoryBean; import org.springframework.util.StringUtils; /** * @author Oleg Zhurakousky * @author Mark Fisher * @author David Turanski + * @author Gary Russell * @since 2.0 */ public class RemoteFileOutboundChannelAdapterParser extends AbstractOutboundChannelAdapterParser { - + @Override protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) { BeanDefinitionBuilder handlerBuilder = BeanDefinitionBuilder.genericBeanDefinition(FileTransferringMessageHandler.class); - BeanDefinitionBuilder sessionFactoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(SessionFactoryFactoryBean.class); - sessionFactoryBuilder.addConstructorArgReference(element.getAttribute("session-factory")); - sessionFactoryBuilder.addConstructorArgValue(element.getAttribute("cache-sessions")); - - handlerBuilder.addConstructorArgValue(sessionFactoryBuilder.getBeanDefinition()); + handlerBuilder.addConstructorArgReference(element.getAttribute("session-factory")); // configure MessageHandler properties IntegrationNamespaceUtils.setValueIfAttributeDefined(handlerBuilder, element, "temporary-file-suffix"); @@ -82,14 +78,14 @@ public class RemoteFileOutboundChannelAdapterParser extends AbstractOutboundChan handlerBuilder.addPropertyValue("remoteFileSeparator", element.getAttribute("remote-file-separator")); return handlerBuilder.getBeanDefinition(); } - + private void configureRemoteDirectories(Element element, BeanDefinitionBuilder handlerBuilder){ this.doConfigureRemoteDirectory(element, handlerBuilder, "remote-directory", "remote-directory-expression", "remoteDirectoryExpression", true); this.doConfigureRemoteDirectory(element, handlerBuilder, "temporary-remote-directory", "temporary-remote-directory-expression", "temporaryRemoteDirectoryExpression", false); } - - private void doConfigureRemoteDirectory(Element element, BeanDefinitionBuilder handlerBuilder, - String directoryAttribute, String directoryExpressionAttribute, + + private void doConfigureRemoteDirectory(Element element, BeanDefinitionBuilder handlerBuilder, + String directoryAttribute, String directoryExpressionAttribute, String directoryExpressionPropertyName, boolean atLeastOneRequired){ String remoteDirectory = element.getAttribute(directoryAttribute); String remoteDirectoryExpression = element.getAttribute(directoryExpressionAttribute); @@ -101,14 +97,14 @@ public class RemoteFileOutboundChannelAdapterParser extends AbstractOutboundChan "is required on a remote file outbound adapter"); } } - + BeanDefinition remoteDirectoryExpressionDefinition = null; if (hasRemoteDirectory) { remoteDirectoryExpressionDefinition = new RootBeanDefinition(LiteralExpression.class); remoteDirectoryExpressionDefinition.getConstructorArgumentValues().addGenericArgumentValue(remoteDirectory); } else if (hasRemoteDirectoryExpression) { - remoteDirectoryExpressionDefinition = new RootBeanDefinition(ExpressionFactoryBean.class); + remoteDirectoryExpressionDefinition = new RootBeanDefinition(ExpressionFactoryBean.class); remoteDirectoryExpressionDefinition.getConstructorArgumentValues().addGenericArgumentValue(remoteDirectoryExpression); } if (remoteDirectoryExpressionDefinition != null){ diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java index 8c59dd2bcb..39077b51e5 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/CachingSessionFactory.java @@ -22,6 +22,7 @@ import java.io.OutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.DisposableBean; import org.springframework.integration.util.SimplePool; @@ -44,10 +45,23 @@ public class CachingSessionFactory implements SessionFactory, DisposableBe private final SimplePool> pool; + /** + * Create a CachingSessionFactory with an unlimited number of sessions. + * @param sessionFactory the underlying session factory. + */ public CachingSessionFactory(SessionFactory sessionFactory) { this(sessionFactory, 0); } + /** + * Create a CachingSessionFactory with the specified session limit. By default, if + * no sessions are available in the cache, and the size limit has been reached, + * calling threads will block until a session is available. + * @see #setSessionWaitTimeout(long) + * @see #setPoolSize(int) + * @param sessionFactory the underlying session factory. + * @param sessionCacheSize the maximum cache size. + */ public CachingSessionFactory(SessionFactory sessionFactory, int sessionCacheSize) { this.sessionFactory = sessionFactory; this.pool = new SimplePool>(sessionCacheSize, new SimplePool.PoolItemCallback>() { @@ -75,14 +89,24 @@ public class CachingSessionFactory implements SessionFactory, DisposableBe this.pool.setWaitTimeout(sessionWaitTimeout); } + /** + * Modify the target session pool size; the actual pool size will adjust up/down + * to this size as and when sessions are requested or retrieved. + */ public void setPoolSize(int poolSize) { this.pool.setPoolSize(poolSize); } + /** + * Get a session from the pool (or block if none available). + */ public Session getSession() { return new CachedSession(this.pool.getItem()); } + /** + * Remove (close) any unused sessions in the pool. + */ public void destroy() { this.pool.removeAllIdleItems(); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/SessionFactoryFactoryBean.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/SessionFactoryFactoryBean.java index feb3769e1d..b49d2c3b24 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/SessionFactoryFactoryBean.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/session/SessionFactoryFactoryBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2011 the original author or authors. + * Copyright 2002-2013 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,21 +15,37 @@ */ package org.springframework.integration.file.remote.session; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.FactoryBean; /** * Temporary factory bean to manage SessionFactory until deprecated 'cache-sessions' attribute * is removed. - * + * + * The attribute is now removed so we deprecate this class and log a message in case someone + * is using it directly. It is no longer used by the framework. + * * @author Oleg Zhurakousky + * @author Gary Russell * @since 2.1 * + * @deprecated */ +@Deprecated public class SessionFactoryFactoryBean implements FactoryBean> { - + + Log logger = LogFactory.getLog(this.getClass()); + private final SessionFactory sessionFactory; - + public SessionFactoryFactoryBean(SessionFactory sessionFactory, boolean cacheSessions){ + if (logger.isWarnEnabled()) { + logger.warn("Do not use this factory bean; " + + "instantiate the session factory directly; " + + "if cached sessions are required, wrap it in a CachingSessionFactory."); + } if (cacheSessions && !(sessionFactory instanceof CachingSessionFactory)){ this.sessionFactory = new CachingSessionFactory(sessionFactory); } @@ -42,7 +58,7 @@ public class SessionFactoryFactoryBean implements FactoryBean getObjectType() { return this.sessionFactory.getClass(); } diff --git a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-3.0.xsd b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-3.0.xsd index 6cbb5ceb88..1e47ad5976 100644 --- a/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-3.0.xsd +++ b/spring-integration-ftp/src/main/resources/org/springframework/integration/ftp/config/spring-integration-ftp-3.0.xsd @@ -521,14 +521,6 @@ - - - - - diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml index 4dc42a1f70..b630450762 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests-context.xml @@ -10,10 +10,13 @@ + + + + - diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests.java index a046da08cb..0fefc196a3 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpInboundChannelAdapterParserTests.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.concurrent.PriorityBlockingQueue; import org.junit.Test; + import org.springframework.beans.factory.FactoryBean; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; @@ -84,10 +85,10 @@ public class FtpInboundChannelAdapterParserTests { } @Test - public void cachingSessionFactoryByDefault() throws Exception{ + public void cachingSessionFactory() throws Exception{ ApplicationContext ac = new ClassPathXmlApplicationContext( "FtpInboundChannelAdapterParserTests-context.xml", this.getClass()); - SourcePollingChannelAdapter adapter = ac.getBean("simpleAdapter", SourcePollingChannelAdapter.class); + SourcePollingChannelAdapter adapter = ac.getBean("simpleAdapterWithCachedSessions", SourcePollingChannelAdapter.class); Object sessionFactory = TestUtils.getPropertyValue(adapter, "source.synchronizer.sessionFactory"); assertEquals(CachingSessionFactory.class, sessionFactory.getClass()); FtpInboundFileSynchronizer fisync = diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml index 3b16bf34ba..3d4da6a070 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundChannelAdapterParserTests-context.xml @@ -25,7 +25,6 @@ + + + + cacheSf = TestUtils.getPropertyValue(handler, "sessionFactory", CachingSessionFactory.class); - DefaultFtpsSessionFactory sf = TestUtils.getPropertyValue(cacheSf, "sessionFactory", DefaultFtpsSessionFactory.class); + DefaultFtpsSessionFactory sf = TestUtils.getPropertyValue(handler, "sessionFactory", DefaultFtpsSessionFactory.class); assertEquals("localhost", TestUtils.getPropertyValue(sf, "host")); assertEquals(22, TestUtils.getPropertyValue(sf, "port")); } diff --git a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-3.0.xsd b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-3.0.xsd index f6a1942485..0387e63e7c 100644 --- a/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-3.0.xsd +++ b/spring-integration-sftp/src/main/resources/org/springframework/integration/sftp/config/spring-integration-sftp-3.0.xsd @@ -527,14 +527,6 @@ - - - - - diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml index 9a92511ac3..be66345274 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/InboundChannelAdapterParserCachingTests-context.xml @@ -32,21 +32,16 @@ + + + + no - - - + + + + - - diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserCachingTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserCachingTests.java index 2668e154e2..3b44ecf485 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserCachingTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserCachingTests.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.integration.file.remote.session.CachingSessionFactory; import org.springframework.integration.sftp.session.DefaultSftpSessionFactory; @@ -30,24 +31,17 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Mark Fisher * @author Gunnar Hillert + * @author Gary Russell */ @ContextConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class OutboundChannelAdapterParserCachingTests { - @Autowired private Object defaultAdapter; - @Autowired private Object cachingAdapter; @Autowired private Object nonCachingAdapter; - @Test - public void defaultAdapter() { - Object sessionFactory = TestUtils.getPropertyValue(defaultAdapter, "handler.sessionFactory"); - assertEquals(CachingSessionFactory.class, sessionFactory.getClass()); - } - @Test public void cachingAdapter() { Object sessionFactory = TestUtils.getPropertyValue(cachingAdapter, "handler.sessionFactory"); diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml index 04c984ca6f..978849904a 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/OutboundChannelAdapterParserTests-context.xml @@ -17,10 +17,14 @@ + + + + + + + + FTP Session Factory + + Starting with version 3.0, sessions are no longer cached by default. See . + Before configuring FTP adapters you must configure an FTP Session Factory. You can configure the FTP Session Factory with a regular bean definition where the implementation class is org.springframework.integration.ftp.session.DefaultFtpSessionFactory: @@ -446,14 +449,17 @@ protected void postProcessClientBeforeConnect(T client) throws IOException {
FTP Session Caching + + Starting with version 3.0, sessions are no longer cached by default; the cache-sessions attribute + is no longer supported on endpoints. You must now use a CachingSessionFactory (see below) if you + wish to cache sessions. + - As of version 2.1 we've exposed more flexibility with regard to session management for remote file adapters (e.g., FTP, SFTP etc). - In previous versions the sessions were cached automatically by default. We did expose a cache-sessions attribute for - disabling the auto caching, but that solution did not provide a way to configure other session caching attributes. For example, one - of the requested features was to support a limit on the number of sessions created since a remote server may impose a limit on the - number of client connections. To support that requirement and other configuration options, we decided to promote explicit definition - of the CachingSessionFactory instance. That provides the sessionCacheSize and sessionWaitTimeout - properties. As its name suggests, the sessionCacheSize property controls how many active sessions this adapter will + In versions prior to 3.0, the sessions were cached automatically by default. A cache-sessions attribute was available for + disabling the auto caching, but that solution did not provide a way to configure other session caching attributes. For example, + you could not limit on the number of sessions created. To support that requirement and other configuration options, a + CachingSessionFactory was provided. It provides sessionCacheSize and sessionWaitTimeout + properties. As its name suggests, the sessionCacheSize property controls how many active sessions the factory will maintain in its cache (the DEFAULT is unbounded). If the sessionCacheSize threshold has been reached, any attempt to acquire another session will block until either one of the cached sessions becomes available or until the wait time for a Session expires (the DEFAULT wait time is Integer.MAX_VALUE). The sessionWaitTimeout property enables configuration of that value. diff --git a/src/reference/docbook/sftp.xml b/src/reference/docbook/sftp.xml index debf56db43..e0a9af88c2 100644 --- a/src/reference/docbook/sftp.xml +++ b/src/reference/docbook/sftp.xml @@ -31,6 +31,9 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
SFTP Session Factory + + Starting with version 3.0, sessions are no longer cached by default. See . + Before configuring SFTP adapters, you must configure an SFTP Session Factory. You can configure the SFTP Session @@ -179,14 +182,17 @@ xsi:schemaLocation="http://www.springframework.org/schema/integration/sftp
SFTP Session Caching + + Starting with version 3.0, sessions are no longer cached by default; the cache-sessions attribute + is no longer supported on endpoints. You must now use a CachingSessionFactory (see below) if you + wish to cache sessions. + - As of version 2.1 we've exposed more flexibility with regard to session management for remote file adapters (e.g., FTP, SFTP etc). - In previous versions the sessions were cached automatically by default. We did expose a cache-sessions attribute for - disabling the auto caching, but that solution did not provide a way to configure other session caching attributes. For example, one - of the requested features was to support a limit on the number of sessions created since a remote server may impose a limit on the - number of client connections. To support that requirement and other configuration options, we decided to promote explicit definition - of the CachingSessionFactory instance. That provides the sessionCacheSize and sessionWaitTimeout - properties. As its name suggests, the sessionCacheSize property controls how many active sessions this adapter will + In versions prior to 3.0, the sessions were cached automatically by default. A cache-sessions attribute was available for + disabling the auto caching, but that solution did not provide a way to configure other session caching attributes. For example, + you could not limit on the number of sessions created. To support that requirement and other configuration options, a + CachingSessionFactory was provided. It provides sessionCacheSize and sessionWaitTimeout + properties. As its name suggests, the sessionCacheSize property controls how many active sessions the factory will maintain in its cache (the DEFAULT is unbounded). If the sessionCacheSize threshold has been reached, any attempt to acquire another session will block until either one of the cached sessions becomes available or until the wait time for a Session expires (the DEFAULT wait time is Integer.MAX_VALUE). The sessionWaitTimeout property enables configuration of that value. diff --git a/src/reference/docbook/whats-new.xml b/src/reference/docbook/whats-new.xml index 1d2cface15..f3fee34d99 100644 --- a/src/reference/docbook/whats-new.xml +++ b/src/reference/docbook/whats-new.xml @@ -106,8 +106,23 @@ URI-schemes supported by Spring Web Services. For more information see .
+
+ FTP, SFTP and FTPS Cached Sessions + + The FTP, SFTP and FTPS endpoints no longer cache sessions by default. + + + The deprecated cached-sessions attribute has been removed from all endpoints. + Previously, the embedded caching mechanism controlled by this attribute's value didn't + provide a way to limit the size of the cache, which could + grow indefinitely. The CachingConnectionFactory was introduced in + release 2.1 and it became the preferred (and is now the only) way to cache sessions. + For more information, see + and . + +
- (S)FTP(S) Inbound Adapters + FTP, SFTP and FTPS Inbound Adapters Previously, there was no way to override the default filter used to process files retrieved from a remote server. The filter attribute determines which files are retrieved @@ -128,7 +143,7 @@
- (S)FTP(S) Gateways + FTP, SFTP and FTPS Gateways The gateways now support the mv command, enabling the renaming of remote files.