sftp - Spring Integration: Get rid of code duplication for setting up beans -


for sftp client project, using spring integration. have different clients , have connect different sftp servers, but, of logic same, have abstracted them out abstractsftpendpoint. each client-specific class implements getclientid(), used abstractsftpendpoint client-specific details sftp credentials.

however, entire logic same clients, still having implement specific classes each client. because need separate "messagesource" each client.

how can rid of duplication?

public class sftpendpointforclientaaaa extends abstractsftpendpoint {      public string getclientid(){        return "clientaaaa";     }      @bean(name = "channelforclientaaaa")     public queuechannel inputfilechannel() {         return super.inputfilechannel();     }      @serviceactivator(inputchannel = "channelforclientaaaa", poller = @poller(fixeddelay = "500"))     public void serviceactivator(message message) {         super.serviceactivator(message);     }      @bean(name = "messagesourceforclientaaaa")     @inboundchanneladapter(value = "channelforclientaaaa",             poller = @poller(fixeddelay = "50", maxmessagesperpoll = "2"))     public messagesource messagesource() {         return super.messagesource();     } } 

basically have bunch of sftp hosts connect , apply same logic. want done automatically without having implement class each sftp host.

see the dynamic ftp sample. uses xml same techniques apply java configuration. uses outbound adapters; inbound little more complicated because might need hook them common context. there links in readme how that.

however, answered similar question multiple imap mail adapters using java configuration , follow-up question.

you should able use technique used there.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -