Search in sources :

Example 1 with TxQueryInterceptor

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());
    }
}
Also used : BasicComponentRegistry(org.infinispan.factories.impl.BasicComponentRegistry) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) QueryInterceptor(org.infinispan.query.backend.QueryInterceptor) AsyncInterceptorChain(org.infinispan.interceptors.AsyncInterceptorChain) EntryWrappingInterceptor(org.infinispan.interceptors.impl.EntryWrappingInterceptor) TxQueryInterceptor(org.infinispan.query.backend.TxQueryInterceptor) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 BasicComponentRegistry (org.infinispan.factories.impl.BasicComponentRegistry)1 AsyncInterceptorChain (org.infinispan.interceptors.AsyncInterceptorChain)1 EntryWrappingInterceptor (org.infinispan.interceptors.impl.EntryWrappingInterceptor)1 QueryInterceptor (org.infinispan.query.backend.QueryInterceptor)1 TxQueryInterceptor (org.infinispan.query.backend.TxQueryInterceptor)1 GlobalTransaction (org.infinispan.transaction.xa.GlobalTransaction)1