Example usage for org.springframework.integration.file.remote.session CachingSessionFactory CachingSessionFactory

List of usage examples for org.springframework.integration.file.remote.session CachingSessionFactory CachingSessionFactory

Introduction

In this page you can find the example usage for org.springframework.integration.file.remote.session CachingSessionFactory CachingSessionFactory.

Prototype

public CachingSessionFactory(SessionFactory<F> sessionFactory) 

Source Link

Document

Create a CachingSessionFactory with an unlimited number of sessions.

Usage

From source file:org.springframework.cloud.stream.app.ftp.FtpSessionFactoryConfiguration.java

@Bean
@ConditionalOnMissingBean/*from   ww w . j  av  a2 s  . c o m*/
public SessionFactory<FTPFile> ftpSessionFactory(FtpSessionFactoryProperties properties) {
    DefaultFtpSessionFactory ftpSessionFactory = new DefaultFtpSessionFactory();
    ftpSessionFactory.setHost(properties.getHost());
    ftpSessionFactory.setPort(properties.getPort());
    ftpSessionFactory.setUsername(properties.getUsername());
    ftpSessionFactory.setPassword(properties.getPassword());
    ftpSessionFactory.setClientMode(properties.getClientMode().getMode());
    if (properties.getCacheSessions() != null) {
        CachingSessionFactory<FTPFile> csf = new CachingSessionFactory<>(ftpSessionFactory);
        return csf;
    } else {
        return ftpSessionFactory;
    }
}

From source file:org.springframework.integration.file.remote.session.SessionFactoryFactoryBean.java

public SessionFactoryFactoryBean(SessionFactory<T> sessionFactory, boolean cacheSessions) {
    if (logger.isWarnEnabled()) {
        logger.warn("Do not use this factory bean; " + "instantiate the session factory directly; "
                + "if cached sessions are required, wrap it in a CachingSessionFactory.");
    }//  w w w.j a va 2  s  .  c  o  m
    if (cacheSessions && !(sessionFactory instanceof CachingSessionFactory)) {
        this.sessionFactory = new CachingSessionFactory<T>(sessionFactory);
    } else {
        this.sessionFactory = sessionFactory;
    }
}

From source file:org.springframework.integration.ftp.FtpTestSupport.java

public static SessionFactory<FTPFile> sessionFactory() {
    DefaultFtpSessionFactory sf = new DefaultFtpSessionFactory();
    sf.setHost("localhost");
    sf.setPort(port);// w w  w . j  ava  2 s. co m
    sf.setUsername("foo");
    sf.setPassword("foo");

    return new CachingSessionFactory<FTPFile>(sf);
}

From source file:org.springframework.integration.ftp.TestFtpServer.java

@Bean
public SessionFactory<FTPFile> ftpSessionFactory() {
    DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
    factory.setHost("localhost");
    factory.setPort(this.ftpPort);
    factory.setUsername("foo");
    factory.setPassword("foo");

    return new CachingSessionFactory<FTPFile>(factory);
}