use of org.infinispan.query.backend.TxQueryInterceptor in project infinispan by infinispan.
the class LifecycleManager method createQueryInterceptorIfNeeded.
private void createQueryInterceptorIfNeeded(ComponentRegistry cr, Configuration cfg, AdvancedCache<?, ?> cache, Map<String, Class<?>> indexedClasses) {
CONTAINER.registeringQueryInterceptor(cache.getName());
BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
ComponentRef<QueryInterceptor> queryInterceptorRef = bcr.getComponent(QueryInterceptor.class);
if (queryInterceptorRef != null) {
// could be already present when two caches share a config
return;
}
ConcurrentMap<GlobalTransaction, Map<Object, Object>> txOldValues = new ConcurrentHashMap<>();
boolean manualIndexing = HS5_CONF_STRATEGY_MANUAL.equals(cfg.indexing().properties().get(HS5_CONF_STRATEGY_PROPERTY));
QueryInterceptor queryInterceptor = new QueryInterceptor(manualIndexing, txOldValues, cache, indexedClasses);
AsyncInterceptorChain ic = bcr.getComponent(AsyncInterceptorChain.class).wired();
EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class);
ic.addInterceptorBefore(queryInterceptor, wrappingInterceptor.getClass());
bcr.registerComponent(QueryInterceptor.class, queryInterceptor, true);
bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), QueryInterceptor.class.getName());
if (cfg.transaction().transactionMode().isTransactional()) {
TxQueryInterceptor txQueryInterceptor = new TxQueryInterceptor(txOldValues, queryInterceptor);
ic.addInterceptorBefore(txQueryInterceptor, wrappingInterceptor.getClass());
bcr.registerComponent(TxQueryInterceptor.class, txQueryInterceptor, true);
bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), TxQueryInterceptor.class.getName());
}
}
Aggregations