/** * Getter to the configured ReadWriteCopyStrategy. * This will always return the same unique instance per cache * * @return the {@link ReadWriteCopyStrategy} for instance for this cache */ public ReadWriteCopyStrategy<Element> getCopyStrategy() { // todo really make this pluggable through config! return copyStrategyConfiguration.getCopyStrategyInstance(getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> CopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new CopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrap(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new TxCopyingElementValueComparator(comparator, copyStrategyHandler); }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrapIfCopy(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { if (isCopyOnReadAndCopyOnWrite(cacheConfiguration)) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new CopyingElementValueComparator(comparator, copyStrategyHandler); } return comparator; }
/** * Getter to the CopyStrategy set in the config (really? how?). * This will always return the same unique instance per cache * * @return the {@link ReadWriteCopyStrategy} for instance for this cache */ public ReadWriteCopyStrategy<Element> getCopyStrategy() { // todo really make this pluggable through config! return copyStrategyConfiguration.getCopyStrategyInstance(); }
/** * Getter to the configured ReadWriteCopyStrategy. * This will always return the same unique instance per cache * * @return the {@link ReadWriteCopyStrategy} for instance for this cache */ public ReadWriteCopyStrategy<Element> getCopyStrategy() { // todo really make this pluggable through config! return copyStrategyConfiguration.getCopyStrategyInstance(getClassLoader()); }
/** * Getter to the configured ReadWriteCopyStrategy. * This will always return the same unique instance per cache * * @return the {@link ReadWriteCopyStrategy} for instance for this cache */ public ReadWriteCopyStrategy<Element> getCopyStrategy() { // todo really make this pluggable through config! return copyStrategyConfiguration.getCopyStrategyInstance(getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> TxCopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new TxCopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> CopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new CopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps (always) with the proper configured CopyingCacheStore * @param cacheStore the store to wrap * @param cacheConfiguration the cache config backed by this store * @param <T> the Store type * @return the wrapped store */ private static <T extends Store> CopyingCacheStore<T> wrap(final T cacheStore, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); return new CopyingCacheStore<T>(cacheStore, cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrap(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new TxCopyingElementValueComparator(comparator, copyStrategyHandler); }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrap(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new TxCopyingElementValueComparator(comparator, copyStrategyHandler); }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrapIfCopy(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { if (isCopyOnReadAndCopyOnWrite(cacheConfiguration)) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new CopyingElementValueComparator(comparator, copyStrategyHandler); } return comparator; }
/** * Wraps the given {@link net.sf.ehcache.store.ElementValueComparator} if the configuration requires copy on read * * @param comparator the comparator to wrap * @param cacheConfiguration the cache configuration * @return the comparator passed if no copy needed, a wrapped comparator otherwise */ public static ElementValueComparator wrapIfCopy(final ElementValueComparator comparator, final CacheConfiguration cacheConfiguration) { if (isCopyOnReadAndCopyOnWrite(cacheConfiguration)) { final ReadWriteCopyStrategy<Element> copyStrategyInstance = cacheConfiguration.getCopyStrategyConfiguration() .getCopyStrategyInstance(cacheConfiguration.getClassLoader()); CopyStrategyHandler copyStrategyHandler = new CopyStrategyHandler(cacheConfiguration.isCopyOnRead(), cacheConfiguration.isCopyOnWrite(), copyStrategyInstance, cacheConfiguration.getClassLoader()); return new CopyingElementValueComparator(comparator, copyStrategyHandler); } return comparator; }
if (configuration.getTransactionalMode().isTransactional()) { configuration.getCopyStrategyConfiguration().setCopyStrategyInstance(null); copyStrategy = configuration.getCopyStrategyConfiguration().getCopyStrategyInstance(); configuration.getCopyStrategyConfiguration().setCopyStrategyInstance(new ImmutableValueElementCopyStrategy());