0
我想在Apache Camel中添加一個自定義sftp組件,以將用戶名,主機,端口和密碼包裹在要傳遞給sftpcomponent的配置對象中。apache camel:使用sftp組件定製sftp配置
下面是我曾嘗試代碼:
@Configuration
class SftpConfig {
@Bean("sourceSftp")
public SftpComponent getSourceSftpComponent(
@Qualifier("sftpConfig")
SftpConfiguration sftpConfig) throws Exception{
SftpComponent sftpComponent = new SftpComponent();
// not getting way to set the configuration
return sftpComponent;
}
@Bean("sftpConfig")
public SftpConfiguration getSftpConfig(
@Value("${host}") String host,
@Value("${port}") int port,
@Value("${applicationUserName}") String applicationUserName,
@Value("${password}") String password) {
SftpConfiguration sftpConfiguration = new SftpConfiguration();
sftpConfiguration.setHost(host);
sftpConfiguration.setPort(port);
sftpConfiguration.setUsername(applicationUserName);
sftpConfiguration.setPassword(password);
return sftpConfiguration;
}
}
//在其他類
from("sourceSftp:<path of directory>") ---custom component
在JMSComponent類似的方法工作,我已經創建了一個sourcejms豆很好,但我由於SftpComponent沒有爲sftp配置設置調用,因此無法爲sftp執行此操作。
謝謝。我會嘗試。 – griffin