use of org.adempiere.ad.trx.api.ITrxManager in project metasfresh-webui-api by metasfresh.
the class DocumentCacheInvalidationDispatcher method reset.
@Override
public int reset(@NonNull final CacheInvalidateMultiRequest request) {
final ITrxManager trxManager = Services.get(ITrxManager.class);
final ITrx currentTrx = trxManager.getThreadInheritedTrx(OnTrxMissingPolicy.ReturnTrxNone);
if (trxManager.isNull(currentTrx)) {
async.execute(() -> resetNow(request));
} else {
final CacheInvalidateMultiRequestsCollector collector = currentTrx.getProperty(TRXPROP_Requests, trx -> {
final CacheInvalidateMultiRequestsCollector c = new CacheInvalidateMultiRequestsCollector();
trx.getTrxListenerManager().newEventListener(TrxEventTiming.AFTER_COMMIT).registerHandlingMethod(innerTrx -> {
final CacheInvalidateMultiRequest aggregatedRequest = c.aggregateOrNull();
if (aggregatedRequest == null) {
return;
}
async.execute(() -> resetNow(aggregatedRequest));
});
return c;
});
collector.add(request);
}
// not relevant
return 1;
}
Aggregations