@Override
public Object apply(ProceedingJoinPoint joinPoint, Compensable compensable, CompensableInterceptor interceptor,
OmegaContext context, String parentTxId, int retries) throws Throwable {
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
LOG.debug("Intercepting compensable method {} with context {}", method.toString(), context);
String compensationSignature =
compensable.compensationMethod().isEmpty() ? "" : compensationMethodSignature(joinPoint, compensable, method);
String retrySignature = (retries != 0 || compensationSignature.isEmpty()) ? method.toString() : "";
AlphaResponse response = interceptor.preIntercept(parentTxId, compensationSignature, compensable.timeout(),
retrySignature, retries, joinPoint.getArgs());
if (response.aborted()) {
String abortedLocalTxId = context.localTxId();
context.setLocalTxId(parentTxId);
throw new InvalidTransactionException("Abort sub transaction " + abortedLocalTxId +
" because global transaction " + context.globalTxId() + " has already aborted.");
}
try {
Object result = joinPoint.proceed();
interceptor.postIntercept(parentTxId, compensationSignature);
return result;
} catch (Throwable throwable) {
interceptor.onError(parentTxId, compensationSignature, throwable);
throw throwable;
}
}