Flow

当您使用 Flow Components 根据涉及多个组件的使用构建某些内容时,您的实现可能变得有点混乱。为了简化这些用例,我们添加了一个 ComponentFlow ,它可以将多个组件执行一起挂接,作为 “flow” 。

以下列表展示了流程及其在 shell 中的输出示例:

link:../../../../../src/test/java/org/springframework/shell/docs/FlowComponentSnippets.java[role=include]
link:example$component-flow-showcase-1.cast[role=include]

组件的正常执行顺序与使用构建器定义的相同。你可以有条件地选择在一个流程中跳到何处,方法是使用 next 函数并返回目标 component id。如果此返回 ID 等于 null 或不存在,那么流程基本上就会在此处停止。

link:../../../../../src/test/java/org/springframework/shell/docs/FlowComponentSnippets.java[role=include]
link:example$component-flow-conditional-1.cast[role=include]

运行流的结果返回 ComponentFlowResult,你可以用它来执行进一步的操作。