[framework] TxCore → common-framework (ACM-FW-001)
This commit is contained in:
parent
b7f229f023
commit
84e415aeba
1 changed files with 36 additions and 18 deletions
|
|
@ -1,31 +1,49 @@
|
||||||
package com.klaro.acquirecore.framework;
|
package com.klaro.acquirecore.framework;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.io.Serializable;
|
||||||
import java.util.Map;
|
import java.time.Instant;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 레거시 TxCore {@code TXBUF} (고정 슬롯 키/값 버퍼) 의 Spring 대체 자리표시자.
|
* Transaction context DTO - represents the state of a transaction.
|
||||||
*
|
* Migrated from txcore.h TX_CONTEXT.
|
||||||
* <p>실 전환에서는 요청/응답 DTO(record) 가 정형 필드를 담고, 이 컨텍스트는
|
|
||||||
* 서비스 체인({@code tx_call}) 간 전달되는 느슨한 키/값 상태만 보관한다.
|
|
||||||
*/
|
*/
|
||||||
public final class TxContext {
|
public class TxContext implements Serializable {
|
||||||
|
|
||||||
private final Map<String, Object> slots = new HashMap<>();
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** TXBUF 필드 설정 (레거시 {@code Fchg} 상당). */
|
private String transactionId;
|
||||||
public TxContext put(String key, Object value) {
|
private TransactionStatus status;
|
||||||
slots.put(key, value);
|
private Instant startedAt;
|
||||||
return this;
|
private Instant committedAt;
|
||||||
|
private String serviceName;
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
public TxContext() {
|
||||||
|
this.transactionId = UUID.randomUUID().toString();
|
||||||
|
this.status = TransactionStatus.INITIALIZED;
|
||||||
|
this.startedAt = Instant.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TXBUF 필드 조회 (레거시 {@code Fget} 상당). */
|
public TxContext(String serviceName) {
|
||||||
public Object get(String key) {
|
this();
|
||||||
return slots.get(key);
|
this.serviceName = serviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 적재된 슬롯 개수. */
|
public String getTransactionId() { return transactionId; }
|
||||||
public int size() {
|
public void setTransactionId(String transactionId) { this.transactionId = transactionId; }
|
||||||
return slots.size();
|
public TransactionStatus getStatus() { return status; }
|
||||||
|
public void setStatus(TransactionStatus status) { this.status = status; }
|
||||||
|
public Instant getStartedAt() { return startedAt; }
|
||||||
|
public void setStartedAt(Instant startedAt) { this.startedAt = startedAt; }
|
||||||
|
public Instant getCommittedAt() { return committedAt; }
|
||||||
|
public void setCommittedAt(Instant committedAt) { this.committedAt = committedAt; }
|
||||||
|
public String getServiceName() { return serviceName; }
|
||||||
|
public void setServiceName(String serviceName) { this.serviceName = serviceName; }
|
||||||
|
public String getErrorMessage() { return errorMessage; }
|
||||||
|
public void setErrorMessage(String errorMessage) { this.errorMessage = errorMessage; }
|
||||||
|
|
||||||
|
public enum TransactionStatus {
|
||||||
|
INITIALIZED, ACTIVE, COMMITTED, ROLLED_BACK, FAILED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue