Class DefaultFlowDefinitionService

java.lang.Object
cloud.opencode.base.flow.internal.DefaultFlowDefinitionService
All Implemented Interfaces:
FlowDefinitionService

public final class DefaultFlowDefinitionService extends Object implements FlowDefinitionService
Default FlowDefinitionService backed by the supplied FlowRepository, DslParser, and DslValidator. 默认 FlowDefinitionService 实现。
Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Constructor Details

    • DefaultFlowDefinitionService

      public DefaultFlowDefinitionService(FlowRepository repo)
      Construct the service with default DSL parser / validator. 使用默认 DSL parser / validator 构造服务。
      Parameters:
      repo - persistence facade — 持久化门面
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • DefaultFlowDefinitionService

      public DefaultFlowDefinitionService(FlowRepository repo, DslParser parser, DslValidator validator, cloud.opencode.base.flow.internal.IdProvider idProvider)
      Test-friendly constructor. 测试友好构造器。
      Parameters:
      repo - persistence facade — 持久化门面
      parser - DSL parser — DSL 解析器
      validator - DSL validator — DSL 校验器
      idProvider - id provider — id 提供者
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Method Details

    • deploy

      public FlowDefinition deploy(String dslJson)
      Description copied from interface: FlowDefinitionService
      Deploy a new flow definition from the given JSON DSL. Allocates an id (snowflake) and persists it as ACTIVE. 部署新的流程定义(从 JSON DSL)。分配 id(snowflake)并以 ACTIVE 持久化。
      Specified by:
      deploy in interface FlowDefinitionService
      Parameters:
      dslJson - DSL JSON string — DSL JSON 串
      Returns:
      persisted definition — 已持久化的定义
    • findActive

      public Optional<FlowDefinition> findActive(String flowKey)
      Description copied from interface: FlowDefinitionService
      Returns the currently active definition for the given business key. 返回业务 key 当前 ACTIVE 的定义。
      Specified by:
      findActive in interface FlowDefinitionService
      Parameters:
      flowKey - business key — 业务 key
      Returns:
      active definition (Optional) — 当前定义(Optional)
    • listVersions

      public List<FlowDefinition> listVersions(String flowKey)
      Description copied from interface: FlowDefinitionService
      Lists every version of the given business key (asc by version). 列出业务 key 的所有版本(按 version 升序)。
      Specified by:
      listVersions in interface FlowDefinitionService
      Parameters:
      flowKey - business key — 业务 key
      Returns:
      all versions — 全部版本
    • deprecate

      public void deprecate(String flowKey, int version)
      Deprecate a specific (flowKey, version) definition. 弃用指定 (flowKey, version) 的定义。

      R1 S-3 (closed as design tweak): when no definition matches the given (flowKey, version), this method throws FlowErrorCode.DEF_DEPRECATED. The semantics is "the requested definition is not in a usable state" — closest available code to "definition not found" without expanding the 23-code catalogue locked in v4 §7.2.

      R1 S-3 决策:找不到指定 (flowKey, version) 时抛 FlowErrorCode.DEF_DEPRECATED。错误码总数仍保持 v4 §7.2 锁定的 23 项, 不新增 DEF_NOT_FOUND;该码语义最接近"定义不可用"。

      Specified by:
      deprecate in interface FlowDefinitionService
      Parameters:
      flowKey - business key — 业务 key
      version - definition version — 定义版本号
      Since:
      JDK 25, opencode-base-flow V1.0.5