Example usage for org.springframework.integration.ftp.session DefaultFtpSessionFactory DefaultFtpSessionFactory

List of usage examples for org.springframework.integration.ftp.session DefaultFtpSessionFactory DefaultFtpSessionFactory

Introduction

In this page you can find the example usage for org.springframework.integration.ftp.session DefaultFtpSessionFactory DefaultFtpSessionFactory.

Prototype

DefaultFtpSessionFactory

Source Link

Usage

From source file:com.apress.prospringintegration.ftp.FtpConfiguration.java

@Bean
public DefaultFtpSessionFactory ftpClientFactory() {
    DefaultFtpSessionFactory ftpSessionFactory = new DefaultFtpSessionFactory();
    ftpSessionFactory.setHost(host);/*from  w  w w . ja v a2  s .c o m*/
    ftpSessionFactory.setUsername(username);
    ftpSessionFactory.setPassword(password);
    ftpSessionFactory.setClientMode(FTPClient.PASSIVE_LOCAL_DATA_CONNECTION_MODE);
    return ftpSessionFactory;
}

From source file:com.github.exper0.efilecopier.ftp.FtpAdapterFactory.java

@Override
public DefaultFtpSessionFactory createSessionFactory(FtpReportSettings settings) {
    DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
    factory.setUsername(settings.getUser());
    factory.setPassword(settings.getPassword());
    factory.setHost(settings.getHost());
    factory.setPort(settings.getPort());
    return factory;
}

From source file:com.github.exper0.efilecopier.ftp.CachedAdapterFactory.java

private AbstractApplicationContext getParent(ReportSettings settings) {
    final String key = String.format("%s:%d", settings.getHost(), settings.getPort());
    AbstractApplicationContext context = parents.get(key);
    if (context == null) {
        context = new GenericApplicationContext();
        DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
        factory.setUsername(settings.getUser());
        factory.setPassword(settings.getPassword());
        factory.setHost(settings.getHost());
        factory.setPort(settings.getPort());
        context.getBeanFactory().registerSingleton(FACTORY_NAME, factory);
        context.refresh();/*from ww  w. j  a v  a  2 s  . co m*/
        parents.put(key, context);
    }
    return context;
}

From source file:com.github.exper0.efilecopier.ftp.DynamicFtpChannelResolver.java

private AbstractApplicationContext getContext(ReportSettings settings) {
    final String key = String.format("%s:%d", settings.getHost(), settings.getPort());
    AbstractApplicationContext context = roots.get(key);
    if (context == null) {
        context = new GenericApplicationContext();
        DefaultFtpSessionFactory factory = new DefaultFtpSessionFactory();
        factory.setUsername(settings.getUser());
        factory.setPassword(settings.getPassword());
        factory.setHost(settings.getHost());
        factory.setPort(settings.getPort());
        context.getBeanFactory().registerSingleton("session.factory", factory);
        context.refresh();/*w w w .j  a  v  a  2 s. c  om*/
    }
    return context;
}

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

@Bean
@ConditionalOnMissingBean/*  ww  w .  j  av  a  2 s.co  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.ftp.FtpTestSupport.java

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

    return new CachingSessionFactory<FTPFile>(sf);
}

From source file:org.springframework.integration.ftp.session.SessionFactoryTests.java

@Test
public void testWithControlEncoding() {
    DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory();
    sessionFactory.setControlEncoding("UTF-8");
    Assert.assertEquals("Expected controlEncoding value of 'UTF-8'", "UTF-8",
            TestUtils.getPropertyValue(sessionFactory, "controlEncoding"));
}

From source file:org.springframework.integration.ftp.session.SessionFactoryTests.java

@Test
public void testWithoutControlEncoding() {
    DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory();
    Assert.assertEquals("Expected controlEncoding value of 'ISO-8859-1'", "ISO-8859-1",
            TestUtils.getPropertyValue(sessionFactory, "controlEncoding"));
}

From source file:org.springframework.integration.ftp.session.SessionFactoryTests.java

@Test(expected = IllegalArgumentException.class)
public void testEmptyControlEncoding() {
    DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory();
    sessionFactory.setControlEncoding("");
}

From source file:org.springframework.integration.ftp.session.SessionFactoryTests.java

@Test(expected = IllegalArgumentException.class)
public void testNullControlEncoding() {
    DefaultFtpSessionFactory sessionFactory = new DefaultFtpSessionFactory();
    sessionFactory.setControlEncoding(null);
}