org.apache.geode.cache.CacheListener Java Examples

The following examples show how to use org.apache.geode.cache.CacheListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeodeConfiguration.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
RegionConfigurer subscriptionCacheListenerRegionConfigurer() {

	return new RegionConfigurer() {

		@Override
		@SuppressWarnings("unchecked")
		public void configure(String beanName, ClientRegionFactoryBean<?, ?> clientRegion) {

			CacheListener subscriptionCacheListener =
					new AbstractCommonEventProcessingCacheListener() {

				@Override
				protected void processEntryEvent(EntryEvent event, EntryEventType eventType) {

					if (event.isOriginRemote()) {
						System.err.printf("[%1$s] EntryEvent for [%2$s] with value [%3$s]%n",
							event.getKey(), event.getOperation(), event.getNewValue());
					}
				}
			};

			clientRegion.setCacheListeners(ArrayUtils.asArray(subscriptionCacheListener));
		}
	};
}
 
Example #2
Source File: MultiSiteCachingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
@SuppressWarnings({ "rawtypes", "unchecked" })
RegionConfigurer customersByNameCacheListenerConfigurer(@Qualifier("customersByNameCacheListener")
		CacheListener<String, Customer> customersByNameCacheListener) {

	return new RegionConfigurer() {

		@Override
		public void configure(String beanName, ClientRegionFactoryBean<?, ?> bean) {

			if ("CustomersByName".equals(beanName)) {
				bean.setCacheListeners(ArrayUtils.<CacheListener>asArray(customersByNameCacheListener));
				bean.setInterests(ArrayUtils.<Interest>asArray(new RegexInterest(".*",
					InterestResultPolicy.KEYS, false, false)));
			}
		}
	};
}
 
Example #3
Source File: EventServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Products")
ReplicatedRegionFactoryBean<Long, Product> createProductRegion(GemFireCache gemFireCache, CacheListener<Long, Product> loggingCacheListener,
															   CacheLoader<Long, Product> productCacheLoader) {
	ReplicatedRegionFactoryBean<Long, Product> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemFireCache);
	replicatedRegionFactoryBean.setRegionName("Products");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	replicatedRegionFactoryBean.setCacheLoader(productCacheLoader);
	replicatedRegionFactoryBean.setCacheListeners(new CacheListener[]{loggingCacheListener});
	return replicatedRegionFactoryBean;
}
 
Example #4
Source File: EventServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
ReplicatedRegionFactoryBean<Long, Customer> createCustomerRegion(GemFireCache gemFireCache,
																 CacheWriter<Long, Customer> customerCacheWriter,
																 CacheListener<Long, Customer> loggingCacheListener) {
	ReplicatedRegionFactoryBean<Long, Customer> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemFireCache);
	replicatedRegionFactoryBean.setRegionName("Customers");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	replicatedRegionFactoryBean.setCacheListeners(new CacheListener[]{loggingCacheListener});
	replicatedRegionFactoryBean.setCacheWriter(customerCacheWriter);
	return replicatedRegionFactoryBean;
}
 
Example #5
Source File: MultiSiteCachingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 4 votes vote down vote up
@Bean
CacheListener<String, Customer> customersByNameCacheListener() {
	return new CustomersByNameCacheListener();
}