[framework] TxCore → common-framework (ACM-FW-001)

This commit is contained in:
forge-bot 2026-07-18 10:10:47 +00:00
parent 2ead4f104a
commit e27ae734ce

View file

@ -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<Object> action) {
return template.execute(serviceName, action);
}
public TxResult executeTransaction(String serviceName, TxConfig config, Supplier<Object> 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);
}
}