private void removeQueryInterceptorFromConfiguration(Configuration cfg) { ConfigurationBuilder builder = new ConfigurationBuilder(); CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors(); for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) { if (!(interceptorConfig.asyncInterceptor() instanceof QueryInterceptor)) { customInterceptorsBuilder.addInterceptor().read(interceptorConfig); } } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); }
private void removeQueryInterceptorFromConfiguration(Configuration cfg) { ConfigurationBuilder builder = new ConfigurationBuilder(); CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors(); for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) { if (!(interceptorConfig.asyncInterceptor() instanceof QueryInterceptor)) { customInterceptorsBuilder.addInterceptor().read(interceptorConfig); } } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); }
private void removeRemoteIndexingInterceptorFromConfig(Configuration cfg) { ConfigurationBuilder builder = new ConfigurationBuilder(); CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors(); for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) { if (!(interceptorConfig.interceptor() instanceof RemoteValueWrapperInterceptor)) { customInterceptorsBuilder.addInterceptor().read(interceptorConfig); } } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); } }
private void createRemoteIndexingInterceptor(ComponentRegistry cr, Configuration cfg) { BaseTypeConverterInterceptor wrapperInterceptor = cr.getComponent(RemoteValueWrapperInterceptor.class); if (wrapperInterceptor == null) { wrapperInterceptor = new RemoteValueWrapperInterceptor(); // Interceptor registration not needed, core configuration handling // already does it for all custom interceptors - UNLESS the InterceptorChain already exists in the component registry! InterceptorChain ic = cr.getComponent(InterceptorChain.class); ConfigurationBuilder builder = new ConfigurationBuilder().read(cfg); InterceptorConfigurationBuilder interceptorBuilder = builder.customInterceptors().addInterceptor(); interceptorBuilder.interceptor(wrapperInterceptor); if (ic != null) ic.addInterceptorAfter(wrapperInterceptor, InvocationContextInterceptor.class); interceptorBuilder.after(InvocationContextInterceptor.class); if (ic != null) { cr.registerComponent(wrapperInterceptor, RemoteValueWrapperInterceptor.class); } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); } }
cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
private void assertCacheHasCustomInterceptor(Cache<?, ?> cache, CommandInterceptor interceptor) { for (InterceptorConfiguration interceptorConfig : cache.getCacheConfiguration().customInterceptors().interceptors()) { if (interceptor == interceptorConfig.interceptor()) { return; } } fail("Expected to find interceptor " + interceptor + " among custom interceptors of cache, but it was not there."); }
private void createQueryInterceptorIfNeeded(ComponentRegistry cr, Configuration cfg, SearchIntegrator searchFactory) { QueryInterceptor queryInterceptor = cr.getComponent(QueryInterceptor.class); if (queryInterceptor == null) { queryInterceptor = buildQueryInterceptor(cfg, searchFactory, cr.getComponent(Cache.class)); // Interceptor registration not needed, core configuration handling // already does it for all custom interceptors - UNLESS the InterceptorChain already exists in the component registry! AsyncInterceptorChain ic = cr.getComponent(AsyncInterceptorChain.class); ConfigurationBuilder builder = new ConfigurationBuilder().read(cfg); InterceptorConfigurationBuilder interceptorBuilder = builder.customInterceptors().addInterceptor(); interceptorBuilder.interceptor(queryInterceptor); boolean txVersioned = Configurations.isTxVersioned(cfg); boolean isTotalOrder = cfg.transaction().transactionProtocol().isTotalOrder(); Class<? extends DDAsyncInterceptor> wrappingInterceptor = EntryWrappingInterceptor.class; if (txVersioned) { wrappingInterceptor = isTotalOrder ? TotalOrderVersionedEntryWrappingInterceptor.class : VersionedEntryWrappingInterceptor.class; } if (ic != null) ic.addInterceptorAfter(queryInterceptor, wrappingInterceptor); interceptorBuilder.after(wrappingInterceptor); if (ic != null) { cr.registerComponent(queryInterceptor, QueryInterceptor.class); cr.registerComponent(queryInterceptor, queryInterceptor.getClass().getName(), true); } cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors()); } }
assertTrue(!c.customInterceptors().interceptors().isEmpty()); assertEquals(6, c.customInterceptors().interceptors().size()); for(InterceptorConfiguration i : c.customInterceptors().interceptors()) { if (i.asyncInterceptor() instanceof FooInterceptor) { assertEquals(i.properties().getProperty("foo"), "bar");
List<InterceptorConfiguration> interceptors = c.customInterceptors().interceptors(); InterceptorConfiguration interceptor = interceptors.get(0); assertTrue(interceptor.interceptor() instanceof CustomInterceptor1);