Class CachingSessionFactory<F>
java.lang.Object
org.springframework.integration.file.remote.session.CachingSessionFactory<F>
- Type Parameters:
- F- the target system file type.
- All Implemented Interfaces:
- DisposableBean,- SessionFactory<F>
A 
SessionFactory implementation that caches Sessions for reuse without
 requiring reconnection each time the Session is retrieved from the factory.
 This implementation wraps and delegates to a target SessionFactory instance.- Since:
- 2.0
- Author:
- Josh Long, Oleg Zhurakousky, Mark Fisher, Gary Russell, Alen Turkovic, Artem Bilan, Christian Tzolov
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructorsConstructorDescriptionCachingSessionFactory(SessionFactory<F> sessionFactory) Create a CachingSessionFactory with an unlimited number of sessions.CachingSessionFactory(SessionFactory<F> sessionFactory, int sessionCacheSize) Create a CachingSessionFactory with the specified session limit.
- 
Method SummaryModifier and TypeMethodDescriptionvoiddestroy()Remove (close) any unused sessions in the pool.Get a session from the pool (or block if none available).voidClear the cache of sessions; also any in-use sessions will be closed when returned to the cache.voidsetPoolSize(int poolSize) 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.voidsetSessionWaitTimeout(long sessionWaitTimeout) Sets the limit of how long to wait for a session to become available.voidsetTestSession(boolean testSession) Set to true to test the session when checking one out from the cache.
- 
Constructor Details- 
CachingSessionFactoryCreate a CachingSessionFactory with an unlimited number of sessions.- Parameters:
- sessionFactory- the underlying session factory.
 
- 
CachingSessionFactoryCreate 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.Do not cache a DelegatingSessionFactory, cache each delegate therein instead.- Parameters:
- sessionFactory- The underlying session factory.
- sessionCacheSize- The maximum cache size.
- See Also:
 
 
- 
- 
Method Details- 
setSessionWaitTimeoutpublic void setSessionWaitTimeout(long sessionWaitTimeout) Sets the limit of how long to wait for a session to become available.- Parameters:
- sessionWaitTimeout- the session wait timeout.
- Throws:
- IllegalStateException- if the wait expires prior to a Session becoming available.
 
- 
setPoolSizepublic void setPoolSize(int poolSize) 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.- Parameters:
- poolSize- The pool size.
 
- 
setTestSessionpublic void setTestSession(boolean testSession) Set to true to test the session when checking one out from the cache.- Parameters:
- testSession- true to test.
- Since:
- 5.1
 
- 
getSessionGet a session from the pool (or block if none available).- Specified by:
- getSessionin interface- SessionFactory<F>
 
- 
destroypublic void destroy()Remove (close) any unused sessions in the pool.- Specified by:
- destroyin interface- DisposableBean
 
- 
resetCachepublic void resetCache()Clear the cache of sessions; also any in-use sessions will be closed when returned to the cache.
 
-