Formate source code for documentation purposes.
This commit is contained in:
@@ -28,13 +28,20 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
import example.app.caching.near.client.model.Person;
|
||||
|
||||
/**
|
||||
* Spring Boot application demonstrating Spring's Cache Abstraction with Apache Geode as the caching provider
|
||||
* for {@literal Near Caching}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.springframework.boot.ApplicationRunner
|
||||
* @see org.springframework.boot.SpringApplication
|
||||
* @see org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see example.app.caching.near.client.model.Person
|
||||
* @since 1.1.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@@ -47,7 +54,7 @@ public class BootGeodeNearCachingClientCacheApplication {
|
||||
|
||||
// tag::application-runner[]
|
||||
@Bean
|
||||
public ApplicationRunner runner(@Qualifier("YellowPages") Region<?, ?> yellowPages) {
|
||||
public ApplicationRunner runner(@Qualifier("YellowPages") Region<String, Person> yellowPages) {
|
||||
|
||||
return args -> {
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ public class GeodeConfiguration {
|
||||
@SuppressWarnings("unchecked")
|
||||
public void configure(String beanName, ClientRegionFactoryBean<?, ?> clientRegion) {
|
||||
|
||||
CacheListener subscriptionCacheListener = new AbstractCommonEventProcessingCacheListener() {
|
||||
CacheListener subscriptionCacheListener =
|
||||
new AbstractCommonEventProcessingCacheListener() {
|
||||
|
||||
@Override
|
||||
protected void processEntryEvent(EntryEvent event, EntryEventType eventType) {
|
||||
|
||||
@@ -21,17 +21,19 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import example.app.caching.near.client.service.YellowPagesService;
|
||||
import example.app.caching.near.client.model.Person;
|
||||
import example.app.caching.near.client.service.YellowPagesService;
|
||||
|
||||
/**
|
||||
* Spring {@link RestController} class for implementing the UI to the Yellow Pages application.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.web.bind.annotation.GetMapping
|
||||
* @see org.springframework.web.bind.annotation.PathVariable
|
||||
* @see org.springframework.web.bind.annotation.RequestParam
|
||||
* @see org.springframework.web.bind.annotation.RestController
|
||||
* @see Person
|
||||
* @see YellowPagesService
|
||||
* @see example.app.caching.near.client.model.Person
|
||||
* @see example.app.caching.near.client.service.YellowPagesService
|
||||
* @since 1.1.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@@ -67,8 +69,8 @@ public class YellowPagesController {
|
||||
|
||||
@GetMapping("/yellow-pages/{name}/update")
|
||||
public String update(@PathVariable("name") String name,
|
||||
@RequestParam(name = "email", required = false) String email,
|
||||
@RequestParam(name = "phoneNumber", required = false) String phoneNumber) {
|
||||
@RequestParam(name = "email", required = false) String email,
|
||||
@RequestParam(name = "phoneNumber", required = false) String phoneNumber) {
|
||||
|
||||
Person person = this.yellowPages.save(this.yellowPages.find(name), email, phoneNumber);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import example.app.caching.near.client.service.support.AbstractCacheableService;
|
||||
import example.app.caching.near.client.model.Person;
|
||||
import example.app.caching.near.client.service.support.AbstractCacheableService;
|
||||
import example.app.caching.near.client.service.support.EmailGenerator;
|
||||
import example.app.caching.near.client.service.support.PhoneNumberGenerator;
|
||||
|
||||
@@ -31,18 +31,20 @@ import example.app.caching.near.client.service.support.PhoneNumberGenerator;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.springframework.cache.annotation.Cacheable
|
||||
* @see org.springframework.cache.annotation.CachePut
|
||||
* @see org.springframework.cache.annotation.CacheEvict
|
||||
* @see org.springframework.stereotype.Service
|
||||
* @see Person
|
||||
* @see AbstractCacheableService
|
||||
* @see EmailGenerator
|
||||
* @see PhoneNumberGenerator
|
||||
* @see example.app.caching.near.client.model.Person
|
||||
* @see example.app.caching.near.client.service.support.AbstractCacheableService
|
||||
* @see example.app.caching.near.client.service.support.EmailGenerator
|
||||
* @see example.app.caching.near.client.service.support.PhoneNumberGenerator
|
||||
* @since 1.1.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@Service
|
||||
public class YellowPagesService extends AbstractCacheableService {
|
||||
|
||||
@Cacheable(cacheNames = "YellowPages", key = "#name")
|
||||
@Cacheable("YellowPages")
|
||||
public Person find(String name) {
|
||||
|
||||
this.cacheMiss.set(true);
|
||||
|
||||
@@ -44,9 +44,15 @@ import example.app.caching.near.client.model.Person;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
* @see org.springframework.boot.builder.SpringApplicationBuilder
|
||||
* @see org.springframework.context.annotation.Bean
|
||||
* @see org.springframework.context.annotation.Configuration
|
||||
* @see org.springframework.context.annotation.Profile
|
||||
* @see org.springframework.data.gemfire.RegionAttributesFactoryBean
|
||||
* @see org.springframework.data.gemfire.ReplicatedRegionFactoryBean
|
||||
* @see org.springframework.data.gemfire.config.annotation.CacheServerApplication
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnableLocator
|
||||
* @see org.springframework.data.gemfire.config.annotation.EnableManager
|
||||
@@ -68,15 +74,15 @@ public class BootGeodeNearCachingCacheServerApplication {
|
||||
|
||||
// tag::application-runner[]
|
||||
@Bean
|
||||
ApplicationRunner runner(@Qualifier("YellowPages") Region<String, Person> yellowPagesRegion) {
|
||||
ApplicationRunner runner(@Qualifier("YellowPages") Region<String, Person> yellowPages) {
|
||||
|
||||
return args -> {
|
||||
|
||||
assertThat(yellowPagesRegion).isNotNull();
|
||||
assertThat(yellowPagesRegion.getName()).isEqualTo("YellowPages");
|
||||
assertThat(yellowPagesRegion.getAttributes()).isNotNull();
|
||||
assertThat(yellowPagesRegion.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(yellowPagesRegion.getAttributes().getEnableSubscriptionConflation()).isTrue();
|
||||
assertThat(yellowPages).isNotNull();
|
||||
assertThat(yellowPages.getName()).isEqualTo("YellowPages");
|
||||
assertThat(yellowPages.getAttributes()).isNotNull();
|
||||
assertThat(yellowPages.getAttributes().getDataPolicy()).isEqualTo(DataPolicy.REPLICATE);
|
||||
assertThat(yellowPages.getAttributes().getEnableSubscriptionConflation()).isTrue();
|
||||
|
||||
};
|
||||
}
|
||||
@@ -87,10 +93,10 @@ public class BootGeodeNearCachingCacheServerApplication {
|
||||
static class GeodeConfiguration {
|
||||
|
||||
@Bean("YellowPages")
|
||||
public ReplicatedRegionFactoryBean<Object, Object> yellowPagesRegion(GemFireCache gemfireCache,
|
||||
@Qualifier("YellowPagesAttributes") RegionAttributes<Object, Object> exampleAttributes) {
|
||||
public ReplicatedRegionFactoryBean<String, Person> yellowPagesRegion(GemFireCache gemfireCache,
|
||||
@Qualifier("YellowPagesAttributes") RegionAttributes<String, Person> exampleAttributes) {
|
||||
|
||||
ReplicatedRegionFactoryBean<Object, Object> yellowPagesRegion =
|
||||
ReplicatedRegionFactoryBean<String, Person> yellowPagesRegion =
|
||||
new ReplicatedRegionFactoryBean<>();
|
||||
|
||||
yellowPagesRegion.setAttributes(exampleAttributes);
|
||||
@@ -102,9 +108,9 @@ public class BootGeodeNearCachingCacheServerApplication {
|
||||
}
|
||||
|
||||
@Bean("YellowPagesAttributes")
|
||||
public RegionAttributesFactoryBean<Object, Object> exampleRegionAttributes() {
|
||||
public RegionAttributesFactoryBean<String, Person> exampleRegionAttributes() {
|
||||
|
||||
RegionAttributesFactoryBean<Object, Object> yellowPagesRegionAttributes =
|
||||
RegionAttributesFactoryBean<String, Person> yellowPagesRegionAttributes =
|
||||
new RegionAttributesFactoryBean<>();
|
||||
|
||||
yellowPagesRegionAttributes.setEnableSubscriptionConflation(true);
|
||||
|
||||
Reference in New Issue
Block a user