org.apache.geode.cache.GemFireCache Java Examples

The following examples show how to use org.apache.geode.cache.GemFireCache. 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("YellowPages")
public ClientRegionFactoryBean<Object, Object> yellowPagesRegion(GemFireCache gemfireCache) {

	ClientRegionFactoryBean<Object, Object> clientRegion = new ClientRegionFactoryBean<>();

	clientRegion.setCache(gemfireCache);
	clientRegion.setClose(false);
	clientRegion.setShortcut(ClientRegionShortcut.CACHING_PROXY);

	clientRegion.setRegionConfigurers(
		interestRegisteringRegionConfigurer(),
		subscriptionCacheListenerRegionConfigurer()
	);

	return clientRegion;
}
 
Example #2
Source File: ManuallyConfiguredSessionCachingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Test
public void gemfireSessionRegionAndSessionRepositoryAreNotPresent() {

	assertThat(this.applicationContext.containsBean("gemfireCache")).isTrue();
	assertThat(this.applicationContext.containsBean("sessionRepository")).isTrue();
	assertThat(this.applicationContext.containsBean(GemFireHttpSessionConfiguration.DEFAULT_SESSION_REGION_NAME))
		.isFalse();

	GemFireCache gemfireCache = this.applicationContext.getBean(GemFireCache.class);

	assertThat(gemfireCache).isNotNull();
	assertThat(gemfireCache.rootRegions()).isEmpty();

	SessionRepository<?> sessionRepository = this.applicationContext.getBean(SessionRepository.class);

	assertThat(sessionRepository).isNotNull();
	assertThat(sessionRepository).isNotInstanceOf(GemFireOperationsSessionRepository.class);
	assertThat(sessionRepository.getClass().getName().toLowerCase()).doesNotContain("redis");
}
 
Example #3
Source File: ManuallyConfiguredWithPropertiesSessionCachingIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Test(expected = NoSuchBeanDefinitionException.class)
public void gemfireSessionRegionAndSessionRepositoryAreNotPresent() {

	String sessionsRegionName = GemFireHttpSessionConfiguration.DEFAULT_SESSION_REGION_NAME;

	assertThat(this.applicationContext.containsBean("gemfireCache")).isTrue();
	assertThat(this.applicationContext.containsBean("sessionRepository")).isFalse();
	assertThat(this.applicationContext.containsBean(sessionsRegionName)).isFalse();
	assertThat(this.applicationContext.getBeansOfType(SessionRepository.class)).isEmpty();

	GemFireCache gemfireCache = this.applicationContext.getBean(GemFireCache.class);

	assertThat(gemfireCache).isNotNull();
	assertThat(gemfireCache.rootRegions()).isEmpty();

	this.applicationContext.getBean(SessionRepository.class);
}
 
Example #4
Source File: GeodeUtils.java    From calcite with Apache License 2.0 6 votes vote down vote up
/**
 * Obtains a proxy pointing to an existing Region on the server
 *
 * @param cache {@link GemFireCache} instance to interact with the Geode server
 * @param regionName  Name of the region to create proxy for.
 * @return Returns a Region proxy to a remote (on the Server) regions.
 */
public static synchronized Region createRegion(GemFireCache cache, String regionName) {
  Objects.requireNonNull(cache, "cache");
  Objects.requireNonNull(regionName, "regionName");
  Region region = REGION_MAP.get(regionName);
  if (region == null) {
    try {
      region = ((ClientCache) cache)
          .createClientRegionFactory(ClientRegionShortcut.PROXY)
          .create(regionName);
    } catch (IllegalStateException | RegionExistsException e) {
      // means this is a server cache (probably part of embedded testing
      // or clientCache is passed directly)
      region = cache.getRegion(regionName);
    }

    REGION_MAP.put(regionName, region);
  }

  return region;
}
 
Example #5
Source File: ClusterConfigurationWithAuthenticationIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 6 votes vote down vote up
@Bean
ApplicationRunner peerCacheVerifier(GemFireCache cache) {

	return args -> {

		assertThat(cache).isNotNull();
		assertThat(GemfireUtils.isPeer(cache)).isTrue();
		assertThat(cache.getName())
			.isEqualTo(ClusterConfigurationWithAuthenticationIntegrationTests.class.getSimpleName());

		List<String> regionNames = cache.rootRegions().stream()
			.map(Region::getName)
			.collect(Collectors.toList());

		assertThat(regionNames)
			.describedAs("Expected no Regions; but was [%s]", regionNames)
			.isEmpty();
	};
}
 
Example #6
Source File: SiteBWanServerConfig.java    From spring-data-examples with Apache License 2.0 6 votes vote down vote up
@Bean
@DependsOn("DiskStore")
GatewaySenderFactoryBean createGatewaySender(GemFireCache gemFireCache, GatewayEventFilter gatewayEventFilter,
		GatewayTransportFilter gatewayTransportFilter,
		GatewayEventSubstitutionFilter<Long, Customer> gatewayEventSubstitutionFilter) {
	GatewaySenderFactoryBean gatewaySenderFactoryBean = new GatewaySenderFactoryBean(gemFireCache);
	gatewaySenderFactoryBean.setBatchSize(15);
	gatewaySenderFactoryBean.setBatchTimeInterval(1000);
	gatewaySenderFactoryBean.setRemoteDistributedSystemId(1);
	gatewaySenderFactoryBean.setDiskStoreRef("DiskStore");
	gatewaySenderFactoryBean.setEventFilters(Collections.singletonList(gatewayEventFilter));
	gatewaySenderFactoryBean.setTransportFilters(Collections.singletonList(gatewayTransportFilter));
	gatewaySenderFactoryBean.setEventSubstitutionFilter(gatewayEventSubstitutionFilter);
	gatewaySenderFactoryBean.setPersistent(false);
	return gatewaySenderFactoryBean;
}
 
Example #7
Source File: EventServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean
AsyncEventQueueFactoryBean orderAsyncEventQueue(GemFireCache gemFireCache, AsyncEventListener orderAsyncEventListener) {
	AsyncEventQueueFactoryBean asyncEventQueueFactoryBean = new AsyncEventQueueFactoryBean((Cache) gemFireCache);
	asyncEventQueueFactoryBean.setBatchTimeInterval(1000);
	asyncEventQueueFactoryBean.setBatchSize(5);
	asyncEventQueueFactoryBean.setAsyncEventListener(orderAsyncEventListener);
	return asyncEventQueueFactoryBean;
}
 
Example #8
Source File: StorageServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Orders")
PartitionedRegionFactoryBean<Long, Order> createOrderRegion(GemFireCache gemFireCache,
		RegionAttributes<Long, Order> regionAttributes) {
	PartitionedRegionFactoryBean<Long, Order> partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
	partitionedRegionFactoryBean.setCache(gemFireCache);
	partitionedRegionFactoryBean.setRegionName("Orders");
	partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
	partitionedRegionFactoryBean.setAttributes(regionAttributes);
	return partitionedRegionFactoryBean;
}
 
Example #9
Source File: TransactionalServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
ReplicatedRegionFactoryBean<Long, Customer> createCustomerRegion(GemFireCache gemfireCache) {
	ReplicatedRegionFactoryBean<Long, Customer> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemfireCache);
	replicatedRegionFactoryBean.setRegionName("Customers");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	replicatedRegionFactoryBean.setScope(Scope.DISTRIBUTED_ACK);
	return replicatedRegionFactoryBean;
}
 
Example #10
Source File: WanClientConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
protected ClientRegionFactoryBean<Long, Customer> configureProxyClientCustomerRegion(GemFireCache gemFireCache) {
	ClientRegionFactoryBean<Long, Customer> clientRegionFactoryBean = new ClientRegionFactoryBean<>();
	clientRegionFactoryBean.setCache(gemFireCache);
	clientRegionFactoryBean.setName("Customers");
	clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY);
	return clientRegionFactoryBean;
}
 
Example #11
Source File: WanServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
PartitionedRegionFactoryBean<Long, Customer> createCustomerRegion(GemFireCache gemFireCache,
		RegionAttributes<Long, Customer> regionAttributes, GatewaySender gatewaySender) {
	PartitionedRegionFactoryBean<Long, Customer> partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
	partitionedRegionFactoryBean.setCache(gemFireCache);
	partitionedRegionFactoryBean.setRegionName("Customers");
	partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
	partitionedRegionFactoryBean.setAttributes(regionAttributes);
	partitionedRegionFactoryBean.setGatewaySenders(new GatewaySender[] { gatewaySender });
	return partitionedRegionFactoryBean;
}
 
Example #12
Source File: WanServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean(name = "DiskStore")
DiskStoreFactoryBean diskStore(GemFireCache gemFireCache, Faker faker) throws IOException {
	DiskStoreFactoryBean diskStoreFactoryBean = new DiskStoreFactoryBean();
	File tempDirectory = File.createTempFile(faker.name().firstName(), faker.name().firstName());
	tempDirectory.delete();
	tempDirectory.mkdirs();
	tempDirectory.deleteOnExit();
	DiskStoreFactoryBean.DiskDir[] diskDirs = { new DiskStoreFactoryBean.DiskDir(tempDirectory.getAbsolutePath()) };
	diskStoreFactoryBean.setDiskDirs(Arrays.asList(diskDirs));
	diskStoreFactoryBean.setCache(gemFireCache);
	return diskStoreFactoryBean;
}
 
Example #13
Source File: FunctionServerApplicationConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Products")
ReplicatedRegionFactoryBean<Long, Product> createProductRegion(GemFireCache gemfireCache) {
	ReplicatedRegionFactoryBean<Long, Product> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemfireCache);
	replicatedRegionFactoryBean.setRegionName("Products");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	return replicatedRegionFactoryBean;
}
 
Example #14
Source File: FunctionServerApplicationConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
ReplicatedRegionFactoryBean<Long, Customer> createCustomerRegion(GemFireCache gemfireCache) {
	ReplicatedRegionFactoryBean<Long, Customer> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemfireCache);
	replicatedRegionFactoryBean.setRegionName("Customers");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	replicatedRegionFactoryBean.setScope(Scope.DISTRIBUTED_ACK);
	return replicatedRegionFactoryBean;
}
 
Example #15
Source File: FunctionServerApplicationConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Orders")
ReplicatedRegionFactoryBean<Long, Order> createOrderRegion(GemFireCache gemfireCache) {
	ReplicatedRegionFactoryBean<Long, Order> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemfireCache);
	replicatedRegionFactoryBean.setRegionName("Orders");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	return replicatedRegionFactoryBean;
}
 
Example #16
Source File: FunctionInvocationClientApplicationConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Orders")
protected ClientRegionFactoryBean<Long, Order> configureProxyClientOrderRegion(GemFireCache gemFireCache) {
	ClientRegionFactoryBean<Long, Order> clientRegionFactoryBean = new ClientRegionFactoryBean<>();
	clientRegionFactoryBean.setCache(gemFireCache);
	clientRegionFactoryBean.setName("Orders");
	clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY);
	return clientRegionFactoryBean;
}
 
Example #17
Source File: SiteBWanServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean
GatewayReceiverFactoryBean createGatewayReceiver(GemFireCache gemFireCache) {
	GatewayReceiverFactoryBean gatewayReceiverFactoryBean = new GatewayReceiverFactoryBean((Cache) gemFireCache);
	gatewayReceiverFactoryBean.setStartPort(25000);
	gatewayReceiverFactoryBean.setEndPort(25010);
	return gatewayReceiverFactoryBean;
}
 
Example #18
Source File: PdxInstanceBuilderUnitTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
public void fromSourceObject() {

	Object source = new Object();

	GemFireCache mockCache = mock(GemFireCache.class);

	PdxInstance mockPdxInstanceHolder = mock(PdxInstance.class);
	PdxInstance mockPdxInstanceSource = mock(PdxInstance.class);

	PdxInstanceFactory mockPdxInstanceFactory = mock(PdxInstanceFactory.class);

	doReturn(true).when(mockCache).getPdxReadSerialized();
	doReturn(mockPdxInstanceFactory).when(mockCache).createPdxInstanceFactory(eq(source.getClass().getName()));
	doReturn(mockPdxInstanceHolder).when(mockPdxInstanceFactory).create();
	doReturn(mockPdxInstanceSource).when(mockPdxInstanceHolder).getField(eq("source"));

	PdxInstanceBuilder builder = PdxInstanceBuilder.create(mockCache);

	assertThat(builder).isNotNull();
	assertThat(builder.getRegionService()).isEqualTo(mockCache);

	PdxInstanceBuilder.Factory factory = builder.from(source);

	assertThat(factory).isNotNull();
	assertThat(factory.create()).isEqualTo(mockPdxInstanceSource);

	verify(mockCache, times(1)).getPdxReadSerialized();
	verify(mockCache, times(1)).createPdxInstanceFactory(eq(source.getClass().getName()));
	verify(mockPdxInstanceFactory, times(1)).writeObject(eq("source"), eq(source));
	verify(mockPdxInstanceFactory, times(1)).create();
	verify(mockPdxInstanceHolder, times(1)).getField(eq("source"));
	verifyNoInteractions(mockPdxInstanceSource);
}
 
Example #19
Source File: EventServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean(name = "OrderProductSummary")
PartitionedRegionFactoryBean<Long, Order> createOrderProductSummaryRegion(GemFireCache gemFireCache) {
	PartitionedRegionFactoryBean<Long, Order> partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
	partitionedRegionFactoryBean.setCache(gemFireCache);
	partitionedRegionFactoryBean.setRegionName("OrderProductSummary");
	partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
	return partitionedRegionFactoryBean;
}
 
Example #20
Source File: SiteAWanEnabledServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean
@DependsOn("DiskStore")
GatewaySenderFactoryBean createGatewaySender(GemFireCache gemFireCache) {
	GatewaySenderFactoryBean gatewaySenderFactoryBean = new GatewaySenderFactoryBean(gemFireCache);
	gatewaySenderFactoryBean.setBatchSize(15);
	gatewaySenderFactoryBean.setBatchTimeInterval(1000);
	gatewaySenderFactoryBean.setRemoteDistributedSystemId(2);
	gatewaySenderFactoryBean.setPersistent(false);
	gatewaySenderFactoryBean.setDiskStoreRef("DiskStore");
	return gatewaySenderFactoryBean;
}
 
Example #21
Source File: FunctionInvocationClientApplicationConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Products")
protected ClientRegionFactoryBean<Long, Product> configureProxyClientProductRegion(GemFireCache gemFireCache) {
	ClientRegionFactoryBean<Long, Product> clientRegionFactoryBean = new ClientRegionFactoryBean<>();
	clientRegionFactoryBean.setCache(gemFireCache);
	clientRegionFactoryBean.setName("Products");
	clientRegionFactoryBean.setShortcut(ClientRegionShortcut.PROXY);
	return clientRegionFactoryBean;
}
 
Example #22
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 #23
Source File: RegionResolver.java    From immutables with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve region using default {@link ContainerNaming#DEFAULT} naming convention.
 * @see org.apache.geode.cache.RegionService#getRegion(String)
 */
static RegionResolver defaultResolver(GemFireCache cache) {
  Objects.requireNonNull(cache, "cache");
  return ctx -> {
    String name = ContainerNaming.DEFAULT.name(ctx);
    Region<Object, Object> region = cache.getRegion(name);
    if (region == null) {
      throw new IllegalArgumentException(String.format("Failed to find geode region for %s. " +
              "Region %s not found in %s cache", ctx.getName(), name, cache.getName()));
    }
    return region;
  };
}
 
Example #24
Source File: SpringBootApacheGeodeDockerClientCacheApplication.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
private void assertClientCacheAndConfigureMappingPdxSerializer(GemFireCache cache) {

		assertThat(cache).isNotNull();
		assertThat(cache.getName())
			.isEqualTo(SpringBootApacheGeodeDockerClientCacheApplication.class.getSimpleName());
		assertThat(cache.getPdxSerializer()).isInstanceOf(MappingPdxSerializer.class);

		MappingPdxSerializer serializer = (MappingPdxSerializer) cache.getPdxSerializer();

		serializer.setIncludeTypeFilters(type -> Optional.ofNullable(type)
			.map(Class::getPackage)
			.map(Package::getName)
			.filter(packageName -> packageName.startsWith(this.getClass().getPackage().getName()))
			.isPresent());
	}
 
Example #25
Source File: EventServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Orders")
PartitionedRegionFactoryBean<Long, Order> createOrderRegion(GemFireCache gemFireCache, AsyncEventQueue orderAsyncEventQueue) {
	PartitionedRegionFactoryBean<Long, Order> partitionedRegionFactoryBean = new PartitionedRegionFactoryBean<>();
	partitionedRegionFactoryBean.setCache(gemFireCache);
	partitionedRegionFactoryBean.setRegionName("Orders");
	partitionedRegionFactoryBean.setDataPolicy(DataPolicy.PARTITION);
	partitionedRegionFactoryBean.setAsyncEventQueues(new AsyncEventQueue[]{orderAsyncEventQueue});
	return partitionedRegionFactoryBean;
}
 
Example #26
Source File: CacheNameAutoConfigurationIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
public void cacheNameUsesSpringApplicationNameProperty() {

	this.springApplicationBuilderFunction = this.springApplicationNamePropertyFunction;

	assertGemFireCache(newApplicationContext(AnnotationNameAttributeTestConfiguration.class)
		.getBean(GemFireCache.class), "SpringApplicationNameTest");
}
 
Example #27
Source File: StorageServerConfig.java    From spring-data-examples with Apache License 2.0 5 votes vote down vote up
@Bean("Customers")
ReplicatedRegionFactoryBean<Long, Customer> createCustomerRegion(GemFireCache gemFireCache, Compressor compressor) {
	ReplicatedRegionFactoryBean<Long, Customer> replicatedRegionFactoryBean = new ReplicatedRegionFactoryBean<>();
	replicatedRegionFactoryBean.setCache(gemFireCache);
	replicatedRegionFactoryBean.setRegionName("Customers");
	replicatedRegionFactoryBean.setDataPolicy(DataPolicy.REPLICATE);
	replicatedRegionFactoryBean.setCompressor(compressor);
	return replicatedRegionFactoryBean;
}
 
Example #28
Source File: ExistingRegionTemplateByRegionAutoConfigurationIntegrationTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Bean("Example")
public ClientRegionFactoryBean<Object, Object> exampleRegion(GemFireCache gemfireCache) {

	ClientRegionFactoryBean<Object, Object> clientRegion = new ClientRegionFactoryBean<>();

	clientRegion.setCache(gemfireCache);
	clientRegion.setClose(false);
	clientRegion.setShortcut(ClientRegionShortcut.LOCAL);

	return clientRegion;
}
 
Example #29
Source File: HttpBasicAuthenticationSecurityConfigurationUnitTests.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Test
public void schemaObjectInitializerPostProcessorProcessesClusterSchemaObjectInitializerBeans() throws Exception {

	Environment mockEnvironment = mock(Environment.class);

	ClientCache mockClientCache = mock(ClientCache.class);

	ClusterConfigurationConfiguration.SchemaObjectContext schemaObjectContextSpy =
		spy(constructInstance(ClusterConfigurationConfiguration.SchemaObjectContext.class,
			new Class[] { GemFireCache.class }, mockClientCache));

	assertThat(schemaObjectContextSpy).isNotNull();
	assertThat(schemaObjectContextSpy.<ClientCache>getGemfireCache()).isEqualTo(mockClientCache);

	doReturn(new RestHttpGemfireAdminTemplate(mockClientCache))
		.when(schemaObjectContextSpy).getGemfireAdminOperations();

	ClusterConfigurationConfiguration.ClusterSchemaObjectInitializer clusterSchemaObjectInitializer =
		constructInstance(ClusterConfigurationConfiguration.ClusterSchemaObjectInitializer.class,
			new Class[] { ClusterConfigurationConfiguration.SchemaObjectContext.class }, schemaObjectContextSpy);

	BeanPostProcessor beanPostProcessor =
		this.httpSecurityConfiguration.schemaObjectInitializerPostProcessor(mockEnvironment);

	assertThat(beanPostProcessor).isNotNull();
	assertThat(beanPostProcessor.postProcessBeforeInitialization(clusterSchemaObjectInitializer,
		"mockClusterSchemaObjectInitializer")).isEqualTo(clusterSchemaObjectInitializer);
	assertThat(beanPostProcessor.postProcessAfterInitialization(clusterSchemaObjectInitializer,
		"mockClusterSchemaObjectInitializer")).isEqualTo(clusterSchemaObjectInitializer);
	assertThat(this.httpSecurityConfiguration.restTemplateReference.get()).isNotNull();
	assertThat(this.httpSecurityConfiguration.restTemplateReference.get().getInterceptors()).isNotEmpty();
	assertThat(this.httpSecurityConfiguration.restTemplateReference.get().getInterceptors().stream()
		.anyMatch(ClientHttpRequestInterceptor.class::isInstance)).isTrue();
}
 
Example #30
Source File: GemFireDebugConfiguration.java    From spring-boot-data-geode with Apache License 2.0 5 votes vote down vote up
@Bean
public BeanPostProcessor gemfireCacheSslConfigurationBeanPostProcessor() {

	return new BeanPostProcessor() {

		@Nullable @Override
		public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {

			Optional.ofNullable(bean)
				.filter(GemFireCache.class::isInstance)
				.map(GemFireCache.class::cast)
				.map(GemFireCache::getDistributedSystem)
				.filter(InternalDistributedSystem.class::isInstance)
				.map(InternalDistributedSystem.class::cast)
				.map(InternalDistributedSystem::getConfig)
				.ifPresent(distributionConfig -> {

					SecurableCommunicationChannel[] securableCommunicationChannels =
						ArrayUtils.nullSafeArray(distributionConfig.getSecurableCommunicationChannels(),
							SecurableCommunicationChannel.class);

					logger.error("SECURABLE COMMUNICATION CHANNELS {}",
						Arrays.toString(securableCommunicationChannels));

					Arrays.stream(securableCommunicationChannels).forEach(securableCommunicationChannel -> {

						SSLConfig sslConfig = SSLConfigurationFactory
							.getSSLConfigForComponent(distributionConfig, securableCommunicationChannel);

						logger.error("{} SSL CONFIGURATION [{}]", securableCommunicationChannel.name(), sslConfig);
					});
				});

			return bean;
		}
	};
}