diff --git a/spring-geode-samples/caching/look-aside/spring-geode-samples-caching-lookaside.gradle b/spring-geode-samples/caching/look-aside/spring-geode-samples-caching-lookaside.gradle new file mode 100644 index 00000000..c2767a1d --- /dev/null +++ b/spring-geode-samples/caching/look-aside/spring-geode-samples-caching-lookaside.gradle @@ -0,0 +1,24 @@ +apply plugin: 'io.spring.convention.spring-sample-boot' + +description = "Spring Geode Sample demonstrating Spring's Cache Abstraction using Apache Geode as the caching provider." + +dependencies { + + compile project(":spring-geode-starter") + + compile ("org.springframework.boot:spring-boot-starter-web") { + exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" + } + + runtime "javax.cache.cache-api" + runtime "org.springframework.shell:spring-shell" + + runtime ("org.springframework.boot:spring-boot-starter-jetty") { + exclude group: "org.apache.logging.log4j", module: "log4j-to-slf4j" + } + +} + +bootJar { + mainClassName = 'example.app.temp.geode.client.BootGeodeClientApplication' +} diff --git a/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/BootGeodeLookAsideCachingApplication.java b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/BootGeodeLookAsideCachingApplication.java new file mode 100644 index 00000000..d60efef3 --- /dev/null +++ b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/BootGeodeLookAsideCachingApplication.java @@ -0,0 +1,39 @@ +/* + * Copyright 2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package example.app.caching.lookaside; + +import org.springframework.boot.WebApplicationType; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; + +/** + * The BootGeodeLookAsideCachingApplication class... + * + * @author John Blum + * @since 1.0.0 + */ +@SpringBootApplication +public class BootGeodeLookAsideCachingApplication { + + public static void main(String[] args) { + + new SpringApplicationBuilder(BootGeodeLookAsideCachingApplication.class) + .web(WebApplicationType.SERVLET) + .build() + .run(args); + } +} diff --git a/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/config/GeodeConfiguration.java b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/config/GeodeConfiguration.java new file mode 100644 index 00000000..09a69a7e --- /dev/null +++ b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/config/GeodeConfiguration.java @@ -0,0 +1,36 @@ +/* + * Copyright 2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package example.app.caching.lookaside.config; + +import org.apache.geode.cache.client.ClientRegionShortcut; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.gemfire.config.annotation.EnableCachingDefinedRegions; +import org.springframework.data.gemfire.config.annotation.EnableLogging; + +/** + * The GeodeConfiguration class... + * + * @author John Blum + * @since 1.0.0 + */ +@SuppressWarnings("unused") +// tag::class[] +@Configuration +@EnableLogging(logLevel = "error") +@EnableCachingDefinedRegions(clientRegionShortcut = ClientRegionShortcut.LOCAL) +public class GeodeConfiguration { } +// end::class[] diff --git a/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/contoller/CounterController.java b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/contoller/CounterController.java new file mode 100644 index 00000000..b046cc84 --- /dev/null +++ b/spring-geode-samples/caching/look-aside/src/main/java/example/app/caching/lookaside/contoller/CounterController.java @@ -0,0 +1,69 @@ +/* + * Copyright 2019 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +package example.app.caching.lookaside.contoller; + +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import example.app.caching.lookaside.service.CounterService; + +/** + * The CounterController class... + * + * @author John Blum + * @since 1.0.0 + */ +@SuppressWarnings("unused") +// tag::class[] +@RestController +public class CounterController { + + private static final String HEADER_ONE = "