feat: dispatch NamedAction and NamedCondition by key

Hosts register one bean per action/condition; Spring wires the dispatcher when no facade is defined, and REST catalog projects from those beans.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
0264408
2026-09-20 11:07:57 +08:00
co-authored by Cursor
parent e4e2c6ed9b
commit d743939964
16 changed files with 570 additions and 26 deletions
@@ -3,7 +3,8 @@ package com.jetlumen.ordo.api;
/**
* Executes a named action step against the running instance. Hosts supply a
* singleton implementation (same pattern as {@link RoutingCondition}); the database only stores
* the {@code actionKey} string.
* the {@code actionKey} string. Prefer {@link NamedAction} beans; Spring wires a dispatcher
* when this facade is not defined.
*/
@FunctionalInterface
public interface ActionHandler {
@@ -0,0 +1,26 @@
package com.jetlumen.ordo.api;
import java.util.List;
/**
* A single ACTION implementation keyed by {@link #key()}, matching {@code action} on the step
* (and {@code due.then.notify} keys). Spring collects these beans into a dispatching
* {@link ActionHandler} when the host does not define that facade itself.
*/
public interface NamedAction {
String key();
void execute(ProcessRuntime runtime);
default String label() {
return key();
}
default List<OrdoCatalog.Param> params() {
return List.of();
}
default OrdoCatalog.Item catalogItem() {
return new OrdoCatalog.Item(key(), label(), params());
}
}
@@ -0,0 +1,27 @@
package com.jetlumen.ordo.api;
import java.util.List;
import java.util.Map;
/**
* A single routing condition keyed by {@link #key()}, matching {@code when.ref}. Spring collects
* these beans into a dispatching {@link RoutingCondition} when the host does not define that
* facade itself.
*/
public interface NamedCondition {
String key();
boolean matches(Map<String, Object> args, ProcessRuntime runtime);
default String label() {
return key();
}
default List<OrdoCatalog.Param> params() {
return List.of();
}
default OrdoCatalog.Item catalogItem() {
return new OrdoCatalog.Item(key(), label(), params());
}
}
@@ -5,7 +5,8 @@ import java.util.Map;
/**
* Evaluates a named routing condition ({@code when.ref}) against the running instance.
* Hosts supply a singleton implementation (same pattern as {@link AssigneeResolver}); the
* definition stores the {@code ref} key and optional {@code args}.
* definition stores the {@code ref} key and optional {@code args}. Prefer {@link NamedCondition}
* beans; Spring wires a dispatcher when this facade is not defined.
*/
@FunctionalInterface
public interface RoutingCondition {