简体   繁体   English

简单工作流程的设计模式

[英]Design pattern for simple workflow

I am developing a java standalone application/framework. 我正在开发一个Java独立应用程序/框架。 The application generates report based on data from database once a day, it's scheduled to run daily. 该应用程序每天根据数据库中的数据生成一次报告,并计划每天运行。 The application has to be generic to support different reports. 该应用程序必须通用才能支持不同的报告。 After some research I figured to store the meta data for each report in database. 经过一些研究,我发现将每个报告的元数据存储在数据库中。 For eg report name, enabled, sql query which returns data for the report etc. 例如,报告名称,已启用,SQL查询(返回报告数据)等。

Each schedule job is associated with specify report (report id). 每个计划作业都与指定报告(报告ID)相关联。

So briefly the workflow is Scheduled Job runs > Retrieves the meta data for specific report > Runs the sql query > FTP the report file > Email the report > End 因此,简要地说,工作流是“计划作业运行”>“检索特定报告的元数据”>“运行sql查询”>“ FTP报告文件”>“通过电子邮件发送报告”>“结束”

There might be more steps added. 可能添加了更多步骤。 And also depending on the step it might not need to successfully complete. 而且,根据步骤的不同,它可能不需要成功完成。 For eg if the FTP fails, the flow should continue. 例如,如果FTP失败,则流程应继续。

The current class which drives the flow is ReportService, which retrieves meta data, use FTP class and then Email class. 当前驱动流的类是ReportService,它检索元数据,使用FTP类,然后使用Email类。

Since I want to make the framework extensible, the user can extend the ReportService class and transform the data retrieved, calls some other business service before continue with usual flow (ftp>email). 由于我想使框架具有可扩展性,因此用户可以扩展ReportService类并转换检索到的数据,然后再调用其他业务服务,然后再继续进行常规流程(ftp> email)。

I am looking fo design patterns which will help me making the framework generic and easily extensible, specifically pattern to implement workflow in which if one of the steps fails, depending on the step the flow should terminate or continue. 我正在寻找设计模式,这将帮助我使框架通用且易于扩展,特别是用于实现工作流的模式,在该模式中,如果步骤之一失败,则取决于流程应终止还是继续进行。

Take a look at Decorator or Chain of Responsibility or Publish/Subscribe . 看一下装饰器责任链发布/订阅 All these patterns allow you to link together behaviours. 所有这些模式使您可以将行为联系在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM