Skip to content

Commit

Permalink
Showcase JSR-107 support
Browse files Browse the repository at this point in the history
This commit changes the guide so that it uses JSR-107 instead of
Spring's annotations. As shown by this commit, adding a couple of
dependencies to the project is enough to start using the JCache
annotations.
  • Loading branch information
snicoll committed Jun 12, 2014
1 parent 85aafb4 commit 32fea97
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
10 changes: 9 additions & 1 deletion complete/build.gradle
Expand Up @@ -2,6 +2,7 @@ buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
Expand All @@ -14,6 +15,11 @@ apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

ext {
springVersion = "4.1.0.BUILD-SNAPSHOT"
jcacheVersion = "1.0.0"
}

jar {
baseName = 'gs-caching'
version = '0.1.0'
Expand All @@ -27,7 +33,9 @@ repositories {

dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-context")
compile("org.springframework:spring-context:${springVersion}")
compile("org.springframework:spring-context-support:${springVersion}")
compile("javax.cache:cache-api:${jcacheVersion}")
}

task wrapper(type: Wrapper) {
Expand Down
18 changes: 18 additions & 0 deletions complete/pom.xml
Expand Up @@ -22,13 +22,24 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>hello.Application</start-class>

<spring.version>4.1.0.BUILD-SNAPSHOT</spring.version>
</properties>

<build>
Expand All @@ -48,6 +59,13 @@
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
Expand Down
4 changes: 2 additions & 2 deletions complete/src/main/java/hello/SimpleBookRepository.java
@@ -1,11 +1,11 @@
package hello;

import org.springframework.cache.annotation.Cacheable;
import javax.cache.annotation.CacheResult;

public class SimpleBookRepository implements BookRepository {

@Override
@Cacheable("books")
@CacheResult(cacheName = "books")
public Book getByIsbn(String isbn) {
simulateSlowService();
return new Book(isbn, "Some book");
Expand Down
10 changes: 9 additions & 1 deletion initial/build.gradle
Expand Up @@ -2,6 +2,7 @@ buildscript {
repositories {
mavenLocal()
mavenCentral()
maven { url "http://repo.spring.io/libs-snapshot" }
maven { url "http://repo.spring.io/libs-release" }
}
dependencies {
Expand All @@ -14,6 +15,11 @@ apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

ext {
springVersion = "4.1.0.BUILD-SNAPSHOT"
jcacheVersion = "1.0.0"
}

jar {
baseName = 'gs-caching'
version = '0.1.0'
Expand All @@ -27,7 +33,9 @@ repositories {

dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-context")
compile("org.springframework:spring-context:${springVersion}")
compile("org.springframework:spring-context-support:${springVersion}")
compile("javax.cache:cache-api:${jcacheVersion}")
}

task wrapper(type: Wrapper) {
Expand Down
18 changes: 18 additions & 0 deletions initial/pom.xml
Expand Up @@ -22,13 +22,24 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<properties>
<!-- use UTF-8 for everything -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<start-class>hello.Application</start-class>

<spring.version>4.1.0.BUILD-SNAPSHOT</spring.version>
</properties>

<build>
Expand All @@ -48,6 +59,13 @@
<id>spring-releases</id>
<url>http://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>spring-snapshots</id>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
Expand Down

0 comments on commit 32fea97

Please sign in to comment.