GH-246 Deprecate SmbCfg.replaceFile & useTempFile

Fixes https://github.com/spring-projects/spring-integration-extensions/issues/246

The `replaceFile` & `useTempFile` options are not `SmbSession` responsibility.
The `FileTransferringMessageHandler` covers a functionality of `replace` and `tmFile`.

* Implement an `SmbMessageHandler` to hide a `replaceFile` setting on the `SmbSessionFactory`
to retain backward compatibility
* Mention an `SmbMessageHandler` in the README

Updates after further unit testing
Updated for initial PR review requested changes
removed comment to satisfy PR review
Updated to satisfy PR review requests for changes
More updates after further PR review
Updated again based on PR review comments
* Suppress deprecations in the tests for these deprecated options
* Add `package-info.java` to `outbound`
* Delegate from one ctor to another in the `SmbMessageHandler`
This commit is contained in:
Gregory Bragg
2022-04-29 16:07:02 -04:00
committed by Artem Bilan
parent 3bd896caed
commit 9ef8e04ead
14 changed files with 112 additions and 32 deletions

View File

@@ -13,12 +13,11 @@ This module adds Spring Integration support for [Server Message Block][] (SMB).
## Using Maven
Put the following block into pom.xml if using Maven:
Put the following block into pom.xml if using Maven, set the `<version>` tag to the desired release:
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-smb</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
## Changes
@@ -30,6 +29,11 @@ Put the following block into pom.xml if using Maven:
##### Version 1.2
* Ability to set the SMB min/max versions in the `SmbSessionFactory` via configuration in the JCIFS library
* Ability to use a custom implementation of the `jcifs.CIFSContext` interface in the `SmbSessionFactory`
##### Version 1.2.2
* Updated to use the latest version of the [JCIFS](https://github.com/codelibs/jcifs) library
* Added implementation for `SmbMessageHandler`
* Deprecated legacy `replaceFile` and `useTempFile` flags in `SmbConfig`
## Overview
@@ -48,15 +52,14 @@ For XML configuration the `<int-smb:inbound-channel-adapter>` component is provi
### SMB Outbound Channel Adapter
There is no (yet) some SMB specific requirements for files transferring to SMB, so for XML `<int-smb:outbound-channel-adapter>` component we simply reuse an existing `FileTransferringMessageHandler`.
In case of Java configuration that `FileTransferringMessageHandler` should be supplied with the `SmbSessionFactory` (or `SmbRemoteFileTemplate`).
For writing files to a SMB share, and for XML `<int-smb:outbound-channel-adapter>` component we use the `SmbMessageHandler`.
In case of Java configuration a `SmbMessageHandler` should be supplied with the `SmbSessionFactory` (or `SmbRemoteFileTemplate`).
````java
@ServiceActivator(inputChannel = "storeToSmb")
@Bean
@ServiceActivator(inputChannel = "storeToSmbShare")
public MessageHandler smbMessageHandler(SmbSessionFactory smbSessionFactory) {
FileTransferringMessageHandler<SmbFile> handler =
new FileTransferringMessageHandler<>(smbSessionFactory);
SmbMessageHandler handler = new SmbMessageHandler(smbSessionFactory);
handler.setRemoteDirectoryExpression(
new LiteralExpression("remote-target-dir"));
handler.setFileNameGenerator(m ->