From 16f1c5beebd0ed6f58e22bada6c088cb7f8b1db7 Mon Sep 17 00:00:00 2001 From: forge-bot Date: Sat, 18 Jul 2026 11:07:04 +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 --- .../framework/TxServiceRegistry.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxServiceRegistry.java diff --git a/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxServiceRegistry.java b/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxServiceRegistry.java new file mode 100644 index 0000000..7708f4a --- /dev/null +++ b/boot/common-framework/src/main/java/com/klaro/acquirecore/framework/TxServiceRegistry.java @@ -0,0 +1,57 @@ +package com.klaro.acquirecore.framework; + +import org.springframework.stereotype.Service; +import jakarta.annotation.PostConstruct; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Service registry for transaction-aware services. + * Migrated from txcore.c TX_SERVICE registry functionality. + * Replaces C function pointers and registry with Spring @Service DI. + */ +@Service +public class TxServiceRegistry { + + private final Map services = new ConcurrentHashMap<>(); + + @PostConstruct + public void initialize() {} + + public void registerService(String name, TxService service) { + services.put(name, service); + } + + public void unregisterService(String name) { + services.remove(name); + } + + public TxService getService(String name) { + return services.get(name); + } + + public boolean hasService(String name) { + return services.containsKey(name); + } + + public TxResult executeInTransaction(String serviceName, TxOperation operation) { + TxService service = services.get(serviceName); + if (service == null) { + return TxResult.failure("SERVICE_NOT_FOUND", "Service not registered: " + serviceName); + } + return service.execute(operation); + } + + public String[] getRegisteredServiceNames() { + return services.keySet().toArray(new String[0]); + } + + public void clear() { + services.clear(); + } + + @FunctionalInterface + public interface TxOperation { + T execute(TxContext context); + } +}