/** * Clone cached object. * * @param obj Object to clone * @return Clone of the given object. * @throws GridException If failed to clone object. */ @SuppressWarnings({"unchecked"}) @Nullable public <T> T cloneValue(@Nullable T obj) throws GridException { if (obj == null) return obj; GridCacheCloner c = cacheCfg.getCloner(); if (c != null) return c.cloneValue(obj); return X.cloneObject(obj, false, true); }
/** * @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; }
/** * @param cctx Cache context. */ private void cleanup(GridCacheContext cctx) { GridCacheConfiguration cfg = cctx.config(); cleanup(cfg, cfg.getEvictionPolicy(), false); cleanup(cfg, cfg.getNearEvictionPolicy(), true); cleanup(cfg, cfg.getAffinity(), false); cleanup(cfg, cfg.getAffinityMapper(), false); cleanup(cfg, cctx.jta().tmLookup(), false); cleanup(cfg, cfg.getCloner(), false); cleanup(cfg, cfg.getStore(), false); cctx.cleanup(); }
/** * @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); }
clonerClsName = className(cfg.getCloner()); evictFilterClsName = className(cfg.getEvictionFilter()); evictPlcClsName = className(cfg.getEvictionPolicy());
backups = cc.getBackups(); cacheMode = cc.getCacheMode(); cloner = cc.getCloner(); dfltConcurrency = cc.getDefaultTxConcurrency(); dfltIsolation = cc.getDefaultTxIsolation();
cfg.invalidate(ccfg.isInvalidate()); cfg.startSize(ccfg.getStartSize()); cfg.cloner(compactClass(ccfg.getCloner())); cfg.transactionManagerLookupClassName(ccfg.getTransactionManagerLookupClassName()); cfg.txSerializableEnabled(ccfg.isTxSerializableEnabled());