From c8922c58f5581660059f0c2c5cd132a1d83e574c Mon Sep 17 00:00:00 2001 From: David Turanski Date: Thu, 15 Aug 2019 14:35:52 -0400 Subject: [PATCH 1/2] Implement RotatingServerAdvice enhancements --- .../file/remote/aop/RotatingServerAdvice.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java index d08bf28de3d..1b71438bed0 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java @@ -171,7 +171,7 @@ protected boolean isFair() { return this.fair; } - protected KeyDirectory getCurrent() { + public KeyDirectory getCurrent() { return this.current; } @@ -201,18 +201,18 @@ public void afterReceive(boolean messageReceived, MessageSource source) { } protected void configureSource(MessageSource source) { - Assert.isTrue(source instanceof AbstractInboundFileSynchronizingMessageSource - || source instanceof AbstractRemoteFileStreamingMessageSource, - "source must be an AbstractInboundFileSynchronizingMessageSource or a " - + "AbstractRemoteFileStreamingMessageSource"); if (!this.iterator.hasNext()) { this.iterator = this.keyDirectories.iterator(); } this.current = this.iterator.next(); + onRotation(source); + } + + protected void onRotation(MessageSource source) { if (source instanceof AbstractRemoteFileStreamingMessageSource) { ((AbstractRemoteFileStreamingMessageSource) source).setRemoteDirectory(this.current.getDirectory()); } - else { + else if (source instanceof AbstractInboundFileSynchronizingMessageSource) { ((AbstractInboundFileSynchronizingMessageSource) source).getSynchronizer() .setRemoteDirectory(this.current.getDirectory()); } From 7cbcc468d8dad7af39bf49f8bb70be7f723a677d Mon Sep 17 00:00:00 2001 From: David Turanski Date: Mon, 19 Aug 2019 11:15:50 -0400 Subject: [PATCH 2/2] Update javadocs --- .../file/remote/aop/RotatingServerAdvice.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java index 1b71438bed0..34ceb11d8ab 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/aop/RotatingServerAdvice.java @@ -208,6 +208,15 @@ protected void configureSource(MessageSource source) { 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) { if (source instanceof AbstractRemoteFileStreamingMessageSource) { ((AbstractRemoteFileStreamingMessageSource) source).setRemoteDirectory(this.current.getDirectory());