use of com.chao.cloud.common.extra.ftp.pool.FtpClientFactory in project chao-cloud by chaojunzi.
the class FtpConfig method fileOperation.
@Bean
public IFileOperation fileOperation(FtpConfig ftpConfig) {
GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
poolConfig.setBlockWhenExhausted(ftpConfig.blockWhenExhausted);
poolConfig.setMaxWaitMillis(ftpConfig.maxWaitMillis);
poolConfig.setMinIdle(ftpConfig.minIdle);
poolConfig.setMaxIdle(ftpConfig.maxIdle);
poolConfig.setMaxTotal(ftpConfig.maxTotal);
poolConfig.setTestOnBorrow(ftpConfig.testOnBorrow);
poolConfig.setTestOnReturn(ftpConfig.testOnReturn);
poolConfig.setTestOnCreate(ftpConfig.testOnCreate);
poolConfig.setTestWhileIdle(ftpConfig.testWhileIdle);
poolConfig.setLifo(ftpConfig.lifo);
// 注入对象
FtpClientFactory factory = new FtpClientFactory(ftpConfig);
FtpClientPool ftpClientPool = new FtpClientPool(new GenericObjectPool(factory, poolConfig));
FtpClientProxy ftpClientProxy = new FtpClientProxy(ftpClientPool);
FileOperationImpl operation = new FileOperationImpl();
operation.setFtpConfig(ftpConfig);
operation.setFtpClientProxy(ftpClientProxy);
return operation;
}
Aggregations