Apply changes from 5.1 for StandardRotationPolicy
Related to https://github.com/spring-projects/spring-integration/issues/3027 * Remove `Assert.isTrue()` from the `onRotation()` to make the behavior as void in case of non-standard `MessageSource` provided * Add JavaDocs into `onRotation()` to describe the behavior and possibility to override
This commit is contained in:
@@ -133,18 +133,21 @@ public class StandardRotationPolicy implements RotationPolicy {
|
||||
onRotation(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the state of the {@link MessageSource} after the server is rotated, if necessary.
|
||||
* The default implementation updates the remote directory for known MessageSource implementations that require it,
|
||||
* specifically, instances of {@link AbstractRemoteFileStreamingMessageSource}, and
|
||||
* {@link AbstractInboundFileSynchronizingMessageSource}, and does nothing otherwise.
|
||||
* Subclasses may override this method to support other MessageSource types.
|
||||
* @param source the MessageSource.
|
||||
*/
|
||||
protected void onRotation(MessageSource<?> source) {
|
||||
Assert.isTrue(source instanceof AbstractInboundFileSynchronizingMessageSource
|
||||
|| source instanceof AbstractRemoteFileStreamingMessageSource,
|
||||
"source must be an AbstractInboundFileSynchronizingMessageSource or a "
|
||||
+ "AbstractRemoteFileStreamingMessageSource");
|
||||
|
||||
if (source instanceof AbstractRemoteFileStreamingMessageSource) {
|
||||
((AbstractRemoteFileStreamingMessageSource<?>) source).setRemoteDirectory(getCurrent().getDirectory());
|
||||
((AbstractRemoteFileStreamingMessageSource<?>) source).setRemoteDirectory(this.current.getDirectory());
|
||||
}
|
||||
else {
|
||||
else if (source instanceof AbstractInboundFileSynchronizingMessageSource) {
|
||||
((AbstractInboundFileSynchronizingMessageSource<?>) source).getSynchronizer()
|
||||
.setRemoteDirectory(getCurrent().getDirectory());
|
||||
.setRemoteDirectory(this.current.getDirectory());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user