[framework] TxCore → common-framework (ACM-FW-001)
This commit is contained in:
parent
b73958739e
commit
2de2967932
1 changed files with 48 additions and 0 deletions
|
|
@ -0,0 +1,48 @@
|
|||
package com.klaro.acquirecore.framework;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Default implementation of TxService.
|
||||
* Provides base transaction service functionality.
|
||||
*/
|
||||
@Service
|
||||
public class DefaultTxService implements TxService {
|
||||
|
||||
private final String serviceName;
|
||||
private final TxTemplate txTemplate;
|
||||
|
||||
public DefaultTxService() {
|
||||
this("default");
|
||||
}
|
||||
|
||||
public DefaultTxService(String serviceName) {
|
||||
this.serviceName = serviceName;
|
||||
this.txTemplate = new TxTemplate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceName() {
|
||||
return serviceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TxResult<T> execute(TxServiceRegistry.TxOperation<T> operation) {
|
||||
return txTemplate.execute(serviceName, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TxContext beginTransaction() {
|
||||
return txTemplate.txBegin(serviceName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TxResult<Void> commit(TxContext context) {
|
||||
return txTemplate.txCommit(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TxResult<Void> rollback(TxContext context, String reason) {
|
||||
return txTemplate.txRollback(context, reason);
|
||||
}
|
||||
}
|
||||
Reference in a new issue