INT-1614 naming changes for synchronizers and the interface's strategy method itself

This commit is contained in:
Mark Fisher
2010-11-19 12:01:39 -05:00
parent abffa7378a
commit d9ebf2657e
10 changed files with 85 additions and 42 deletions

View File

@@ -29,8 +29,8 @@ import org.apache.commons.net.ftp.FTPFile;
import org.springframework.core.io.Resource;
import org.springframework.integration.MessagingException;
import org.springframework.integration.file.synchronizer.AbstractInboundRemoteFileSystemSychronizer;
import org.springframework.integration.file.synchronizer.AbstractInboundRemoteFileSystemSynchronizingMessageSource;
import org.springframework.integration.file.synchronizer.AbstractInboundFileSynchronizer;
import org.springframework.integration.file.synchronizer.AbstractInboundFileSynchronizingMessageSource;
import org.springframework.integration.ftp.client.FtpClientPool;
import org.springframework.util.Assert;
@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
* @author Iwein Fuld
* @author Josh Long
*/
public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemoteFileSystemSychronizer<FTPFile> {
public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundFileSynchronizer<FTPFile> {
private volatile FtpClientPool clientPool;
@@ -54,15 +54,14 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
this.clientPool = clientPool;
}
public void afterPropertiesSet() throws Exception {
public void afterPropertiesSet() {
Assert.notNull(this.clientPool, "clientPool must not be null");
if (this.shouldDeleteSourceFile) {
this.setEntryAcknowledgmentStrategy(new DeletionEntryAcknowledgmentStrategy());
}
}
@Override
protected void syncRemoteToLocalFileSystem(Resource localDirectory) {
public void synchronizeToLocalDirectory(Resource localDirectory) {
try {
FTPClient client = this.clientPool.getClient();
Assert.state(client != null,
@@ -93,7 +92,7 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
String localFileName = localDirectory.getFile().getPath() + "/" + remoteFileName;
File localFile = new File(localFileName);
if (!localFile.exists()) {
String tempFileName = localFileName + AbstractInboundRemoteFileSystemSynchronizingMessageSource.INCOMPLETE_EXTENSION;
String tempFileName = localFileName + AbstractInboundFileSynchronizingMessageSource.INCOMPLETE_EXTENSION;
File file = new File(tempFileName);
FileOutputStream fos = new FileOutputStream(file);
try {
@@ -122,7 +121,7 @@ public class FtpInboundRemoteFileSystemSynchronizer extends AbstractInboundRemot
/**
* An acknowledgment strategy that deletes the file.
*/
private static class DeletionEntryAcknowledgmentStrategy implements AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<FTPFile> {
private static class DeletionEntryAcknowledgmentStrategy implements EntryAcknowledgmentStrategy<FTPFile> {
private final Log logger = LogFactory.getLog(this.getClass());

View File

@@ -18,7 +18,8 @@ package org.springframework.integration.ftp.inbound;
import org.apache.commons.net.ftp.FTPFile;
import org.springframework.integration.file.synchronizer.AbstractInboundRemoteFileSystemSynchronizingMessageSource;
import org.springframework.integration.file.synchronizer.AbstractInboundFileSynchronizer;
import org.springframework.integration.file.synchronizer.AbstractInboundFileSynchronizingMessageSource;
import org.springframework.integration.ftp.client.FtpClientPool;
/**
@@ -27,8 +28,7 @@ import org.springframework.integration.ftp.client.FtpClientPool;
* @author Iwein Fuld
* @author Josh Long
*/
public class FtpInboundRemoteFileSystemSynchronizingMessageSource
extends AbstractInboundRemoteFileSystemSynchronizingMessageSource<FTPFile, FtpInboundRemoteFileSystemSynchronizer> {
public class FtpInboundRemoteFileSystemSynchronizingMessageSource extends AbstractInboundFileSynchronizingMessageSource<FTPFile> {
private volatile FtpClientPool clientPool;
@@ -41,10 +41,17 @@ public class FtpInboundRemoteFileSystemSynchronizingMessageSource
return "ftp:inbound-channel-adapter";
}
@Override
public void setSynchronizer(AbstractInboundFileSynchronizer<FTPFile> synchronizer) {
super.setSynchronizer(synchronizer);
}
@Override
protected void onInit() {
super.onInit();
this.synchronizer.setClientPool(this.clientPool);
if (this.synchronizer instanceof FtpInboundRemoteFileSystemSynchronizer) {
((FtpInboundRemoteFileSystemSynchronizer) this.synchronizer).setClientPool(this.clientPool);
}
}
}

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.ftp.inbound;
import static org.mockito.Mockito.mock;
@@ -71,7 +72,7 @@ public class FtpInboundRemoteFileSystemSynchronizerTest {
syncronizer.afterPropertiesSet();
Resource localDirectory = new FileSystemResource(System.getProperty("java.io.tmpdir"));
syncronizer.syncRemoteToLocalFileSystem(localDirectory);
syncronizer.synchronizeToLocalDirectory(localDirectory);
verify(ftpClient, times(1)).retrieveFile(Mockito.anyString(), Mockito.any(OutputStream.class));
verify(ftpClient, times(1)).deleteFile(Mockito.anyString());