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

This commit is contained in:
forge-bot 2026-07-18 10:10:41 +00:00
parent 43be2fff98
commit a31101b71a

View file

@ -1,31 +1,53 @@
package com.klaro.acquirecore.framework;
import java.util.HashMap;
import java.util.Map;
import java.util.HashMap;
/**
* 레거시 TxCore {@code TXBUF} (고정 슬롯 / 버퍼) Spring 대체 자리표시자.
*
* <p> 전환에서는 요청/응답 DTO(record) 정형 필드를 담고, 컨텍스트는
* 서비스 체인({@code tx_call}) 전달되는 느슨한 / 상태만 보관한다.
* Transaction context DTO holding state for a single transaction lifecycle.
* Migrated from txcore.h tx_context_t struct.
*/
public final class TxContext {
public class TxContext {
private final Map<String, Object> slots = new HashMap<>();
/** TXBUF 필드 설정 (레거시 {@code Fchg} 상당). */
public TxContext put(String key, Object value) {
slots.put(key, value);
return this;
/** Transaction state enumeration. Migrated from txcore.h tx_state_t. */
public enum TxState {
IDLE, PENDING, ACTIVE, COMMITTED, ROLLED_BACK, FAILED
}
/** TXBUF 필드 조회 (레거시 {@code Fget} 상당). */
public Object get(String key) {
return slots.get(key);
private String txId;
private String serviceName;
private TxState state;
private long startTime;
private long endTime;
private Map<String, Object> attributes;
private String errorMessage;
public TxContext() {
this.attributes = new HashMap<>();
this.state = TxState.IDLE;
}
/** 적재된 슬롯 개수. */
public int size() {
return slots.size();
public TxContext(String txId, String serviceName) {
this();
this.txId = txId;
this.serviceName = serviceName;
}
public String getTxId() { return txId; }
public void setTxId(String txId) { this.txId = txId; }
public String getServiceName() { return serviceName; }
public void setServiceName(String serviceName) { this.serviceName = serviceName; }
public TxState getState() { return state; }
public void setState(TxState state) { this.state = state; }
public long getStartTime() { return startTime; }
public void setStartTime(long startTime) { this.startTime = startTime; }
public long getEndTime() { return endTime; }
public void setEndTime(long endTime) { this.endTime = endTime; }
public Map<String, Object> getAttributes() { return attributes; }
public void setAttributes(Map<String, Object> attributes) { this.attributes = attributes; }
public Object getAttribute(String key) { return attributes.get(key); }
public void setAttribute(String key, Object value) { attributes.put(key, value); }
public String getErrorMessage() { return errorMessage; }
public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
public boolean isActive() { return state == TxState.ACTIVE || state == TxState.PENDING; }
}