Search in sources :

Example 1 with FtpClientFactory

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;
}
Also used : FtpClientFactory(com.chao.cloud.common.extra.ftp.pool.FtpClientFactory) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) FtpClientProxy(com.chao.cloud.common.extra.ftp.pool.FtpClientProxy) FileOperationImpl(com.chao.cloud.common.extra.ftp.impl.FileOperationImpl) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) FtpClientPool(com.chao.cloud.common.extra.ftp.pool.FtpClientPool) InitializingBean(org.springframework.beans.factory.InitializingBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

FileOperationImpl (com.chao.cloud.common.extra.ftp.impl.FileOperationImpl)1 FtpClientFactory (com.chao.cloud.common.extra.ftp.pool.FtpClientFactory)1 FtpClientPool (com.chao.cloud.common.extra.ftp.pool.FtpClientPool)1 FtpClientProxy (com.chao.cloud.common.extra.ftp.pool.FtpClientProxy)1 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)1 GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 Bean (org.springframework.context.annotation.Bean)1