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

org.infinispan.spring.provider.SpringRemoteCacheManager Maven / Gradle / Ivy

package org.infinispan.spring.provider;

import java.util.Collection;

import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.springframework.util.Assert;

/**
 * 

* A {@link org.springframework.cache.CacheManager CacheManager} implementation that is * backed by an {@link org.infinispan.client.hotrod.RemoteCacheManager * Infinispan RemoteCacheManager} instance. *

* * @author Olaf Bergner * @author Marius Bogoevici * */ public class SpringRemoteCacheManager implements org.springframework.cache.CacheManager { private final RemoteCacheManager nativeCacheManager; private volatile long readTimeout; private volatile long writeTimeout; /** * @param nativeCacheManager the underlying cache manager */ public SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager, long readTimeout, long writeTimeout) { Assert.notNull(nativeCacheManager, "A non-null instance of EmbeddedCacheManager needs to be supplied"); this.nativeCacheManager = nativeCacheManager; this.readTimeout = readTimeout; this.writeTimeout = writeTimeout; } public SpringRemoteCacheManager(final RemoteCacheManager nativeCacheManager) { this(nativeCacheManager, 0, 0); } /** * @see org.springframework.cache.CacheManager#getCache(java.lang.String) */ @Override public SpringCache getCache(final String name) { RemoteCache nativeCache = this.nativeCacheManager.getCache(name); return new SpringCache(nativeCache, readTimeout, writeTimeout); } /** * @see org.springframework.cache.CacheManager#getCacheNames() */ @Override public Collection getCacheNames() { return this.nativeCacheManager.getCacheNames(); } /** * Return the {@link org.infinispan.client.hotrod.RemoteCacheManager * org.infinispan.client.hotrod.RemoteCacheManager} that backs this * SpringRemoteCacheManager. * * @return The {@link org.infinispan.client.hotrod.RemoteCacheManager * org.infinispan.client.hotrod.RemoteCacheManager} that backs this * SpringRemoteCacheManager */ public RemoteCacheManager getNativeCacheManager() { return this.nativeCacheManager; } public long getReadTimeout() { return this.readTimeout; } public long getWriteTimeout() { return this.writeTimeout; } public void setReadTimeout(final long readTimeout) { this.readTimeout = readTimeout; } public void setWriteTimeout(final long writeTimeout) { this.writeTimeout = writeTimeout; } /** * Start the {@link org.infinispan.client.hotrod.RemoteCacheManager * org.infinispan.client.hotrod.RemoteCacheManager} that backs this * SpringRemoteCacheManager. */ public void start() { this.nativeCacheManager.start(); } /** * Stop the {@link org.infinispan.client.hotrod.RemoteCacheManager * org.infinispan.client.hotrod.RemoteCacheManager} that backs this * SpringRemoteCacheManager. */ public void stop() { this.nativeCacheManager.stop(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy