Delegating Session Factory

版本 4.2 引入了 DelegatingSessionFactory,它允许在运行时选择实际会话工厂。在调用 FTP 端点之前,对工厂调用 setThreadKey() 以将密钥与当前线程关联。然后使用该密钥查找要使用的实际会话工厂。使用后,可以通过调用 clearThreadKey() 清除密钥。

Version 4.2 introduced the DelegatingSessionFactory, which allows the selection of the actual session factory at runtime. Prior to invoking the FTP endpoint, call setThreadKey() on the factory to associate a key with the current thread. That key is then used to look up the actual session factory to be used. You can clear the key by calling clearThreadKey() after use.

有关如何将此工厂与 `ContextHolderRequestHandlerAdvice`结合使用的更多信息,请参见 Context Holder Advice

See Context Holder Advice for more information how this factory can be used together with a ContextHolderRequestHandlerAdvice.

当您使用会话缓存(请参阅 FTP Session Caching)时,每个委托都应该被缓存。您不能缓存 DelegatingSessionFactory 本身。

When you use session caching (see FTP Session Caching), each of the delegates should be cached. You cannot cache the DelegatingSessionFactory itself.

从 5.0.7 版本开始,`DelegatingSessionFactory`可以与 `RotatingServerAdvice`结合使用来轮询多个服务器;请参见 Inbound Channel Adapters: Polling Multiple Servers and Directories

Starting with version 5.0.7, the DelegatingSessionFactory can be used in conjunction with a RotatingServerAdvice to poll multiple servers; see Inbound Channel Adapters: Polling Multiple Servers and Directories.