Add Asciidoc tags to the Multi-Site Caching example source code for documentation (guide) purposes.
Resolves gh-80.
This commit is contained in:
@@ -34,6 +34,7 @@ import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRe
|
||||
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@SpringBootApplication
|
||||
@SuppressWarnings("unused")
|
||||
public class BootGeodeMultiSiteCachingClientApplication {
|
||||
@@ -47,3 +48,4 @@ public class BootGeodeMultiSiteCachingClientApplication {
|
||||
static class GeodeClientConfiguration { }
|
||||
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
@@ -32,6 +32,7 @@ import lombok.ToString;
|
||||
* @see org.springframework.data.gemfire.mapping.annotation.Region
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@Region("Customers")
|
||||
@EqualsAndHashCode
|
||||
@ToString(of = "name")
|
||||
@@ -45,3 +46,4 @@ public class Customer {
|
||||
private String name;
|
||||
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
@@ -42,6 +42,7 @@ import example.app.caching.multisite.client.util.ThreadUtils;
|
||||
* @see example.app.caching.multisite.client.model.Customer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@Service
|
||||
public class CustomerService {
|
||||
|
||||
@@ -53,12 +54,14 @@ public class CustomerService {
|
||||
|
||||
private volatile Long sleepInSeconds;
|
||||
|
||||
// tag::find-by-name[]
|
||||
@Cacheable("CustomersByName")
|
||||
public Customer findBy(String name) {
|
||||
setCacheMiss();
|
||||
ThreadUtils.safeSleep(name, Duration.ofSeconds(getSleepInSeconds()));
|
||||
return Customer.newCustomer(this.customerId.incrementAndGet(), name);
|
||||
}
|
||||
// end::find-by-name[]
|
||||
|
||||
public boolean isCacheMiss() {
|
||||
return this.cacheMiss.compareAndSet(true, false);
|
||||
@@ -79,3 +82,4 @@ public class CustomerService {
|
||||
this.sleepInSeconds = seconds;
|
||||
}
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
@@ -37,6 +37,7 @@ import example.app.caching.multisite.client.service.CustomerService;
|
||||
* @see example.app.caching.multisite.client.service.CustomerService
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@RestController
|
||||
public class CustomerController {
|
||||
|
||||
@@ -46,12 +47,14 @@ public class CustomerController {
|
||||
@Autowired
|
||||
private Environment environment;
|
||||
|
||||
// tag::rest-api-endpoint[]
|
||||
@GetMapping("/customers/{name}")
|
||||
public CustomerHolder searchBy(@PathVariable String name) {
|
||||
|
||||
return CustomerHolder.from(this.customerService.findBy(name))
|
||||
.setCacheMiss(this.customerService.isCacheMiss());
|
||||
}
|
||||
// end::rest-api-endpoint[]
|
||||
|
||||
@GetMapping("/ping")
|
||||
public String pingPong() {
|
||||
@@ -97,3 +100,4 @@ public class CustomerController {
|
||||
}
|
||||
}
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
@@ -77,6 +77,7 @@ import example.app.caching.multisite.client.model.Customer;
|
||||
* @see org.springframework.data.gemfire.wan.GatewaySenderFactoryBean
|
||||
* @since 1.3.0
|
||||
*/
|
||||
// tag::class[]
|
||||
@SpringBootApplication
|
||||
@SuppressWarnings("unused")
|
||||
public class BootGeodeMultiSiteCachingServerApplication {
|
||||
@@ -97,6 +98,7 @@ public class BootGeodeMultiSiteCachingServerApplication {
|
||||
.run(args);
|
||||
}
|
||||
|
||||
// tag::geode-server-configuration[]
|
||||
@CacheServerApplication(name = "BootGeodeMultiSiteCachingServerApplication", port = 0)
|
||||
static class GeodeServerConfiguration {
|
||||
|
||||
@@ -113,6 +115,7 @@ public class BootGeodeMultiSiteCachingServerApplication {
|
||||
return customersByName;
|
||||
}
|
||||
|
||||
// tag::server-application-runner[]
|
||||
@Bean
|
||||
ApplicationRunner geodeClusterObjectsBootstrappedAssertionRunner(Environment environment, Cache cache,
|
||||
Region<?, ?> customersByName, GatewayReceiver gatewayReceiver, GatewaySender gatewaySender) {
|
||||
@@ -140,14 +143,19 @@ public class BootGeodeMultiSiteCachingServerApplication {
|
||||
environment.getProperty("spring.application.name", "UNKNOWN"));
|
||||
};
|
||||
}
|
||||
// end::server-application-runner[]
|
||||
}
|
||||
// end::geode-server-configuration[]
|
||||
|
||||
// tag::locator-manager-configuration[]
|
||||
@Configuration
|
||||
@EnableLocator
|
||||
@EnableManager(start = true)
|
||||
@Profile("locator-manager")
|
||||
static class GeodeLocatorManagerConfiguration { }
|
||||
// end::locator-manager-configuration[]
|
||||
|
||||
// tag::gateway-receiver-configuration[]
|
||||
@Configuration
|
||||
@Profile("gateway-receiver")
|
||||
static class GeodeGatewayReceiverConfiguration {
|
||||
@@ -164,7 +172,9 @@ public class BootGeodeMultiSiteCachingServerApplication {
|
||||
return gatewayReceiver;
|
||||
}
|
||||
}
|
||||
// end::gateway-receiver-configuration[]
|
||||
|
||||
// tag::gateway-sender-configuration[]
|
||||
@Configuration
|
||||
@Profile("gateway-sender")
|
||||
static class GeodeGatewaySenderConfiguration {
|
||||
@@ -196,4 +206,6 @@ public class BootGeodeMultiSiteCachingServerApplication {
|
||||
};
|
||||
}
|
||||
}
|
||||
// end::gateway-sender-configuration[]
|
||||
}
|
||||
// end::class[]
|
||||
|
||||
Reference in New Issue
Block a user