diff --git a/clearing-parent/swt-exporter/src/main/java/ru/spcex/clearing/swt/exporter/config/SFTPConfig.java b/clearing-parent/swt-exporter/src/main/java/ru/spcex/clearing/swt/exporter/config/SFTPConfig.java index 2e49d1e39..c22344859 100644 --- a/clearing-parent/swt-exporter/src/main/java/ru/spcex/clearing/swt/exporter/config/SFTPConfig.java +++ b/clearing-parent/swt-exporter/src/main/java/ru/spcex/clearing/swt/exporter/config/SFTPConfig.java @@ -33,14 +33,9 @@ import ru.spcex.clearing.swt.exporter.config.settings.ExportSwtServiceSettings; @ConditionalOnProperty(value="export-swt-service.sftp-out.sftp-out-dir") public class SFTPConfig { protected Logger log = LoggerFactory.getLogger(getClass()); - private final ExportSwtServiceSettings settings; - - public SFTPConfig(ExportSwtServiceSettings settings) { - this.settings = settings; - } @Bean("sftpSessionFactory") - public SessionFactory sftpSessionFactory() { + public SessionFactory sftpSessionFactory(ExportSwtServiceSettings settings) { DefaultSftpSessionFactory factory = new DefaultSftpSessionFactory(true); factory.setHost(settings.getSftpOut().getServerIp()); factory.setPort(settings.getSftpOut().getServerPort()); @@ -52,7 +47,8 @@ public class SFTPConfig { @Bean("sftpHandler") @ServiceActivator(inputChannel = "toSftpChannel") - public MessageHandler handler(@Qualifier("sftpSessionFactory") SessionFactory sessionFactory) { + public MessageHandler handler(@Qualifier("sftpSessionFactory") SessionFactory sessionFactory, + ExportSwtServiceSettings settings) { SftpMessageHandler handler = new SftpMessageHandler(sessionFactory); handler.setRemoteDirectoryExpression(new LiteralExpression(settings.getSftpOut().getSftpOutDir())); log.info("Configure sftp output directory \"{}\"", settings.getSftpOut().getSftpOutDir()); @@ -69,7 +65,8 @@ public class SFTPConfig { @Bean("sftpHandlerList") @ServiceActivator(inputChannel = "listSftpChannel") - public MessageHandler handlerList(@Qualifier("sftpSessionFactory") SessionFactory sessionFactory) { + public MessageHandler handlerList(@Qualifier("sftpSessionFactory") SessionFactory sessionFactory, + ExportSwtServiceSettings settings) { String expression = "'/%s'".formatted(settings.getSftpOut().getSftpOutDir()); return new SftpOutboundGateway(sessionFactory, LS.getCommand(), expression); }