FIle传输系统的设计模式 [英] Design pattern for FIle transfer system

查看:65
本文介绍了FIle传输系统的设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将文件从异构源(例如:FTP,SSH,SSHW)传输到目标(可以再次使用FTP,SSH,SSHW ..等)。



我已确定了实施此步骤的步骤;

1.从源代码获取所有文件名

2 。重命名文件

3.下载文件

4.转换文件

5.上传到目的地

6。从源代码删除



在大多数情况下,我必须执行所有6个步骤。但在某些情况下,我只能使用其中一些步骤。简而言之,我将有上述步骤的不同组合。我将在DB或xml中的某处配置这些组合。



例如:

case1:step 1,2,3,4,5, 6

case2:步骤1,2,4



我正在寻找合适的设计来实现这一点。



我试图使用责任链。以为我会采取专家建议。



感谢您的输入。

解决方案

第一件事就是mind是一个XML配置文件,类似于以下内容。



 < ;  任务 >  
< 任务 id = 1 >
< step1 > true < / step1 >
< step2 > true < / step2 >
< step3 > true < / step3 >
< step4 > true < / step4 >
< step5 > true < / step5 >
< step6 > true < / step6 >
< span class =code-keyword>< / task >
< 任务 id = 2 >
< step1 > true < / step1 >
< st ep2 > true < / step2 >
< step3 > true < / step3 >
< step4 > true < / step4 >
< step5 > true < / step5 >
&l t; step6 > false < / step6 >
< / task >
< / tasks >


I have a requirement to transfer files from heterogeneous sources (eg: FTP,SSH,SSHW) to destinations (can be again FTP,SSH,SSHW..etc).

I have identified the steps to implemenent this;
1. Get All File names from source
2. Rename files
3. Download Files
4. Transform Files
5. Upload to destination
6. Delete from source

In most cases, I have to execute all the 6 steps. But in some cases I have to use only some of these steps. In short, I will have different combinations of above steps. I will configure these combinations somewhere in DB or xml.

eg:
case1: step 1 ,2,3,4,5,6
case2: step 1,2,4

I am looking for proper design to implement this.

I tried to use Chain of responsibility. Thought I will take expert advise.

Appreciate your input.

解决方案

The first thing that comes to mind is an XML configuration file, something along the lines of the following.

<tasks>
    <task id="1">
        <step1>true</step1>
        <step2>true</step2>
        <step3>true</step3>
        <step4>true</step4>
        <step5>true</step5>
        <step6>true</step6>
    </task>
    <task id="2">
        <step1>true</step1>
        <step2>true</step2>
        <step3>true</step3>
        <step4>true</step4>
        <step5>true</step5>
        <step6>false</step6>
    </task>
</tasks>


这篇关于FIle传输系统的设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆