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

org.infinispan.cdi.embedded.ContextInputCache Maven / Gradle / Ivy

There is a newer version: 9.1.7.Final
Show newest version
package org.infinispan.cdi.embedded;

import java.util.Collection;

import org.infinispan.Cache;
import org.infinispan.distexec.DistributedExecutorService;

/**
 * ContextInputCache keeps track of {@link Input} cache to be injected into Callables from
 * {@link DistributedExecutorService} using CDI
 * mechanism. The cache injected will be the cache used to construct
 * {@link DistributedExecutorService}
 *
 * @author Vladimir Blagoejvic
 * @since 5.2
 * @see InfinispanExtensionEmbedded#registerInputCacheCustomBean(javax.enterprise.inject.spi.AfterBeanDiscovery,
 *      javax.enterprise.inject.spi.BeanManager)
 *
 */
public class ContextInputCache {

   /*
    * Using thread local was the last choice. See https://issues.jboss.org/browse/ISPN-2181 for more
    * details and design decisions made
    */
   private static ThreadLocal> contextualCache = new ThreadLocal>();
   private static ThreadLocal> contextualKeys = new ThreadLocal<>();

   public static  void set(Cache input) {
      contextualCache.set(input);
   }

   @SuppressWarnings("unchecked")
   public static  Cache get() {
      return (Cache) contextualCache.get();
   }

   public static  void setKeys(Collection inputKeys) {
      contextualKeys.set(inputKeys);
   }

   public static  Collection getKeys(){
      return (Collection) contextualKeys.get();
   }

   public static void clean() {
      contextualCache.remove();
      contextualKeys.remove();
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy