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

org.infinispan.jcache.embedded.JCacheWriterAdapter Maven / Gradle / Ivy

package org.infinispan.jcache.embedded;

import javax.cache.integration.CacheWriter;

import org.infinispan.jcache.Exceptions;
import org.infinispan.jcache.JCacheEntry;
import org.infinispan.marshall.core.MarshalledEntry;
import org.infinispan.persistence.spi.InitializationContext;

public class JCacheWriterAdapter implements org.infinispan.persistence.spi.CacheWriter {

   private CacheWriter delegate;

   public JCacheWriterAdapter() {
      // Empty constructor required so that it can be instantiated with
      // reflection. This is a limitation of the way the current cache
      // loader configuration works.
   }

   public void setCacheWriter(CacheWriter delegate) {
      this.delegate = delegate;
   }

   @Override
   public void init(InitializationContext ctx) {
   }

   @Override
   public void write(MarshalledEntry entry) {
      try {
         delegate.write(new JCacheEntry(entry.getKey(), entry.getValue()));
      } catch (Exception e) {
         throw Exceptions.launderCacheWriterException(e);
      }
   }

   @Override
   public boolean delete(Object key) {
      try {
         delegate.delete(key);
      } catch (Exception e) {
         throw Exceptions.launderCacheWriterException(e);
      }
      return false;
   }

   @Override
   public void start() {
   }

   @Override
   public void stop() {
   }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy