快捷搜索: 王者荣耀 脱发

webMethods之Developer (2)

我们继续讲webMethods Developer。本文主要讲的是Developer的Flow Service。

Flow Service的功能类似于一般的函数。但是,这个函数是用webMethods自创的Flow语言写的。(其实与其说写,还不如说“画”的)。看doc里的定义: A flow service is a service that is written in the webMethods flow language. 另外,每个Flow Service都有输入输出。

Flow Service是由Flow Step构成的。我们可以将flow step想象为函数的一条(或者多条语句)。doc:A flow step is a basic unit of work. 本文主要讲的就是不同类型的flow step。

了解了上面的两个概念,我们还需要知道Pipeline的含义。 在我看来,Pipeline很像JSP里的Servlet Context,它存放着可以被整个系统使用的数据。我们看doc:The pipeline is the general term used to refer to the data structure in which input and output values are maintained for a flow service. It allows services in the flow to share data. When a service in the flow executes, it has access to all data in the pipeline at that point. (SHARE)

接下来是有关flow step的内容。flow step 分为BRANCH,SEQUENCE,REPEAT,LOOP,EXIT,MAP六种。这六种其实只不过是对一般编程语言的赋值、流程控制等的重新定义而已。

BRANCH是分支结构的意思,它与Java里的switch类似。而有趣的是,用来确定BRANCH走向的参数名恰好就是在switch中定义的. (而子选择参数是以Label确定的)

SEQUENCE是顺序结构的意思。它的意义在于它可以将多个flow step封装成一个来看待。并且,在其内部可以定义运行到何时结束,比如until failure, until success, until done等。

REPEAT是重复,它可以指定重复次数。

LOOP的意义在于它极大方便了对数组的枚举。

EXIT是退出的意思,它可以选择退出到程序的那一层。

MAP是赋值的作用,它有一个叫transformer的东西,可以在赋值前完成一些处理。

以上就是对Flow Language的简单介绍,上面的各种step都是通过拖拽图标实现的,而不是手工code。这是好是坏,也没什么好说的。不过pipeline的作用,是需要在实践中逐步体会的。

经验分享 程序员 微信小程序 职场和发展