Search in sources :

Example 1 with CacheInvalidateMultiRequest

use of org.adempiere.ad.dao.cache.CacheInvalidateMultiRequest 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;
}
Also used : ITrx(org.adempiere.ad.trx.api.ITrx) CacheInvalidateMultiRequest(org.adempiere.ad.dao.cache.CacheInvalidateMultiRequest) ITrxManager(org.adempiere.ad.trx.api.ITrxManager)

Aggregations

CacheInvalidateMultiRequest (org.adempiere.ad.dao.cache.CacheInvalidateMultiRequest)1 ITrx (org.adempiere.ad.trx.api.ITrx)1 ITrxManager (org.adempiere.ad.trx.api.ITrxManager)1