[framework] TxCore → common-framework (ACM-FW-001)
This commit is contained in:
parent
43be2fff98
commit
a31101b71a
1 changed files with 40 additions and 18 deletions
|
|
@ -1,31 +1,53 @@
|
||||||
package com.klaro.acquirecore.framework;
|
package com.klaro.acquirecore.framework;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 레거시 TxCore {@code TXBUF} (고정 슬롯 키/값 버퍼) 의 Spring 대체 자리표시자.
|
* Transaction context DTO holding state for a single transaction lifecycle.
|
||||||
*
|
* Migrated from txcore.h tx_context_t struct.
|
||||||
* <p>실 전환에서는 요청/응답 DTO(record) 가 정형 필드를 담고, 이 컨텍스트는
|
|
||||||
* 서비스 체인({@code tx_call}) 간 전달되는 느슨한 키/값 상태만 보관한다.
|
|
||||||
*/
|
*/
|
||||||
public final class TxContext {
|
public class TxContext {
|
||||||
|
|
||||||
private final Map<String, Object> slots = new HashMap<>();
|
/** Transaction state enumeration. Migrated from txcore.h tx_state_t. */
|
||||||
|
public enum TxState {
|
||||||
/** TXBUF 필드 설정 (레거시 {@code Fchg} 상당). */
|
IDLE, PENDING, ACTIVE, COMMITTED, ROLLED_BACK, FAILED
|
||||||
public TxContext put(String key, Object value) {
|
|
||||||
slots.put(key, value);
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** TXBUF 필드 조회 (레거시 {@code Fget} 상당). */
|
private String txId;
|
||||||
public Object get(String key) {
|
private String serviceName;
|
||||||
return slots.get(key);
|
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 TxContext(String txId, String serviceName) {
|
||||||
public int size() {
|
this();
|
||||||
return slots.size();
|
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; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue