Results 1 to 2 of 2

Thread: Dynamic ftp:inbound-channel-adapter

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Default Dynamic ftp:inbound-channel-adapter

    Hi,

    I'm testing a lot these days the spring intergration and I hit a problem.
    I need to connect to 10 FTP servers. FTP server configurations are stored in db (hosts, users, passwords)

    In the config file I have somethig like this:

    Code:
           <bean id="ftpClientFactory"  class="org.springframework.integration.ftp.session.DefaultFtpSessionFactory">
                <property name="host" value="${host}"/>
                <property name="username" value="${user}"/>
    	    <property name="password" value="${password}"/>  	
            </bean>
    
            <ftp:inbound-channel-adapter id="ftpInbound"
                        cache-sessions="false"
                        channel="myChannel"
                        session-factory="ftpClientFactory"
                        filename-pattern="*.xml"
                        auto-create-local-directory="true"
                        delete-remote-files="false"
                        remote-directory="/"
                        local-directory="d:\temp">
            </ftp:inbound-channel-adapter>

    I do not want to declare all 10 adapters and factories in config file, so the only one solution that I've found until now is to do something like:

    Code:
    for (DBConfiguration dbConfiguration:dbConfigurations ) {
    
            ConfigurableApplicationContext applicationContext =
                   new ClassPathXmlApplicationContext(
    					new String[] { "classpath:ftp-adapter.xml" },
    					false);
                setEnvironmentForDBConfiguration(applicationContext, dbConfiguration); //<--- I will not go in details here if not necessary 
                applicationContext.refresh() ;
    }

    There are other solutions to this problem ?
    Thank you

  2. #2
    Join Date
    Oct 2011
    Location
    Mumbai, India
    Posts
    213

    Default

    Have a look at this sample. Let us know if this helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •