Class DefaultFlowInstanceService
java.lang.Object
cloud.opencode.base.flow.internal.DefaultFlowInstanceService
- All Implemented Interfaces:
FlowInstanceService
Default
FlowInstanceService implementation.
默认 FlowInstanceService 实现。
R3 SEC P0-2 / P0-5: when a non-no-op CurrentUserProvider is
wired, terminate / get / findByInitiator enforce that the caller is the
instance initiator (or admin). CurrentUserProvider.NO_OP reverts
to the legacy permissive behaviour for backward compatibility.
R3 SEC P0-2 / P0-5:装配真实 CurrentUserProvider 时引擎对
terminate/get/findByInitiator 强制按发起人鉴权;NO_OP 退化为兼容模式。
- Since:
- JDK 25, opencode-base-flow V1.0.5
- Author:
- Leon Soo
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider) Test-friendly constructor.DefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider, FlowMetrics metrics) Test-friendly constructor with explicitFlowMetrics.DefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider, FlowMetrics metrics, CurrentUserProvider currentUser) Full test-friendly constructor including authn SPI.DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator) Convenience constructor that wires a no-opFlowMetrics.DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator, FlowMetrics metrics) Convenience constructor with an explicitFlowMetrics.DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator, FlowMetrics metrics, CurrentUserProvider currentUser) Full convenience constructor including authn SPI. -
Method Summary
Modifier and TypeMethodDescriptionfindByInitiator(String userId, int page, int size) Paginated list of instances started by the given user.Returns the instance by id (or throws INST_NOT_FOUND).Start a new instance for the given business key.voidTerminate the running instance (out-of-band).
-
Constructor Details
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator) Convenience constructor that wires a no-opFlowMetrics. 便利构造器:默认使用 no-opFlowMetrics。- Parameters:
repo- persistence facade — 持久化门面assigneeResolver- assignee resolver SPI — 参与者解析 SPIexprEvaluator- optional expression evaluator — 可选表达式 SPI- Since:
- JDK 25, opencode-base-flow V1.0.5
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator, FlowMetrics metrics) Convenience constructor with an explicitFlowMetrics. 便利构造器:显式注入FlowMetrics。- Parameters:
repo- persistence facade — 持久化门面assigneeResolver- assignee resolver SPI — 参与者解析 SPIexprEvaluator- optional expression evaluator SPI — 可选表达式 SPImetrics- metrics sink — 指标接收器- Since:
- JDK 25, opencode-base-flow V1.0.5
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, AssigneeResolver assigneeResolver, ExpressionEvaluator exprEvaluator, FlowMetrics metrics, CurrentUserProvider currentUser) Full convenience constructor including authn SPI. 完整便利构造器(含认证 SPI)。- Parameters:
repo- persistence facade — 持久化门面assigneeResolver- assignee resolver SPI — 参与者解析 SPIexprEvaluator- optional expression evaluator SPI — 可选表达式 SPImetrics- metrics sink — 指标接收器currentUser- current-user SPI — 当前用户 SPI- Since:
- JDK 25, opencode-base-flow V1.0.5
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider) Test-friendly constructor. 测试友好构造器。- Parameters:
repo- persistence facade — 持久化门面stepEntry- step entry helper — 节点进入工具history- history writer — 历史追加器idProvider- id provider — id 提供者- Since:
- JDK 25, opencode-base-flow V1.0.5
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider, FlowMetrics metrics) Test-friendly constructor with explicitFlowMetrics. 测试友好构造器:显式注入FlowMetrics。- Parameters:
repo- persistence facade — 持久化门面stepEntry- step entry helper — 节点进入工具history- history writer — 历史追加器idProvider- id provider — id 提供者metrics- metrics sink — 指标接收器- Since:
- JDK 25, opencode-base-flow V1.0.5
-
DefaultFlowInstanceService
public DefaultFlowInstanceService(FlowRepository repo, StepEntry stepEntry, HistoryWriter history, cloud.opencode.base.flow.internal.IdProvider idProvider, FlowMetrics metrics, CurrentUserProvider currentUser) Full test-friendly constructor including authn SPI. 完整测试构造器(含认证 SPI)。- Parameters:
repo- persistence facade — 持久化门面stepEntry- step entry helper — 节点进入工具history- history writer — 历史追加器idProvider- id provider — id 提供者metrics- metrics sink — 指标接收器currentUser- current-user SPI — 当前用户 SPI- Since:
- JDK 25, opencode-base-flow V1.0.5
-
-
Method Details
-
start
Description copied from interface:FlowInstanceServiceStart a new instance for the given business key. 启动一个新实例。- Specified by:
startin interfaceFlowInstanceService- Parameters:
flowKey- business key — 业务 keyinitiatorId- initiator user id — 发起人variables- business variables (nullable) — 业务变量(可空)- Returns:
- persisted instance — 已持久化实例
-
get
Description copied from interface:FlowInstanceServiceReturns the instance by id (or throws INST_NOT_FOUND). 按 id 返回实例(不存在抛 INST_NOT_FOUND)。- Specified by:
getin interfaceFlowInstanceService- Parameters:
instanceId- instance id — 实例 ID- Returns:
- instance — 实例
-
findByInitiator
Description copied from interface:FlowInstanceServicePaginated list of instances started by the given user. 分页查询某发起人启动的实例。- Specified by:
findByInitiatorin interfaceFlowInstanceService- Parameters:
userId- initiator user id — 发起人page- zero-based page — 页码(0 起)size- page size — 每页大小- Returns:
- instances on the requested page — 该页实例
-
terminate
Description copied from interface:FlowInstanceServiceTerminate the running instance (out-of-band). Cancels every PENDING task; writes a history record. 终止运行中的实例(外部操作)。取消所有 PENDING task;写一条 history。- Specified by:
terminatein interfaceFlowInstanceService- Parameters:
instanceId- instance id — 实例 IDoperatorId- operator user id — 操作人reason- reason (nullable) — 理由
-