/** {@inheritDoc} */ @Nullable @Override public V get(K key) throws GridException { V val = get(key, true, null); if (ctx.config().getInterceptor() != null) val = (V)ctx.config().getInterceptor().onGet(key, val); return val; }
/** * @param ccfg Cache configuration. * @param objs Extra components. * @return Components provided in cache configuration which can implement {@link GridLifecycleAware} interface. */ private Iterable<Object> lifecycleAwares(GridCacheConfiguration ccfg, Object...objs) { Collection<Object> ret = new ArrayList<>(7 + objs.length); ret.add(ccfg.getAffinity()); ret.add(ccfg.getAffinityMapper()); ret.add(ccfg.getCloner()); ret.add(ccfg.getEvictionFilter()); ret.add(ccfg.getEvictionPolicy()); ret.add(ccfg.getNearEvictionPolicy()); ret.add(ccfg.getInterceptor()); Collections.addAll(ret, objs); return ret; }
/** {@inheritDoc} */ @Override public Map<K, V> getAll(@Nullable Collection<? extends K> keys) throws GridException { Map<K, V> map = getAll(keys, true, null); if (ctx.config().getInterceptor() != null) map = interceptGet(keys, map); return map; }
/** {@inheritDoc} */ @Override public GridFuture<Map<K, V>> getAllAsync(@Nullable final Collection<? extends K> keys) { GridFuture<Map<K, V>> fut = getAllAsync(keys, true, null); if (ctx.config().getInterceptor() != null) return fut.chain(new CX1<GridFuture<Map<K, V>>, Map<K, V>>() { @Override public Map<K, V> applyx(GridFuture<Map<K, V>> f) throws GridException { return interceptGet(keys, f.get()); } }); return fut; }
return map; GridCacheInterceptor<K, V> interceptor = cacheCfg.getInterceptor();
/** {@inheritDoc} */ @Override public V remove(K key, @Nullable GridCacheEntryEx<K, V> cached, GridPredicate<GridCacheEntry<K, V>>[] filter) throws GridException { V ret = removeAllAsync(Collections.singletonList(key), cached, implicit, true, filter).get().value(); if (cctx.config().getInterceptor() != null) return (V)cctx.config().getInterceptor().onBeforeRemove(key, ret).get2(); return ret; }
/** {@inheritDoc} */ @Override public GridFuture<V> getAsync(final K key) { GridFuture<V> fut = getAsync(key, true, null); if (ctx.config().getInterceptor() != null) return fut.chain(new CX1<GridFuture<V>, V>() { @Override public V applyx(GridFuture<V> f) throws GridException { return (V)ctx.config().getInterceptor().onGet(key, f.get()); } }); return fut; }
@Override public V applyx(GridFuture<V> f) throws GridException { return (V)ctx.config().getInterceptor().onGet(key, f.get()); } });
/** {@inheritDoc} */ @Override public void addAttributes(Map<String, Object> attrs) throws GridException { if (ctx.isDaemon() || F.isEmpty(ctx.config().getCacheConfiguration())) return; GridCacheAttributes[] attrVals = new GridCacheAttributes[ctx.config().getCacheConfiguration().length]; Map<String, Boolean> attrPortable = new HashMap<>(); Collection<String> replicationCaches = new ArrayList<>(); Map<String, String> interceptors = new HashMap<>(); int i = 0; for (GridCacheConfiguration cfg : ctx.config().getCacheConfiguration()) { attrVals[i++] = new GridCacheAttributes(cfg); attrPortable.put(CU.mask(cfg.getName()), cfg.isPortableEnabled()); if (cfg.getDrSenderConfiguration() != null) replicationCaches.add(cfg.getName()); if (cfg.getInterceptor() != null) interceptors.put(cfg.getName(), cfg.getInterceptor().getClass().getName()); } attrs.put(ATTR_CACHE, attrVals); attrs.put(ATTR_CACHE_PORTABLE, attrPortable); attrs.put(ATTR_REPLICATION_CACHES, replicationCaches); if (!interceptors.isEmpty()) attrs.put(ATTR_CACHE_INTERCEPTORS, interceptors); }
boolean intercept = ctx.config().getInterceptor() != null; ctx.config().getInterceptor().onAfterPut(entry.key(), writeVal); else ctx.config().getInterceptor().onAfterRemove(entry.key(), t.get2());
GridCacheStoreManager<K, V> store = cctx.store(); boolean intercept = cctx.config().getInterceptor() != null; V old = e.cached().rawGetOrUnmarshal(true); val = (V)cctx.config().getInterceptor().onBeforePut(key, old, val); V old = e.cached().rawGetOrUnmarshal(true); GridBiTuple<Boolean, V> t = cctx.config().<K, V>getInterceptor() .onBeforeRemove(key, old);
if (cctx.config().getInterceptor() != null && !F.isEmpty(writes)) { for (GridCacheTxEntry<K, V> e : writes) { GridCacheTxEntry<K, V> txEntry = tx.entry(e.key());
boolean intercept = ctx.config().getInterceptor() != null;
/** * @param cfg Configuration. * @param objs Extra components. * @throws GridException If failed to inject. */ private void prepare(GridCacheConfiguration cfg, Object... objs) throws GridException { prepare(cfg, cfg.getEvictionPolicy(), false); prepare(cfg, cfg.getNearEvictionPolicy(), true); prepare(cfg, cfg.getAffinity(), false); prepare(cfg, cfg.getAffinityMapper(), false); prepare(cfg, cfg.getCloner(), false); prepare(cfg, cfg.getStore(), false); prepare(cfg, cfg.getEvictionFilter(), false); prepare(cfg, cfg.getInterceptor(), false); GridDrSenderCacheConfiguration drSndCfg = cfg.getDrSenderConfiguration(); if (drSndCfg != null) prepare(cfg, drSndCfg.getEntryFilter(), false); GridDrReceiverCacheConfiguration drRcvCfg = cfg.getDrReceiverConfiguration(); if (drRcvCfg != null) prepare(cfg, drRcvCfg.getConflictResolver(), false); for (Object obj : objs) prepare(cfg, obj, false); }
updated = (V)cctx.config().getInterceptor().onBeforePut(key, old, updated); interceptorRes = cctx.config().getInterceptor().onBeforeRemove(key, old); cctx.config().getInterceptor().onAfterPut(key, val); else cctx.config().getInterceptor().onAfterRemove(key, old);
boolean intercept = cctx.config().getInterceptor() != null; V interceptorVal = (V)cctx.config().getInterceptor().onBeforePut(key, old, val); cctx.config().getInterceptor().onAfterPut(key, val);
boolean intercept = req.forceTransformBackups() && ctx.config().getInterceptor() != null;
boolean intercept = req.forceTransformBackups() && ctx.config().getInterceptor() != null;
cfg.memoryMode(ccfg.getMemoryMode()); cfg.indexingSpiName(ccfg.getIndexingSpiName()); cfg.interceptor(compactClass(ccfg.getInterceptor())); cfg.affinityConfig(VisorAffinityConfig.from(ccfg)); cfg.preloadConfig(VisorPreloadConfig.from(ccfg));
evictSyncTimeout = cc.getEvictSynchronizedTimeout(); indexingSpiName = cc.getIndexingSpiName(); interceptor = cc.getInterceptor(); invalidate = cc.isInvalidate(); keepPortableInStore = cc.isKeepPortableInStore();