2.3 platform-mediator¶
Sprint: Sprint 02 - Platform Core Libraries
Feature ID: 2.3
Subtasks: 2.3.1, 2.3.2, 2.3.3
Objective¶
Deliver "platform-mediator" within Sprint 02 - Platform Core Libraries.
Dependencies¶
Aggregated from the subtasks below (prerequisite task IDs and enablers):
- 2.2.1
- 2.3.1
- 2.3.2
- 2.1.2
- 2.1.3
Subtasks¶
2.3.1 Pipeline contracts and ordering¶
- ID: 2.3.1
- Title: Implement RequestHandlerDelegate, PipelineBehavior, PipelineOrder
- Description: In
com.telco.platform.mediator.pipeline: functionalRequestHandlerDelegate<R>;PipelineBehavior(supports,handle, defaultorder());PipelineOrderconstants (VALIDATION 100, AUTHORIZATION 200, LOGGING 300, INBOX 350, TRANSACTION 400, PERFORMANCE 500, DEFAULT 1000; lower = outer). - Business Purpose: Defines the cross-cutting behavior chain order.
- Inputs: PLATFORM-SPEC Section 4.1.
- Outputs: Pipeline contracts and order constants.
- Acceptance Criteria:
- Constants equal the PLATFORM-SPEC values and lower order wraps outer.
- Dependencies: 2.2.1
- Complexity: S
2.3.2 Mediator dispatcher¶
- ID: 2.3.2
- Title: Implement Mediator, HandlerRegistry, InProcessMediator
- Description: In
com.telco.platform.mediator:Mediator(send/query/publish),HandlerRegistry(resolution port, implemented later by the starter),InProcessMediatorthat sorts behaviors ascending byorder(), builds the chain (index 0 outermost), applies only supporting behaviors, then dispatches to the registry handler. Missing command/query handler ->IllegalStateException; events with no handlers are a no-op. Sort viaComparator.comparingInt(PipelineBehavior::order). No Spring. - Business Purpose: Single dispatch point routing all domain operations through behaviors (ARC-03).
- Inputs: PLATFORM-SPEC Section 4.2.
- Outputs:
Mediator,HandlerRegistry,InProcessMediator. - Acceptance Criteria:
- Unit test: behaviors execute in ascending-order nesting; a non-supporting behavior is skipped.
- Missing handler throws
IllegalStateException; publishing an event with no handlers does not throw. - Dependencies: 2.3.1
- Complexity: L
2.3.3 Pipeline behaviors and support ports¶
- ID: 2.3.3
- Title: Implement Validation, Authorization, Logging, Performance, Transaction behaviors
- Description: In
com.telco.platform.mediator.behavior:ValidationBehavior(jakartaValidator, throwsValidationExceptionwith violations);AuthorizationBehavior(CurrentUserProvider, List<AuthorizationRule>);LoggingBehavior(serviceName, List<RequestLogWriter>)skippingNotLoggable;PerformanceBehavior(slowThresholdMs);TransactionBehavior(TransactionRunner)wrapping onlyCommand. Support ports inbehavior.support:TransactionRunner,AuthorizationRule,RequestLogWriter,RequestLogEntry,NotLoggable. ProvideSlf4jRequestLogWriter. - Business Purpose: Cross-cutting validation, authz, logging, timing, and transactionality applied uniformly to every request.
- Inputs: PLATFORM-SPEC Section 4.3.
- Outputs: Behavior classes, support ports,
Slf4jRequestLogWriter. - Acceptance Criteria:
- Validation behavior throws on an invalid bean and passes a valid one.
- Transaction behavior
supportsreturns true only forCommand. - Authorization behavior throws
AccessDeniedException/UnauthenticatedExceptionper the rule. - Dependencies: 2.3.2, 2.1.2, 2.1.3
- Complexity: L
Acceptance Criteria¶
Each subtask above carries its own objective, testable acceptance criteria. This feature is complete when every subtask's acceptance criteria are met.
Deliverables¶
- Pipeline contracts and order constants.
Mediator,HandlerRegistry,InProcessMediator.- Behavior classes, support ports,
Slf4jRequestLogWriter.
Definition of Done¶
- All subtasks (2.3.1, 2.3.2, 2.3.3) completed and their acceptance criteria verified.
- All listed dependencies satisfied.
- Build and tests green per the global conventions in ../README.md (Section 3).