From e27ae734ce86af48ecb674f8f41d6580794f125c Mon Sep 17 00:00:00 2001 From: forge-bot Date: Sat, 18 Jul 2026 10:10:47 +0000 Subject: [PATCH] =?UTF-8?q?[framework]=20TxCore=20=E2=86=92=20common-frame?= =?UTF-8?q?work=20(ACM-FW-001)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../klaro/acquirecore/framework/TxCore.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxCore.java diff --git a/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxCore.java b/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxCore.java new file mode 100644 index 0000000..9ef868d --- /dev/null +++ b/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxCore.java @@ -0,0 +1,57 @@ +package com.klaro.acquirecore.framework; + +import org.springframework.stereotype.Component; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.function.Supplier; + +/** + * TxCore main entry point. Migrated from txcore.h/txcore.c. + * Provides centralized transaction management facade. + */ +@Component +public class TxCore { + + private final TxServiceRegistry registry; + private final TxTemplate template; + + @Autowired + public TxCore(TxServiceRegistry registry, TxTemplate template) { + this.registry = registry; + this.template = template; + } + + public TxServiceRegistry getRegistry() { return registry; } + public TxTemplate getTemplate() { return template; } + + public TxResult executeTransaction(String serviceName, Supplier action) { + return template.execute(serviceName, action); + } + + public TxResult executeTransaction(String serviceName, TxConfig config, Supplier action) { + return template.execute(serviceName, config, action); + } + + public void registerService(String serviceName, TxServiceRegistry.TxServiceHandler handler) { + registry.registerService(serviceName, handler); + } + + public void registerService(String serviceName, TxServiceRegistry.TxServiceHandler handler, TxConfig config) { + registry.registerService(serviceName, handler, config); + } + + public boolean hasService(String serviceName) { + return registry.hasService(serviceName); + } + + public TxContext beginTransaction(String serviceName) { + return template.begin(serviceName); + } + + public TxResult commitTransaction(TxContext context) { + return template.commit(context); + } + + public TxResult rollbackTransaction(TxContext context, String reason) { + return template.rollback(context, reason); + } +}