All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.infinispan.iteration.impl.TransactionAwareCloseableIterable Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.iteration.impl;

import org.infinispan.Cache;
import org.infinispan.commons.util.CloseableIterable;
import org.infinispan.commons.util.CloseableIterator;
import org.infinispan.container.entries.CacheEntry;
import org.infinispan.context.impl.TxInvocationContext;
import org.infinispan.filter.Converter;
import org.infinispan.filter.KeyValueFilter;
import org.infinispan.transaction.impl.LocalTransaction;

/**
 * CloseableIterable implementation that will enhance another CloseableIterable to use the provided context values in the
 * iteration process properly.  That is context values will take precendence over values found from the iterator.
 *
 * @author wburns
 * @since 7.0
 */
public class TransactionAwareCloseableIterable implements CloseableIterable> {
   protected final CloseableIterable>  iterable;
   protected final TxInvocationContext ctx;
   protected final Cache cache;
   protected final KeyValueFilter filter;
   protected final Converter converter;

   public TransactionAwareCloseableIterable(CloseableIterable> iterable, 
         KeyValueFilter filter,
         Converter converter,
         TxInvocationContext ctx, Cache cache) {
      this.iterable = iterable;
      this.ctx = ctx;
      this.cache = cache;
      this.filter = filter;
      this.converter = converter;
   }

   @Override
   public void close() {
      iterable.close();
   }

   @Override
   public CloseableIterator> iterator() {
      return new TransactionAwareCloseableIterator(iterable.iterator(), filter, converter,
            ctx, cache);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy