|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2010-2013 the original author or authors.
|
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
@ -18,7 +18,11 @@ package sample.data.gemfire;
|
|
|
|
|
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import com.gemstone.gemfire.cache.Cache;
|
|
|
|
|
import com.gemstone.gemfire.cache.RegionAttributes;
|
|
|
|
|
import sample.data.gemfire.config.SampleDataGemFireProperties;
|
|
|
|
|
import sample.data.gemfire.domain.Gemstone;
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.SpringApplication;
|
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
|
|
|
@ -30,12 +34,6 @@ import org.springframework.data.gemfire.ReplicatedRegionFactoryBean;
|
|
|
|
|
import org.springframework.data.gemfire.repository.config.EnableGemfireRepositories;
|
|
|
|
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|
|
|
|
|
|
|
|
|
import com.gemstone.gemfire.cache.Cache;
|
|
|
|
|
import com.gemstone.gemfire.cache.RegionAttributes;
|
|
|
|
|
|
|
|
|
|
import sample.data.gemfire.config.SampleDataGemFireApplicationProperties;
|
|
|
|
|
import sample.data.gemfire.domain.Gemstone;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The GemstoneAppConfiguration class for allowing Spring Boot to pick up additional
|
|
|
|
|
* application Spring configuration meta-data for GemFire, which must be specified in
|
|
|
|
@ -46,29 +44,21 @@ import sample.data.gemfire.domain.Gemstone;
|
|
|
|
|
@SpringBootApplication
|
|
|
|
|
@EnableGemfireRepositories
|
|
|
|
|
@EnableTransactionManagement
|
|
|
|
|
@EnableConfigurationProperties(SampleDataGemFireApplicationProperties.class)
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
@EnableConfigurationProperties(SampleDataGemFireProperties.class)
|
|
|
|
|
public class SampleDataGemFireApplication {
|
|
|
|
|
|
|
|
|
|
protected static final String GEMSTONES_REGION_NAME = "Gemstones";
|
|
|
|
|
|
|
|
|
|
private final SampleDataGemFireProperties applicationProperties;
|
|
|
|
|
|
|
|
|
|
public SampleDataGemFireApplication(SampleDataGemFireProperties applicationProperties) {
|
|
|
|
|
this.applicationProperties = applicationProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(final String[] args) {
|
|
|
|
|
SpringApplication.run(SampleDataGemFireApplication.class, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
SampleDataGemFireApplicationProperties applicationProperties;
|
|
|
|
|
|
|
|
|
|
Properties gemfireProperties() {
|
|
|
|
|
Properties gemfireProperties = new Properties();
|
|
|
|
|
|
|
|
|
|
gemfireProperties.setProperty("name", SampleDataGemFireApplication.class.getSimpleName());
|
|
|
|
|
gemfireProperties.setProperty("mcast-port", "0");
|
|
|
|
|
gemfireProperties.setProperty("locators", "");
|
|
|
|
|
gemfireProperties.setProperty("log-level", applicationProperties.getLogLevel());
|
|
|
|
|
|
|
|
|
|
return gemfireProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
CacheFactoryBean gemfireCache() {
|
|
|
|
@ -80,12 +70,23 @@ public class SampleDataGemFireApplication {
|
|
|
|
|
return gemfireCache;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Properties gemfireProperties() {
|
|
|
|
|
Properties gemfireProperties = new Properties();
|
|
|
|
|
|
|
|
|
|
gemfireProperties.setProperty("name", SampleDataGemFireApplication.class.getSimpleName());
|
|
|
|
|
gemfireProperties.setProperty("mcast-port", "0");
|
|
|
|
|
gemfireProperties.setProperty("locators", "");
|
|
|
|
|
gemfireProperties.setProperty("log-level", this.applicationProperties.getLogLevel());
|
|
|
|
|
|
|
|
|
|
return gemfireProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean(name = GEMSTONES_REGION_NAME)
|
|
|
|
|
ReplicatedRegionFactoryBean<Long, Gemstone> gemstonesRegion(Cache gemfireCache,
|
|
|
|
|
RegionAttributes<Long, Gemstone> gemstonesRegionAttributes) {
|
|
|
|
|
|
|
|
|
|
ReplicatedRegionFactoryBean<Long, Gemstone> gemstonesRegion =
|
|
|
|
|
new ReplicatedRegionFactoryBean<Long, Gemstone>();
|
|
|
|
|
new ReplicatedRegionFactoryBean<Long, Gemstone>();
|
|
|
|
|
|
|
|
|
|
gemstonesRegion.setAttributes(gemstonesRegionAttributes);
|
|
|
|
|
gemstonesRegion.setClose(false);
|
|
|
|
@ -100,7 +101,7 @@ public class SampleDataGemFireApplication {
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
RegionAttributesFactoryBean gemstonesRegionAttributes() {
|
|
|
|
|
RegionAttributesFactoryBean gemstonesRegionAttributes =
|
|
|
|
|
new RegionAttributesFactoryBean();
|
|
|
|
|
new RegionAttributesFactoryBean();
|
|
|
|
|
|
|
|
|
|
gemstonesRegionAttributes.setKeyConstraint(Long.class);
|
|
|
|
|
gemstonesRegionAttributes.setValueConstraint(Gemstone.class);
|
|
|
|
|