@Override public String getValueType() { return cache.getConfiguration(CompleteConfiguration.class).getValueType().getName(); }
@Override public String getValueType() { return cache.getConfiguration(CompleteConfiguration.class).getValueType().getName(); }
@Override public String getValueType() { return configuration().getValueType().getName(); }
@Override public <K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType, Class<V> valueType) { checkNotClosed(); if (cacheName == null) { throw new NullPointerException(); } if (keyType == null) { throw new NullPointerException(); } if (valueType == null) { throw new NullPointerException(); } JCache<?, ?> cache = caches.get(cacheName); if (cache == null) { return null; } if (!keyType.isAssignableFrom(cache.getConfiguration(CompleteConfiguration.class).getKeyType())) { throw new ClassCastException("Wrong type of key for " + cacheName); } if (!valueType.isAssignableFrom(cache.getConfiguration(CompleteConfiguration.class).getValueType())) { throw new ClassCastException("Wrong type of value for " + cacheName); } return (Cache<K, V>) cache; }
@Override public <K, V> Cache<K, V> getCache(String cacheName, Class<K> keyType, Class<V> valueType) { checkNotClosed(); if (cacheName == null) { throw new NullPointerException(); } if (keyType == null) { throw new NullPointerException(); } if (valueType == null) { throw new NullPointerException(); } JCache<?, ?> cache = caches.get(cacheName); if (cache == null) { return null; } if (!keyType.isAssignableFrom(cache.getConfiguration(CompleteConfiguration.class).getKeyType())) { throw new ClassCastException("Wrong type of key for " + cacheName); } if (!valueType.isAssignableFrom(cache.getConfiguration(CompleteConfiguration.class).getValueType())) { throw new ClassCastException("Wrong type of value for " + cacheName); } return (Cache<K, V>) cache; }
@Override public <K, V> Cache<K, V> getCache(String cacheName) { checkNotClosed(); Cache<K, V> cache = (Cache<K, V>) getCache(cacheName, Object.class, Object.class); if (cache != null) { if (cache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class) { throw new IllegalArgumentException("Wrong type of key for " + cacheName); } if (cache.getConfiguration(CompleteConfiguration.class).getValueType() != Object.class) { throw new IllegalArgumentException("Wrong type of value for " + cacheName); } } return cache; }
@Override public <K, V> Cache<K, V> getCache(String cacheName) { checkNotClosed(); Cache<K, V> cache = (Cache<K, V>) getCache(cacheName, Object.class, Object.class); if (cache != null) { if (cache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class) { throw new IllegalArgumentException("Wrong type of key for " + cacheName); } if (cache.getConfiguration(CompleteConfiguration.class).getValueType() != Object.class) { throw new IllegalArgumentException("Wrong type of value for " + cacheName); } } return cache; }
/** * Constructs a {@link MutableConfiguration} based on another * {@link CompleteConfiguration}. * * @param configuration the {@link CompleteConfiguration} */ public MutableConfiguration(CompleteConfiguration<K, V> configuration) { this.keyType = configuration.getKeyType(); this.valueType = configuration.getValueType(); listenerConfigurations = new HashSet<CacheEntryListenerConfiguration<K, V>>(); for (CacheEntryListenerConfiguration<K, V> definition : configuration .getCacheEntryListenerConfigurations()) { addCacheEntryListenerConfiguration(definition); } this.cacheLoaderFactory = configuration.getCacheLoaderFactory(); this.cacheWriterFactory = configuration.getCacheWriterFactory(); if (configuration.getExpiryPolicyFactory() == null) { this.expiryPolicyFactory = EternalExpiryPolicy.factoryOf(); } else { this.expiryPolicyFactory = configuration.getExpiryPolicyFactory(); } this.isReadThrough = configuration.isReadThrough(); this.isWriteThrough = configuration.isWriteThrough(); this.isStatisticsEnabled = configuration.isStatisticsEnabled(); this.isStoreByValue = configuration.isStoreByValue(); this.isManagementEnabled = configuration.isManagementEnabled(); }
@Override public Class<T> getValueType() { return cc.getValueType(); }
@Override public String getValueType() { return cache.getConfiguration(CompleteConfiguration.class).getValueType().getName(); }
@Override public String getValueType() { return configuration().getValueType().getName(); }
/** * <p>Constructor for JCacheEntryEventAdapter.</p> * * @param source a {@link JCache} object. * @param element a {@link net.sf.ehcache.Element} object. * @param eventType type */ public JCacheEntryEventAdapter(JCache<K, V> source, Element element, final EventType eventType) { super(source, eventType); this.element = element; final CompleteConfiguration<K, V> cfg = source.getConfiguration(CompleteConfiguration.class); this.keyType = cfg.getKeyType(); this.valueType = cfg.getValueType(); }
/** * <p>Constructor for JCacheEntryEventAdapter.</p> * * @param source a {@link JCache} object. * @param element a {@link net.sf.ehcache.Element} object. * @param eventType type */ public JCacheEntryEventAdapter(JCache<K, V> source, Element element, final EventType eventType) { super(source, eventType); this.element = element; final CompleteConfiguration<K, V> cfg = source.getConfiguration(CompleteConfiguration.class); this.keyType = cfg.getKeyType(); this.valueType = cfg.getValueType(); }
@Override public <K, V> Cache<K, V> getCache(final String cacheName) { final JCache<K, V> jCache = allCaches.get(cacheName); if(jCache == null) { refreshAllCaches(); return allCaches.get(cacheName); } if(jCache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class || jCache.getConfiguration(CompleteConfiguration.class).getValueType() != Object.class) { throw new IllegalArgumentException(); } return jCache; }
@Override public <K, V> Cache<K, V> getCache(final String cacheName) { final JCache<K, V> jCache = allCaches.get(cacheName); if(jCache == null) { refreshAllCaches(); return allCaches.get(cacheName); } if(jCache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class || jCache.getConfiguration(CompleteConfiguration.class).getValueType() != Object.class) { throw new IllegalArgumentException(); } return jCache; }
@Override public <K, V> Cache<K, V> getCache(String cacheName) { checkNotClosed(); Cache<K, V> cache = (Cache<K, V>) getCache(cacheName, Object.class, Object.class); if (cache != null) { if (cache.getConfiguration(CompleteConfiguration.class).getKeyType() != Object.class) { throw new IllegalArgumentException("Wrong type of key for " + cacheName); } if (cache.getConfiguration(CompleteConfiguration.class).getValueType() != Object.class) { throw new IllegalArgumentException("Wrong type of value for " + cacheName); } } return cache; }
public AbstractCacheConfig(CompleteConfiguration<K, V> configuration) { setKeyType(configuration.getKeyType()); setValueType(configuration.getValueType()); this.listenerConfigurations = createConcurrentSet(); for (CacheEntryListenerConfiguration<K, V> listenerConf : configuration.getCacheEntryListenerConfigurations()) { listenerConfigurations.add(DeferredValue.withValue(listenerConf)); } this.cacheLoaderFactory = DeferredValue.withValue(configuration.getCacheLoaderFactory()); this.cacheWriterFactory = DeferredValue.withValue(configuration.getCacheWriterFactory()); Factory<ExpiryPolicy> factory = configuration.getExpiryPolicyFactory(); factory = (factory == null) ? EternalExpiryPolicy.factoryOf() : factory; this.expiryPolicyFactory = DeferredValue.withValue(factory); this.isReadThrough = configuration.isReadThrough(); this.isWriteThrough = configuration.isWriteThrough(); this.isStatisticsEnabled = configuration.isStatisticsEnabled(); this.isStoreByValue = configuration.isStoreByValue(); this.isManagementEnabled = configuration.isManagementEnabled(); }
public AbstractCacheConfig(CompleteConfiguration<K, V> configuration) { setKeyType(configuration.getKeyType()); setValueType(configuration.getValueType()); this.listenerConfigurations = createConcurrentSet(); for (CacheEntryListenerConfiguration<K, V> listenerConf : configuration.getCacheEntryListenerConfigurations()) { listenerConfigurations.add(DeferredValue.withValue(listenerConf)); } this.cacheLoaderFactory = DeferredValue.withValue(configuration.getCacheLoaderFactory()); this.cacheWriterFactory = DeferredValue.withValue(configuration.getCacheWriterFactory()); Factory<ExpiryPolicy> factory = configuration.getExpiryPolicyFactory(); factory = (factory == null) ? EternalExpiryPolicy.factoryOf() : factory; this.expiryPolicyFactory = DeferredValue.withValue(factory); this.isReadThrough = configuration.isReadThrough(); this.isWriteThrough = configuration.isWriteThrough(); this.isStatisticsEnabled = configuration.isStatisticsEnabled(); this.isStoreByValue = configuration.isStoreByValue(); this.isManagementEnabled = configuration.isManagementEnabled(); }
/** * Ensure a cache's config isn't changed by its configuration object after construction. */ @Test public void testModifyingConfigurationAfterCreateCacheDoesNotModifyCacheConfiguration() { MutableConfiguration mutableConfiguration = new MutableConfiguration().setTypes(Integer.class, Integer.class); Cache<Object, Object> cache = getCacheManager().createCache(getTestCacheName() + "_", mutableConfiguration); mutableConfiguration.setTypes(String.class, String.class); assertEquals(Integer.class, cache.getConfiguration(CompleteConfiguration.class).getKeyType()); assertEquals(Integer.class, cache.getConfiguration(CompleteConfiguration.class).getValueType()); }
@Test public void getTypedCache() { CacheManager cacheManager = getCacheManager(); MutableConfiguration<String, Long> config = new MutableConfiguration<String, Long>().setTypes(String.class, Long.class); cacheManager.createCache("typed-cache", config); Cache<String, Long> cache = cacheManager.getCache("typed-cache", String.class, Long.class); assertNotNull(cache); assertEquals(String.class, cache.getConfiguration(CompleteConfiguration.class).getKeyType()); assertEquals(Long.class, cache.getConfiguration(CompleteConfiguration.class).getValueType()); }