diff --git a/build.gradle b/build.gradle
index 71dfd882..614b3efb 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,14 +1,14 @@
buildscript {
- repositories {
- maven { url "https://repo.spring.io/plugins-release" }
- }
- dependencies {
- classpath("org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3")
- classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
- classpath("org.springframework.build.gradle:spring-io-plugin:0.0.3.RELEASE")
- classpath('me.champeau.gradle:gradle-javadoc-hotfix-plugin:0.1')
- classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
- }
+ repositories {
+ maven { url "https://repo.spring.io/plugins-release" }
+ }
+ dependencies {
+ classpath("org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3")
+ classpath("org.springframework.build.gradle:propdeps-plugin:0.0.7")
+ classpath("org.springframework.build.gradle:spring-io-plugin:0.0.3.RELEASE")
+ classpath('me.champeau.gradle:gradle-javadoc-hotfix-plugin:0.1')
+ classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.2'
+ }
}
group = 'org.springframework.session'
@@ -27,37 +27,37 @@ apply plugin: 'base'
sonarRunner {
- sonarProperties {
- property "sonar.java.coveragePlugin", "jacoco"
- property "sonar.projectName", "Spring Session"
- property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
- property "sonar.links.homepage", 'https://github.com/spring-projects/spring-session'
- property "sonar.links.ci", 'https://build.spring.io/browse/SESSION'
- property "sonar.links.issue", 'https://github.com/spring-projects/spring-session/issues'
- property "sonar.links.scm", 'https://github.com/spring-projects/spring-session'
- property "sonar.links.scm_dev", 'https://github.com/spring-projects/spring-session.git'
- property "sonar.java.coveragePlugin", "jacoco"
- }
+ sonarProperties {
+ property "sonar.java.coveragePlugin", "jacoco"
+ property "sonar.projectName", "Spring Session"
+ property "sonar.jacoco.reportPath", "${buildDir.name}/jacoco.exec"
+ property "sonar.links.homepage", 'https://github.com/spring-projects/spring-session'
+ property "sonar.links.ci", 'https://build.spring.io/browse/SESSION'
+ property "sonar.links.issue", 'https://github.com/spring-projects/spring-session/issues'
+ property "sonar.links.scm", 'https://github.com/spring-projects/spring-session'
+ property "sonar.links.scm_dev", 'https://github.com/spring-projects/spring-session.git'
+ property "sonar.java.coveragePlugin", "jacoco"
+ }
}
task configDocsZip(dependsOn: [':docs:asciidoctor',':spring-session:javadoc']) << {
- project.tasks.docsZip.from(project(':docs').asciidoctor) {
- into('reference')
- }
- project.tasks.docsZip.from(project(':spring-session').javadoc) {
- into('api')
- }
+ project.tasks.docsZip.from(project(':docs').asciidoctor) {
+ into('reference')
+ }
+ project.tasks.docsZip.from(project(':spring-session').javadoc) {
+ into('api')
+ }
}
task docsZip(type: Zip, dependsOn: 'configDocsZip') {
- group = "Distribution"
- baseName = "spring-session"
- classifier = "docs"
- description = "Builds -${classifier} archive containing api and reference " +
- "for deployment."
+ group = "Distribution"
+ baseName = "spring-session"
+ classifier = "docs"
+ description = "Builds -${classifier} archive containing api and reference " +
+ "for deployment."
}
artifacts {
- archives docsZip
+ archives docsZip
}
\ No newline at end of file
diff --git a/docs/build.gradle b/docs/build.gradle
index 69bc7f44..472a6075 100644
--- a/docs/build.gradle
+++ b/docs/build.gradle
@@ -8,37 +8,37 @@ asciidoctorj {
tasks.findByPath("artifactoryPublish")?.enabled = false
dependencies {
- testCompile project(':spring-session'),
- "org.springframework.data:spring-data-redis:$springDataRedisVersion",
- "org.springframework:spring-websocket:${springVersion}",
- "org.springframework:spring-messaging:${springVersion}",
- 'junit:junit:4.11',
- 'org.mockito:mockito-core:1.9.5',
- "org.springframework:spring-test:$springVersion",
- 'org.easytesting:fest-assert:1.4',
- "redis.clients:jedis:2.4.1"
+ testCompile project(':spring-session'),
+ "org.springframework.data:spring-data-redis:$springDataRedisVersion",
+ "org.springframework:spring-websocket:${springVersion}",
+ "org.springframework:spring-messaging:${springVersion}",
+ 'junit:junit:4.11',
+ 'org.mockito:mockito-core:1.9.5',
+ "org.springframework:spring-test:$springVersion",
+ 'org.easytesting:fest-assert:1.4',
+ "redis.clients:jedis:2.4.1"
}
asciidoctor {
- def ghTag = snapshotBuild ? 'master' : project.version
- def ghUrl = "https://github.com/spring-projects/spring-session/tree/$ghTag/"
- attributes 'version-snapshot': snapshotBuild,
- 'version-milestone': milestoneBuild,
- 'version-release': releaseBuild,
- 'gh-url': ghUrl,
- 'gh-samples-url': "$ghUrl/samples/",
- 'download-url' : "https://github.com/spring-projects/spring-session/archive/${ghTag}.zip",
- 'spring-session-version' : version,
- 'spring-version' : springVersion,
- 'docs-test-dir' : rootProject.projectDir.path + '/docs/src/test/java/',
- 'samples-dir' : rootProject.projectDir.path + '/samples/',
+ def ghTag = snapshotBuild ? 'master' : project.version
+ def ghUrl = "https://github.com/spring-projects/spring-session/tree/$ghTag/"
+ attributes 'version-snapshot': snapshotBuild,
+ 'version-milestone': milestoneBuild,
+ 'version-release': releaseBuild,
+ 'gh-url': ghUrl,
+ 'gh-samples-url': "$ghUrl/samples/",
+ 'download-url' : "https://github.com/spring-projects/spring-session/archive/${ghTag}.zip",
+ 'spring-session-version' : version,
+ 'spring-version' : springVersion,
+ 'docs-test-dir' : rootProject.projectDir.path + '/docs/src/test/java/',
+ 'samples-dir' : rootProject.projectDir.path + '/samples/',
- 'source-highlighter' : 'coderay',
- 'imagesdir':'./images',
- 'icons': 'font',
- 'sectanchors':'',
- 'idprefix':'',
- 'idseparator':'-',
- 'docinfo1':'true',
- 'revnumber' : project.version
+ 'source-highlighter' : 'coderay',
+ 'imagesdir':'./images',
+ 'icons': 'font',
+ 'sectanchors':'',
+ 'idprefix':'',
+ 'idseparator':'-',
+ 'docinfo1':'true',
+ 'revnumber' : project.version
}
\ No newline at end of file
diff --git a/docs/src/docs/asciidoc/guides/boot.adoc b/docs/src/docs/asciidoc/guides/boot.adoc
index 3335c22f..87f08bbd 100644
--- a/docs/src/docs/asciidoc/guides/boot.adoc
+++ b/docs/src/docs/asciidoc/guides/boot.adoc
@@ -16,14 +16,14 @@ If you are using Maven, ensure to add the following dependencies:
[subs="verbatim,attributes"]
----
-
+
-
- org.springframework.session
- spring-session-data-redis
- {spring-session-version}
- pom
-
+
+ org.springframework.session
+ spring-session-data-redis
+ {spring-session-version}
+ pom
+
----
@@ -36,12 +36,12 @@ Ensure you have the following in your pom.xml:
----
-
+
-
- spring-snapshot
- https://repo.spring.io/libs-snapshot
-
+
+ spring-snapshot
+ https://repo.spring.io/libs-snapshot
+
----
endif::[]
@@ -54,8 +54,8 @@ Ensure you have the following in your pom.xml:
[source,xml]
----
- spring-milestone
- https://repo.spring.io/libs-milestone
+ spring-milestone
+ https://repo.spring.io/libs-milestone
----
endif::[]
@@ -69,7 +69,7 @@ Add the following Spring Configuration:
[source,java]
----
-include::{samples-dir}boot/src/main/java/sample/config/HttpSessionConfig.java[]
+include::{samples-dir}boot/src/main/java/sample/config/HttpSessionConfig.java[tags=class]
----
<1> The `@EnableRedisHttpSession` annotation creates a Spring Bean with the name of `springSessionRepositoryFilter` that implements Filter.
@@ -111,7 +111,9 @@ The boot Sample Application demonstrates how to use Spring Session to transparen
You can run the sample by obtaining the {download-url}[source code] and invoking the following command:
- $ ./gradlew :samples:boot:bootRun
+----
+$ ./gradlew :samples:boot:bootRun
+----
You should now be able to access the application at http://localhost:8080/
@@ -139,12 +141,12 @@ Go ahead and view the cookies (click for help with https://developer.chrome.com/
If you like, you can easily remove the session using redis-cli. For example, on a Linux based system you can type:
- $ redis-cli keys '*' | xargs redis-cli del
+ $ redis-cli keys '*' | xargs redis-cli del
TIP: The Redis documentation has instructions for http://redis.io/topics/quickstart[installing redis-cli].
Alternatively, you can also delete the explicit key. Enter the following into your terminal ensuring to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your SESSION cookie:
- $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
+ $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
Now visit the application at http://localhost:8080/ and observe that we are no longer authenticated.
diff --git a/docs/src/docs/asciidoc/guides/httpsession.adoc b/docs/src/docs/asciidoc/guides/httpsession.adoc
index edae9f6e..9947c4ae 100644
--- a/docs/src/docs/asciidoc/guides/httpsession.adoc
+++ b/docs/src/docs/asciidoc/guides/httpsession.adoc
@@ -15,19 +15,19 @@ If you are using Maven, ensure to add the following dependencies:
[subs="verbatim,attributes"]
----
-
+
-
- org.springframework.session
- spring-session-data-redis
- {spring-session-version}
- pom
-
-
- org.springframework
- spring-web
- {spring-version}
-
+
+ org.springframework.session
+ spring-session-data-redis
+ {spring-session-version}
+ pom
+
+
+ org.springframework
+ spring-web
+ {spring-version}
+
----
@@ -40,12 +40,12 @@ Ensure you have the following in your pom.xml:
----
-
+
-
- spring-snapshot
- https://repo.spring.io/libs-snapshot
-
+
+ spring-snapshot
+ https://repo.spring.io/libs-snapshot
+
----
endif::[]
@@ -58,8 +58,8 @@ Ensure you have the following in your pom.xml:
[source,xml]
----
- spring-milestone
- https://repo.spring.io/libs-milestone
+ spring-milestone
+ https://repo.spring.io/libs-milestone
----
endif::[]
@@ -75,7 +75,7 @@ Add the following Spring Configuration:
[source,java]
----
-include::{samples-dir}httpsession/src/main/java/sample/Config.java[]
+include::{samples-dir}httpsession/src/main/java/sample/Config.java[tags=class]
----
<1> We import an embedded Redis Server so that there is no need to start up Redis external of our application.
@@ -100,7 +100,7 @@ You can find an example below:
.src/main/java/sample/Initializer.java
[source,java]
----
-include::{samples-dir}httpsession/src/main/java/sample/Initializer.java[]
+include::{samples-dir}httpsession/src/main/java/sample/Initializer.java[tags=class]
----
NOTE: The name of our class (Initializer) does not matter. What is important is that we extend `AbstractHttpSessionApplicationInitializer`.
@@ -120,7 +120,9 @@ This ensures that the Spring Bean by the name `springSessionRepositoryFilter` is
You can run the sample by obtaining the {download-url}[source code] and invoking the following command:
- $ ./gradlew :samples:httpsession:tomcatRun
+----
+$ ./gradlew :samples:httpsession:tomcatRun
+----
You should now be able to access the application at http://localhost:8080/
@@ -140,7 +142,7 @@ We interact with the standard `HttpSession` in the `SessionServlet` shown below:
.src/main/java/sample/SessionServlet.java
[source,java]
----
-include::{samples-dir}httpsession/src/main/java/sample/SessionServlet.java[]
+include::{samples-dir}httpsession/src/main/java/sample/SessionServlet.java[tags=class]
----
Instead of using Tomcat's `HttpSession`, we are actually persisting the values in Redis.
@@ -149,12 +151,12 @@ Go ahead and view the cookies (click for help with https://developer.chrome.com/
If you like, you can easily remove the session using redis-cli. For example, on a Linux based system you can type:
- $ redis-cli keys '*' | xargs redis-cli del
+ $ redis-cli keys '*' | xargs redis-cli del
TIP: The Redis documentation has instructions for http://redis.io/topics/quickstart[installing redis-cli].
Alternatively, you can also delete the explicit key. Enter the following into your terminal ensuring to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your SESSION cookie:
- $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
+ $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
Now visit the application at http://localhost:8080/ and observe that the attribute we added is no longer displayed.
\ No newline at end of file
diff --git a/docs/src/docs/asciidoc/guides/rest.adoc b/docs/src/docs/asciidoc/guides/rest.adoc
index d69cd5e2..668371d3 100644
--- a/docs/src/docs/asciidoc/guides/rest.adoc
+++ b/docs/src/docs/asciidoc/guides/rest.adoc
@@ -15,19 +15,19 @@ If you are using Maven, ensure to add the following dependencies:
[subs="verbatim,attributes"]
----
-
+
-
- org.springframework.session
- spring-session-data-redis
- {spring-session-version}
- pom
-
-
- org.springframework
- spring-web
- {spring-version}
-
+
+ org.springframework.session
+ spring-session-data-redis
+ {spring-session-version}
+ pom
+
+
+ org.springframework
+ spring-web
+ {spring-version}
+
----
@@ -40,12 +40,12 @@ Ensure you have the following in your pom.xml:
----
-
+
-
- spring-snapshot
- https://repo.spring.io/libs-snapshot
-
+
+ spring-snapshot
+ https://repo.spring.io/libs-snapshot
+
----
endif::[]
@@ -58,8 +58,8 @@ Ensure you have the following in your pom.xml:
[source,xml]
----
- spring-milestone
- https://repo.spring.io/libs-milestone
+ spring-milestone
+ https://repo.spring.io/libs-milestone
----
endif::[]
@@ -75,7 +75,7 @@ Add the following Spring Configuration:
[source,java]
----
-include::{samples-dir}rest/src/main/java/sample/HttpSessionConfig.java[]
+include::{samples-dir}rest/src/main/java/sample/HttpSessionConfig.java[tags=class]
----
<1> We import an embedded Redis Server so that there is no need to start up Redis external of our application.
@@ -107,7 +107,7 @@ Fortunately, Spring Session provides a utility class named `AbstractHttpSessionA
.src/main/java/sample/Initializer.java
[source,java]
----
-include::{samples-dir}rest/src/main/java/sample/Initializer.java[]
+include::{samples-dir}rest/src/main/java/sample/Initializer.java[tags=class]
----
NOTE: The name of our class (Initializer) does not matter. What is important is that we extend `AbstractHttpSessionApplicationInitializer`.
@@ -121,7 +121,9 @@ NOTE: The name of our class (Initializer) does not matter. What is important is
You can run the sample by obtaining the {download-url}[source code] and invoking the following command:
- $ ./gradlew :samples:rest:tomcatRun
+----
+$ ./gradlew :samples:rest:tomcatRun
+----
You should now be able to access the application at http://localhost:8080/
@@ -129,14 +131,14 @@ You should now be able to access the application at http://localhost:8080/
Try using the application. Use your favorite REST client to request http://localhost:8080/
- $ curl -v http://localhost:8080/
+ $ curl -v http://localhost:8080/
Observe that we are prompted for basic authentication. Provide the following information for the username and password:
* **Username** *user*
* **Password** *password*
- $ curl -v http://localhost:8080/ -u user:password
+$ curl -v http://localhost:8080/ -u user:password
In the output you will notice the following:
@@ -156,13 +158,13 @@ Specifically, we notice the following things about our response:
We can now use the *x-auth-token* to make another request without providing the username and password again. For example, the following outputs the the username just as before:
- $ curl -v http://localhost:8080/ -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
+ $ curl -v http://localhost:8080/ -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
The only difference is that the session id is not provided in the response headers because we are reusing an existing session.
If we invalidate the session, then the x-auth-token is displayed in the response with an empty value. For example, the following will invalidate our session:
- $ curl -v http://localhost:8080/logout -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
+ $ curl -v http://localhost:8080/logout -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
You will see in the output that the x-auth-token provides an empty String indicating that the previous session was invalidated.
@@ -181,7 +183,7 @@ Spring Session creates a header named x-auth-token in your browser that contains
If you like, you can easily see that the session is created in Redis. First create a session using the following:
- $ curl -v http://localhost:8080/ -u user:password
+$ curl -v http://localhost:8080/ -u user:password
In the output you will notice the following:
@@ -195,14 +197,14 @@ x-auth-token: 7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
Now remove the session using redis-cli. For example, on a Linux based system you can type:
- $ redis-cli keys '*' | xargs redis-cli del
+ $ redis-cli keys '*' | xargs redis-cli del
TIP: The Redis documentation has instructions for http://redis.io/topics/quickstart[installing redis-cli].
Alternatively, you can also delete the explicit key. Enter the following into your terminal ensuring to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your SESSION cookie:
- $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
+ $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
We can now use the *x-auth-token* to make another request with the session we deleted and observe we are prompted for a authentication. For example, the following returns an HTTP 401:
- $ curl -v http://localhost:8080/ -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
+ $ curl -v http://localhost:8080/ -H "x-auth-token: 0dc1f6e1-c7f1-41ac-8ce2-32b6b3e57aa3"
diff --git a/docs/src/docs/asciidoc/guides/security.adoc b/docs/src/docs/asciidoc/guides/security.adoc
index 18729334..ce29d878 100644
--- a/docs/src/docs/asciidoc/guides/security.adoc
+++ b/docs/src/docs/asciidoc/guides/security.adoc
@@ -16,19 +16,19 @@ If you are using Maven, ensure to add the following dependencies:
[subs="verbatim,attributes"]
----
-
+
-
- org.springframework.session
- spring-session-data-redis
- {spring-session-version}
- pom
-
-
- org.springframework
- spring-web
- {spring-version}
-
+
+ org.springframework.session
+ spring-session-data-redis
+ {spring-session-version}
+ pom
+
+
+ org.springframework
+ spring-web
+ {spring-version}
+
----
@@ -41,12 +41,12 @@ Ensure you have the following in your pom.xml:
----
-
+
-
- spring-snapshot
- https://repo.spring.io/libs-snapshot
-
+
+ spring-snapshot
+ https://repo.spring.io/libs-snapshot
+
----
endif::[]
@@ -59,8 +59,8 @@ Ensure you have the following in your pom.xml:
[source,xml]
----
- spring-milestone
- https://repo.spring.io/libs-milestone
+spring-milestone
+https://repo.spring.io/libs-milestone
----
endif::[]
@@ -74,7 +74,7 @@ Add the following Spring Configuration:
[source,java]
----
-include::{samples-dir}security/src/main/java/sample/Config.java[]
+include::{samples-dir}security/src/main/java/sample/Config.java[tags=class]
----
<1> We import an embedded Redis Server so that there is no need to start up Redis external of our application.
@@ -97,7 +97,7 @@ Since our application is already loading Spring configuration using our `Securit
.src/main/java/sample/SecurityInitializer.java
[source,java]
----
-include::{samples-dir}security/src/main/java/sample/SecurityInitializer.java[]
+include::{samples-dir}security/src/main/java/sample/SecurityInitializer.java[tags=class]
----
Last we need to ensure that our Servlet Container (i.e. Tomcat) uses our `springSessionRepositoryFilter` for every request.
@@ -109,7 +109,7 @@ You can find an example below:
.src/main/java/sample/Initializer.java
[source,java]
----
-include::{samples-dir}security/src/main/java/sample/Initializer.java[]
+include::{samples-dir}security/src/main/java/sample/Initializer.java[tags=class]
----
NOTE: The name of our class (Initializer) does not matter. What is important is that we extend `AbstractHttpSessionApplicationInitializer`.
@@ -125,7 +125,9 @@ By extending `AbstractHttpSessionApplicationInitializer` we ensure that the Spri
You can run the sample by obtaining the {download-url}[source code] and invoking the following command:
- $ ./gradlew :samples:security:tomcatRun
+----
+$ ./gradlew :samples:security:tomcatRun
+----
You should now be able to access the application at http://localhost:8080/
@@ -151,12 +153,12 @@ Go ahead and view the cookies (click for help with https://developer.chrome.com/
If you like, you can easily remove the session using redis-cli. For example, on a Linux based system you can type:
- $ redis-cli keys '*' | xargs redis-cli del
+ $ redis-cli keys '*' | xargs redis-cli del
TIP: The Redis documentation has instructions for http://redis.io/topics/quickstart[installing redis-cli].
Alternatively, you can also delete the explicit key. Enter the following into your terminal ensuring to replace `7e8383a4-082c-4ffe-a4bc-c40fd3363c5e` with the value of your SESSION cookie:
- $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
+ $ redis-cli del spring:session:sessions:7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
Now visit the application at http://localhost:8080/ and observe that we are no longer authenticated.
\ No newline at end of file
diff --git a/docs/src/docs/asciidoc/guides/users.adoc b/docs/src/docs/asciidoc/guides/users.adoc
index bfed16a6..e95f49aa 100644
--- a/docs/src/docs/asciidoc/guides/users.adoc
+++ b/docs/src/docs/asciidoc/guides/users.adoc
@@ -17,7 +17,9 @@ The users application demonstrates how to allow an application to manage multipl
You can run the sample by obtaining the {download-url}[source code] and invoking the following command:
- $ ./gradlew :samples:users:tomcatRun
+----
+$ ./gradlew :samples:users:tomcatRun
+----
You should now be able to access the application at http://localhost:8080/
@@ -71,7 +73,7 @@ Let's take a look at how Spring Session keeps track of multiple sessions.
Spring Session keeps track of the `HttpSession` by adding a value to a cookie named SESSION.
For example, the SESSION cookie might have a value of:
- 7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
+ 7e8383a4-082c-4ffe-a4bc-c40fd3363c5e
=== Adding a Session
@@ -113,7 +115,7 @@ The URL contains a session alias that either points to an existing unauthenticat
Now our SESSION cookie looks something like this:
- 0 7e8383a4-082c-4ffe-a4bc-c40fd3363c5e 1 1d526d4a-c462-45a4-93d9-84a39b6d44ad
+ 0 7e8383a4-082c-4ffe-a4bc-c40fd3363c5e 1 1d526d4a-c462-45a4-93d9-84a39b6d44ad
Such that:
diff --git a/docs/src/docs/asciidoc/guides/websocket.adoc b/docs/src/docs/asciidoc/guides/websocket.adoc
index a210df5e..b5a37d17 100644
--- a/docs/src/docs/asciidoc/guides/websocket.adoc
+++ b/docs/src/docs/asciidoc/guides/websocket.adoc
@@ -82,7 +82,9 @@ include::{samples-dir}websocket/src/main/java/sample/config/WebSecurityConfig.ja
----
====
- $ ./gradlew :samples:websocket:bootRun
+----
+$ ./gradlew :samples:websocket:bootRun
+----
You should now be able to access the application at http://localhost:8080/
diff --git a/docs/src/docs/asciidoc/index.adoc b/docs/src/docs/asciidoc/index.adoc
index d9b0ea0f..a451b18c 100644
--- a/docs/src/docs/asciidoc/index.adoc
+++ b/docs/src/docs/asciidoc/index.adoc
@@ -106,19 +106,19 @@ It looks something like the following:
----
public class SessionRepositoryRequestWrapper extends HttpServletRequestWrapper {
- public SessionRepositoryRequestWrapper(HttpServletRequest original) {
- super(original);
- }
+ public SessionRepositoryRequestWrapper(HttpServletRequest original) {
+ super(original);
+ }
- public HttpSession getSession() {
- return getSession(true);
- }
+ public HttpSession getSession() {
+ return getSession(true);
+ }
- public HttpSession getSession(boolean createNew) {
- // create an HttpSession implementation from Spring Session
- }
+ public HttpSession getSession(boolean createNew) {
+ // create an HttpSession implementation from Spring Session
+ }
- // ... other methods delegate to the original HttpServletRequest ...
+ // ... other methods delegate to the original HttpServletRequest ...
}
----
@@ -132,15 +132,15 @@ The pseudocode can be found below:
----
public class SessionRepositoryFilter implements Filter {
- public doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
- HttpServletRequest httpRequest = (HttpServletRequest) request;
- SessionRepositoryRequestWrapper customRequest =
- new SessionRepositoryRequestWrapper(httpRequest);
+ public doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
+ HttpServletRequest httpRequest = (HttpServletRequest) request;
+ SessionRepositoryRequestWrapper customRequest =
+ new SessionRepositoryRequestWrapper(httpRequest);
- chain.doFilter(customRequest, response, chain);
- }
+ chain.doFilter(customRequest, response, chain);
+ }
- // ...
+ // ...
}
----
@@ -286,9 +286,9 @@ Each session is stored in Redis as a Hash.
Each session is set and updated using the HMSET command.
An example of how each session is stored can be seen below.
- HMSET spring:session:sessions: creationTime 1404360000000 \
- maxInactiveInterval 1800 lastAccessedTime 1404360000000 \
- sessionAttr: someAttrValue sessionAttr: someAttrValue2
+ HMSET spring:session:sessions: creationTime 1404360000000 \
+ maxInactiveInterval 1800 lastAccessedTime 1404360000000 \
+ sessionAttr: someAttrValue sessionAttr: someAttrValue2
[[api-redisoperationssessionrepository-expiration]]
===== Session Expiration
@@ -296,7 +296,7 @@ An example of how each session is stored can be seen below.
An expiration is associated to each session using the EXPIRE command based upon the RedisOperationsSessionRepository.RedisSession.getMaxInactiveInterval().
For example:
- EXPIRE spring:session:sessions: 1800
+ EXPIRE spring:session:sessions: 1800
Spring Session relies on the expired and delete http://redis.io/topics/notifications[keyspace notifications] from Redis to fire a <>.
It is the `SessionDestroyedEvent` that ensures resources associated with the Session are cleaned up.
@@ -313,8 +313,8 @@ For this reason, each session expiration is also tracked to the nearest minute.
This allows a background task to access the potentially expired sessions to ensure that Redis expired events are fired in a more deterministic fashion.
For example:
- SADD spring:session:expirations:
- EXPIRE spring:session:expirations: 1800
+SADD spring:session:expirations:
+EXPIRE spring:session:expirations: 1800
The background task will then use these mappings to explicitly request each key.
By accessing they key, rather than deleting it, we ensure that Redis deletes the key for us only if the TTL is expired.
@@ -331,8 +331,8 @@ This means if an attribute is written once and read many times we only need to w
For example, assume the session attribute "sessionAttr2" from earlier was updated.
The following would be executed upon saving:
- HMSET spring:session:sessions: sessionAttr: newValue
- EXPIRE spring:session:sessions: 1800
+HMSET spring:session:sessions: sessionAttr: newValue
+EXPIRE spring:session:sessions: 1800
[[api-redisoperationssessionrepository-sessiondestroyedevent]]
==== SessionDestroyedEvent
@@ -405,7 +405,7 @@ include::{indexdoc-tests}[tags=new-mapsessionrepository]
The <> is a complete application demonstrating using Spring Session with Hazelcast.
To run it use the following:
- ./gradlew :samples:hazelcast:tomcatRun
+ ./gradlew :samples:hazelcast:tomcatRun
[[community]]
== Spring Session Community
diff --git a/docs/src/test/java/docs/IndexDocTests.java b/docs/src/test/java/docs/IndexDocTests.java
index d0287417..fdf46914 100644
--- a/docs/src/test/java/docs/IndexDocTests.java
+++ b/docs/src/test/java/docs/IndexDocTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 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
@@ -26,85 +26,85 @@ import static org.fest.assertions.Assertions.assertThat;
* @author Rob Winch
*/
public class IndexDocTests {
- static final String ATTR_USER = "user";
+ static final String ATTR_USER = "user";
- @Test
- public void repositoryDemo() {
- ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo();
- demo.repository = new MapSessionRepository();
+ @Test
+ public void repositoryDemo() {
+ ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo();
+ demo.repository = new MapSessionRepository();
- demo.demo();
- }
+ demo.demo();
+ }
- // tag::repository-demo[]
- public class RepositoryDemo {
- private SessionRepository repository; // <1>
+ // tag::repository-demo[]
+ public class RepositoryDemo {
+ private SessionRepository repository; // <1>
- public void demo() {
- S toSave = repository.createSession(); // <2>
+ public void demo() {
+ S toSave = repository.createSession(); // <2>
- // <3>
- User rwinch = new User("rwinch");
- toSave.setAttribute(ATTR_USER, rwinch);
+ // <3>
+ User rwinch = new User("rwinch");
+ toSave.setAttribute(ATTR_USER, rwinch);
- repository.save(toSave); // <4>
+ repository.save(toSave); // <4>
- S session = repository.getSession(toSave.getId()); // <5>
+ S session = repository.getSession(toSave.getId()); // <5>
- // <6>
- User user = session.getAttribute(ATTR_USER);
- assertThat(user).isEqualTo(rwinch);
- }
+ // <6>
+ User user = session.getAttribute(ATTR_USER);
+ assertThat(user).isEqualTo(rwinch);
+ }
- // ... setter methods ...
- }
- // end::repository-demo[]
+ // ... setter methods ...
+ }
+ // end::repository-demo[]
- @Test
- public void expireRepositoryDemo() {
- ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo();
- demo.repository = new MapSessionRepository();
+ @Test
+ public void expireRepositoryDemo() {
+ ExpiringRepositoryDemo demo = new ExpiringRepositoryDemo();
+ demo.repository = new MapSessionRepository();
- demo.demo();
- }
+ demo.demo();
+ }
- // tag::expire-repository-demo[]
- public class ExpiringRepositoryDemo {
- private SessionRepository repository; // <1>
+ // tag::expire-repository-demo[]
+ public class ExpiringRepositoryDemo {
+ private SessionRepository repository; // <1>
- public void demo() {
- S toSave = repository.createSession(); // <2>
- // ...
- toSave.setMaxInactiveIntervalInSeconds(30); // <3>
+ public void demo() {
+ S toSave = repository.createSession(); // <2>
+ // ...
+ toSave.setMaxInactiveIntervalInSeconds(30); // <3>
- repository.save(toSave); // <4>
+ repository.save(toSave); // <4>
- S session = repository.getSession(toSave.getId()); // <5>
- // ...
- }
+ S session = repository.getSession(toSave.getId()); // <5>
+ // ...
+ }
- // ... setter methods ...
- }
- // end::expire-repository-demo[]
+ // ... setter methods ...
+ }
+ // end::expire-repository-demo[]
- @Test
- public void newRedisOperationsSessionRepository() {
- // tag::new-redisoperationssessionrepository[]
- JedisConnectionFactory factory = new JedisConnectionFactory();
- SessionRepository extends ExpiringSession> repository =
- new RedisOperationsSessionRepository(factory);
- // end::new-redisoperationssessionrepository[]
- }
+ @Test
+ public void newRedisOperationsSessionRepository() {
+ // tag::new-redisoperationssessionrepository[]
+ JedisConnectionFactory factory = new JedisConnectionFactory();
+ SessionRepository extends ExpiringSession> repository =
+ new RedisOperationsSessionRepository(factory);
+ // end::new-redisoperationssessionrepository[]
+ }
- @Test
- public void mapRepository() {
- // tag::new-mapsessionrepository[]
- SessionRepository extends ExpiringSession> repository = new MapSessionRepository();
- // end::new-mapsessionrepository[]
- }
+ @Test
+ public void mapRepository() {
+ // tag::new-mapsessionrepository[]
+ SessionRepository extends ExpiringSession> repository = new MapSessionRepository();
+ // end::new-mapsessionrepository[]
+ }
- private static class User {
- private User(String username) {}
- }
+ private static class User {
+ private User(String username) {}
+ }
}
diff --git a/docs/src/test/java/docs/websocket/WebSocketConfig.java b/docs/src/test/java/docs/websocket/WebSocketConfig.java
index acb24de3..46123ad2 100644
--- a/docs/src/test/java/docs/websocket/WebSocketConfig.java
+++ b/docs/src/test/java/docs/websocket/WebSocketConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 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
@@ -30,17 +30,17 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
@EnableScheduling
@EnableWebSocketMessageBroker
public class WebSocketConfig
- extends AbstractWebSocketMessageBrokerConfigurer {
+ extends AbstractWebSocketMessageBrokerConfigurer {
- public void registerStompEndpoints(StompEndpointRegistry registry) {
- registry.addEndpoint("/messages")
- .withSockJS();
- }
+ public void registerStompEndpoints(StompEndpointRegistry registry) {
+ registry.addEndpoint("/messages")
+ .withSockJS();
+ }
- @Override
- public void configureMessageBroker(MessageBrokerRegistry registry) {
- registry.enableSimpleBroker("/queue/", "/topic/");
- registry.setApplicationDestinationPrefixes("/app");
- }
+ @Override
+ public void configureMessageBroker(MessageBrokerRegistry registry) {
+ registry.enableSimpleBroker("/queue/", "/topic/");
+ registry.setApplicationDestinationPrefixes("/app");
+ }
}
// end::class[]
\ No newline at end of file
diff --git a/docs/src/test/java/docs/websocket/WebSocketDocTests.java b/docs/src/test/java/docs/websocket/WebSocketDocTests.java
deleted file mode 100644
index e1562757..00000000
--- a/docs/src/test/java/docs/websocket/WebSocketDocTests.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright 2002-2014 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
- *
- * http://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 docs.websocket;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.messaging.simp.config.MessageBrokerRegistry;
-import org.springframework.scheduling.annotation.EnableScheduling;
-import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
-import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
-import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
-
-/**
- * @author Rob Winch
- */
-public class WebSocketDocTests {
-
-}
diff --git a/gradle/java.gradle b/gradle/java.gradle
index 584ce2d5..43cba5f1 100644
--- a/gradle/java.gradle
+++ b/gradle/java.gradle
@@ -14,73 +14,73 @@ targetCompatibility = 1.5
ext.springIoVersion = project.hasProperty('platformVersion') ? platformVersion : '1.1.0.BUILD-SNAPSHOT'
ext.spockDependencies = [
- dependencies.create("org.spockframework:spock-core:$spockVersion") {
- exclude group: 'junit', module: 'junit-dep'
- }
+ dependencies.create("org.spockframework:spock-core:$spockVersion") {
+ exclude group: 'junit', module: 'junit-dep'
+ }
]
ext.gebDependencies = spockDependencies + [
- "org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
- "org.gebish:geb-spock:$gebVersion",
- 'commons-httpclient:commons-httpclient:3.1',
- "org.codehaus.groovy:groovy:$groovyVersion"
+ "org.seleniumhq.selenium:selenium-htmlunit-driver:$seleniumVersion",
+ "org.gebish:geb-spock:$gebVersion",
+ 'commons-httpclient:commons-httpclient:3.1',
+ "org.codehaus.groovy:groovy:$groovyVersion"
]
ext.jstlDependencies = [
- "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:$jstlVersion",
- "org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
+ "javax.servlet.jsp.jstl:javax.servlet.jsp.jstl-api:$jstlVersion",
+ "org.apache.taglibs:taglibs-standard-jstlel:1.2.1"
]
repositories {
- mavenCentral()
- maven { url 'http://clojars.org/repo' }
- maven { url 'https://repo.spring.io/libs-snapshot' }
+ mavenCentral()
+ maven { url 'http://clojars.org/repo' }
+ maven { url 'https://repo.spring.io/libs-snapshot' }
}
configurations.all {
- resolutionStrategy.eachDependency { DependencyResolveDetails details ->
- if (details.requested.group == 'org.springframework') {
- details.useVersion springVersion
- }
- }
+ resolutionStrategy.eachDependency { DependencyResolveDetails details ->
+ if (details.requested.group == 'org.springframework') {
+ details.useVersion springVersion
+ }
+ }
}
// Integration test setup
configurations {
- integrationTestCompile {
- extendsFrom testCompile, optional, provided
- }
- integrationTestRuntime {
- extendsFrom integrationTestCompile, testRuntime
- }
+ integrationTestCompile {
+ extendsFrom testCompile, optional, provided
+ }
+ integrationTestRuntime {
+ extendsFrom integrationTestCompile, testRuntime
+ }
}
sourceSets {
- integrationTest {
- java.srcDir file('src/integration-test/java')
- groovy.srcDirs file('src/integration-test/groovy')
- resources.srcDir file('src/integration-test/resources')
- compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
- runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
- }
+ integrationTest {
+ java.srcDir file('src/integration-test/java')
+ groovy.srcDirs file('src/integration-test/groovy')
+ resources.srcDir file('src/integration-test/resources')
+ compileClasspath = sourceSets.main.output + sourceSets.test.output + configurations.integrationTestCompile
+ runtimeClasspath = output + compileClasspath + configurations.integrationTestRuntime
+ }
}
task integrationTest(type: Test, dependsOn: jar) {
- testClassesDir = sourceSets.integrationTest.output.classesDir
- logging.captureStandardOutput(LogLevel.INFO)
- classpath = sourceSets.integrationTest.runtimeClasspath
- maxParallelForks = 1
- reports {
- html.destination = project.file("$project.buildDir/reports/integration-tests/")
- junitXml.destination = project.file("$project.buildDir/integration-test-results/")
- }
+ testClassesDir = sourceSets.integrationTest.output.classesDir
+ logging.captureStandardOutput(LogLevel.INFO)
+ classpath = sourceSets.integrationTest.runtimeClasspath
+ maxParallelForks = 1
+ reports {
+ html.destination = project.file("$project.buildDir/reports/integration-tests/")
+ junitXml.destination = project.file("$project.buildDir/integration-test-results/")
+ }
}
eclipse {
- classpath {
- plusConfigurations += [ configurations.integrationTestCompile ]
- }
+ classpath {
+ plusConfigurations += [ configurations.integrationTestCompile ]
+ }
}
project.idea.module {
- scopes.TEST.plus += [project.configurations.integrationTestRuntime]
+ scopes.TEST.plus += [project.configurations.integrationTestRuntime]
}
\ No newline at end of file
diff --git a/gradle/publish-maven.gradle b/gradle/publish-maven.gradle
index e5788a12..89fc7673 100644
--- a/gradle/publish-maven.gradle
+++ b/gradle/publish-maven.gradle
@@ -1,51 +1,51 @@
apply plugin: 'propdeps-maven'
install {
- repositories.mavenInstaller {
- customizePom(pom, project)
- }
+ repositories.mavenInstaller {
+ customizePom(pom, project)
+ }
}
def customizePom(pom, gradleProject) {
- pom.whenConfigured { generatedPom ->
+ pom.whenConfigured { generatedPom ->
- // sort to make pom dependencies order consistent to ease comparison of older poms
- generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
- "$dep.scope:$dep.groupId:$dep.artifactId"
- }
+ // sort to make pom dependencies order consistent to ease comparison of older poms
+ generatedPom.dependencies = generatedPom.dependencies.sort { dep ->
+ "$dep.scope:$dep.groupId:$dep.artifactId"
+ }
- // add all items necessary for maven central publication
- generatedPom.project {
- name = gradleProject.description
- description = gradleProject.description
- url = "https://github.com/spring-projects/spring-session"
- organization {
- name = "Spring IO"
- url = "http://projects.spring.io/spring-session"
- }
- licenses {
- license {
- name "The Apache Software License, Version 2.0"
- url "http://www.apache.org/licenses/LICENSE-2.0.txt"
- distribution "repo"
- }
- }
- scm {
- url = "https://github.com/spring-projects/spring-session"
- connection = "scm:git:git://github.com/spring-projects/spring-session"
- developerConnection = "scm:git:git://github.com/spring-projects/spring-session"
- }
- developers {
- developer {
- id = "rwinch"
- name = "Rob Winch"
- email = "rwinch@pivotal.io"
- }
- }
- issueManagement {
- system = "GitHub"
- url = "https://github.com/spring-projects/spring-session/issues"
- }
- }
- }
+ // add all items necessary for maven central publication
+ generatedPom.project {
+ name = gradleProject.description
+ description = gradleProject.description
+ url = "https://github.com/spring-projects/spring-session"
+ organization {
+ name = "Spring IO"
+ url = "http://projects.spring.io/spring-session"
+ }
+ licenses {
+ license {
+ name "The Apache Software License, Version 2.0"
+ url "http://www.apache.org/licenses/LICENSE-2.0.txt"
+ distribution "repo"
+ }
+ }
+ scm {
+ url = "https://github.com/spring-projects/spring-session"
+ connection = "scm:git:git://github.com/spring-projects/spring-session"
+ developerConnection = "scm:git:git://github.com/spring-projects/spring-session"
+ }
+ developers {
+ developer {
+ id = "rwinch"
+ name = "Rob Winch"
+ email = "rwinch@pivotal.io"
+ }
+ }
+ issueManagement {
+ system = "GitHub"
+ url = "https://github.com/spring-projects/spring-session/issues"
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/gradle/tomcat.gradle b/gradle/tomcat.gradle
index dadb414f..0fb391eb 100644
--- a/gradle/tomcat.gradle
+++ b/gradle/tomcat.gradle
@@ -1,71 +1,71 @@
buildscript {
- repositories {
- maven { url "https://repo.spring.io/plugins-release" }
- }
- dependencies {
- classpath("org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3")
- }
+ repositories {
+ maven { url "https://repo.spring.io/plugins-release" }
+ }
+ dependencies {
+ classpath("org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3")
+ }
}
apply plugin: 'war'
apply plugin: 'tomcat'
dependencies {
- def tomcatVersion = '7.0.54'
- tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
- "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
- tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
- exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
- }
+ def tomcatVersion = '7.0.54'
+ tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
+ "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
+ tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
+ exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
+ }
}
[tomcatRun,tomcatRunWar]*.contextPath = '/'
task integrationTomcatRun(type: org.gradle.api.plugins.tomcat.tasks.TomcatRun) {
- onlyIf { !sourceSets.integrationTest.allSource.empty }
- buildscriptClasspath = tomcatRun.buildscriptClasspath
- contextPath = tomcatRun.contextPath
- daemon = true
- tomcatClasspath = tomcatRun.tomcatClasspath
- webAppClasspath = tomcatRun.webAppClasspath
- webAppSourceDirectory = tomcatRun.webAppSourceDirectory
- doFirst {
- def mainOutputDir = project.sourceSets.main.output.classesDir
- if(mainOutputDir) {
- classesDirectory = mainOutputDir
- }
- // delay reserving ports to ensure they are still available
- def ports = reservePorts(3)
- httpPort = ports[0]
- ajpPort = ports[1]
- stopPort = ports[2]
- }
+ onlyIf { !sourceSets.integrationTest.allSource.empty }
+ buildscriptClasspath = tomcatRun.buildscriptClasspath
+ contextPath = tomcatRun.contextPath
+ daemon = true
+ tomcatClasspath = tomcatRun.tomcatClasspath
+ webAppClasspath = tomcatRun.webAppClasspath
+ webAppSourceDirectory = tomcatRun.webAppSourceDirectory
+ doFirst {
+ def mainOutputDir = project.sourceSets.main.output.classesDir
+ if(mainOutputDir) {
+ classesDirectory = mainOutputDir
+ }
+ // delay reserving ports to ensure they are still available
+ def ports = reservePorts(3)
+ httpPort = ports[0]
+ ajpPort = ports[1]
+ stopPort = ports[2]
+ }
}
task integrationTomcatStop(type: org.gradle.api.plugins.tomcat.tasks.TomcatStop) {
- onlyIf { !sourceSets.integrationTest.allSource.empty }
- doFirst {
- stopPort = integrationTomcatRun.stopPort
- }
+ onlyIf { !sourceSets.integrationTest.allSource.empty }
+ doFirst {
+ stopPort = integrationTomcatRun.stopPort
+ }
}
integrationTest {
- dependsOn integrationTomcatRun
- doFirst {
- def host = 'localhost:' + integrationTomcatRun.httpPort
- systemProperties['geb.build.baseUrl'] = 'http://'+host+'/' + integrationTomcatRun.contextPath
- systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
- }
- finalizedBy integrationTomcatStop
+ dependsOn integrationTomcatRun
+ doFirst {
+ def host = 'localhost:' + integrationTomcatRun.httpPort
+ systemProperties['geb.build.baseUrl'] = 'http://'+host+'/' + integrationTomcatRun.contextPath
+ systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
+ }
+ finalizedBy integrationTomcatStop
}
def reservePorts(int count) {
- def sockets = []
- for(int i in 1..count) {
- sockets << new ServerSocket(0)
- }
- def result = sockets*.localPort
- sockets*.close()
- result
+ def sockets = []
+ for(int i in 1..count) {
+ sockets << new ServerSocket(0)
+ }
+ def result = sockets*.localPort
+ sockets*.close()
+ result
}
\ No newline at end of file
diff --git a/samples/boot/build.gradle b/samples/boot/build.gradle
index 3fd1f07f..8309f45b 100644
--- a/samples/boot/build.gradle
+++ b/samples/boot/build.gradle
@@ -1,10 +1,10 @@
buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
- }
+ repositories {
+ mavenCentral()
+ }
+ dependencies {
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion")
+ }
}
apply plugin: 'spring-boot'
@@ -16,36 +16,36 @@ tasks.findByPath("artifactoryPublish")?.enabled = false
group = 'samples'
dependencies {
- compile project(':spring-session-data-redis'),
- "org.springframework.boot:spring-boot-starter-web",
- "org.springframework.boot:spring-boot-starter-thymeleaf",
- "redis.embedded:embedded-redis:0.2",
- "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",
- "org.springframework.security:spring-security-web:$springSecurityVersion",
- "org.springframework.security:spring-security-config:$springSecurityVersion"
+ compile project(':spring-session-data-redis'),
+ "org.springframework.boot:spring-boot-starter-web",
+ "org.springframework.boot:spring-boot-starter-thymeleaf",
+ "redis.embedded:embedded-redis:0.2",
+ "nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect",
+ "org.springframework.security:spring-security-web:$springSecurityVersion",
+ "org.springframework.security:spring-security-config:$springSecurityVersion"
- testCompile "org.springframework.boot:spring-boot-starter-test"
+ testCompile "org.springframework.boot:spring-boot-starter-test"
- integrationTestCompile gebDependencies,
- "org.spockframework:spock-spring:$spockVersion"
+ integrationTestCompile gebDependencies,
+ "org.spockframework:spock-spring:$spockVersion"
}
integrationTest {
- doFirst {
- def port = reservePort()
+ doFirst {
+ def port = reservePort()
- def host = 'localhost:' + port
- systemProperties['geb.build.baseUrl'] = 'http://'+host+'/'
- systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
- systemProperties['server.port'] = port
- systemProperties['management.port'] = 0
- }
+ def host = 'localhost:' + port
+ systemProperties['geb.build.baseUrl'] = 'http://'+host+'/'
+ systemProperties['geb.build.reportsDir'] = 'build/geb-reports'
+ systemProperties['server.port'] = port
+ systemProperties['management.port'] = 0
+ }
}
def reservePort() {
- def socket = new ServerSocket(0)
- def result = socket.localPort
- socket.close()
- result
+ def socket = new ServerSocket(0)
+ def result = socket.localPort
+ socket.close()
+ result
}
\ No newline at end of file
diff --git a/samples/boot/src/integration-test/groovy/sample/BootTests.groovy b/samples/boot/src/integration-test/groovy/sample/BootTests.groovy
index 134aaf52..b1c8d7f4 100644
--- a/samples/boot/src/integration-test/groovy/sample/BootTests.groovy
+++ b/samples/boot/src/integration-test/groovy/sample/BootTests.groovy
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2002-2015 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
+ *
+ * http://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 sample
import geb.spock.*
@@ -23,37 +38,37 @@ import pages.*
@IntegrationTest
class BootTests extends GebReportingSpec {
- def 'Unauthenticated user sent to log in page'() {
- when: 'unauthenticated user request protected page'
- via HomePage
- then: 'sent to the log in page'
- at LoginPage
- }
+ def 'Unauthenticated user sent to log in page'() {
+ when: 'unauthenticated user request protected page'
+ via HomePage
+ then: 'sent to the log in page'
+ at LoginPage
+ }
- def 'Log in views home page'() {
- when: 'log in successfully'
- login()
- then: 'sent to original page'
- at HomePage
- and: 'the username is displayed'
- username == 'user'
- and: 'Spring Session Management is being used'
- driver.manage().cookies.find { it.name == 'SESSION' }
- and: 'Standard Session is NOT being used'
- !driver.manage().cookies.find { it.name == 'JSESSIONID' }
- }
+ def 'Log in views home page'() {
+ when: 'log in successfully'
+ login()
+ then: 'sent to original page'
+ at HomePage
+ and: 'the username is displayed'
+ username == 'user'
+ and: 'Spring Session Management is being used'
+ driver.manage().cookies.find { it.name == 'SESSION' }
+ and: 'Standard Session is NOT being used'
+ !driver.manage().cookies.find { it.name == 'JSESSIONID' }
+ }
- def 'Log out success'() {
- when:
- logout()
- then:
- at LoginPage
- }
+ def 'Log out success'() {
+ when:
+ logout()
+ then:
+ at LoginPage
+ }
- def 'Logged out user sent to log in page'() {
- when: 'logged out user request protected page'
- via HomePage
- then: 'sent to the log in page'
- at LoginPage
- }
+ def 'Logged out user sent to log in page'() {
+ when: 'logged out user request protected page'
+ via HomePage
+ then: 'sent to the log in page'
+ at LoginPage
+ }
}
\ No newline at end of file
diff --git a/samples/boot/src/integration-test/groovy/sample/pages/HomePage.groovy b/samples/boot/src/integration-test/groovy/sample/pages/HomePage.groovy
index ec93126f..867b81a7 100644
--- a/samples/boot/src/integration-test/groovy/sample/pages/HomePage.groovy
+++ b/samples/boot/src/integration-test/groovy/sample/pages/HomePage.groovy
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2002-2015 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
+ *
+ * http://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 sample.pages
import geb.*
@@ -8,10 +23,10 @@ import geb.*
* @author Rob Winch
*/
class HomePage extends Page {
- static url = ''
- static at = { assert driver.title == 'Spring Session Sample - Secured Content'; true}
- static content = {
- username { $('#un').text() }
- logout(to:LoginPage) { $('input[type=submit]').click() }
- }
+ static url = ''
+ static at = { assert driver.title == 'Spring Session Sample - Secured Content'; true}
+ static content = {
+ username { $('#un').text() }
+ logout(to:LoginPage) { $('input[type=submit]').click() }
+ }
}
diff --git a/samples/boot/src/integration-test/groovy/sample/pages/LoginPage.groovy b/samples/boot/src/integration-test/groovy/sample/pages/LoginPage.groovy
index 63f9d6f9..ceeb790a 100644
--- a/samples/boot/src/integration-test/groovy/sample/pages/LoginPage.groovy
+++ b/samples/boot/src/integration-test/groovy/sample/pages/LoginPage.groovy
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2002-2015 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
+ *
+ * http://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 sample.pages
import geb.*
@@ -8,15 +23,15 @@ import geb.*
* @author Rob Winch
*/
class LoginPage extends Page {
- static url = '/login'
- static at = { assert driver.title == 'Login Page'; true}
- static content = {
- form { $('form') }
- submit { $('input[type=submit]') }
- login(required:false) { user='user', pass='password' ->
- form.username = user
- form.password = pass
- submit.click(HomePage)
- }
- }
+ static url = '/login'
+ static at = { assert driver.title == 'Login Page'; true}
+ static content = {
+ form { $('form') }
+ submit { $('input[type=submit]') }
+ login(required:false) { user='user', pass='password' ->
+ form.username = user
+ form.password = pass
+ submit.click(HomePage)
+ }
+ }
}
diff --git a/samples/boot/src/main/java/sample/Application.java b/samples/boot/src/main/java/sample/Application.java
index 8bf6cf63..7646ee50 100644
--- a/samples/boot/src/main/java/sample/Application.java
+++ b/samples/boot/src/main/java/sample/Application.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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
@@ -28,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
@EnableAutoConfiguration
public class Application {
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
}
diff --git a/samples/boot/src/main/java/sample/config/EmbeddedRedisConfiguration.java b/samples/boot/src/main/java/sample/config/EmbeddedRedisConfiguration.java
index 38958db6..b380d397 100644
--- a/samples/boot/src/main/java/sample/config/EmbeddedRedisConfiguration.java
+++ b/samples/boot/src/main/java/sample/config/EmbeddedRedisConfiguration.java
@@ -1,19 +1,19 @@
-package sample.config;
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 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
+ * 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
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://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.
+ * 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 sample.config;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
@@ -36,35 +36,33 @@ import redis.embedded.RedisServer;
@Configuration
public class EmbeddedRedisConfiguration {
- @Bean
- public static RedisServerBean redisServer() {
- return new RedisServerBean();
- }
+ @Bean
+ public static RedisServerBean redisServer() {
+ return new RedisServerBean();
+ }
- /**
- * Implements BeanDefinitionRegistryPostProcessor to ensure this Bean
- * is initialized before any other Beans. Specifically, we want to ensure
- * that the Redis Server is started before RedisHttpSessionConfiguration
- * attempts to enable Keyspace notifications.
- */
- static class RedisServerBean implements InitializingBean, DisposableBean, BeanDefinitionRegistryPostProcessor {
- private RedisServer redisServer;
+ /**
+ * Implements BeanDefinitionRegistryPostProcessor to ensure this Bean
+ * is initialized before any other Beans. Specifically, we want to ensure
+ * that the Redis Server is started before RedisHttpSessionConfiguration
+ * attempts to enable Keyspace notifications.
+ */
+ static class RedisServerBean implements InitializingBean, DisposableBean, BeanDefinitionRegistryPostProcessor {
+ private RedisServer redisServer;
- public void afterPropertiesSet() throws Exception {
- redisServer = new RedisServer(Protocol.DEFAULT_PORT);
- redisServer.start();
- }
+ public void afterPropertiesSet() throws Exception {
+ redisServer = new RedisServer(Protocol.DEFAULT_PORT);
+ redisServer.start();
+ }
- public void destroy() throws Exception {
- if(redisServer != null) {
- redisServer.stop();
- }
- }
+ public void destroy() throws Exception {
+ if(redisServer != null) {
+ redisServer.stop();
+ }
+ }
- @Override
- public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {}
+ public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {}
- @Override
- public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {}
- }
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {}
+ }
}
\ No newline at end of file
diff --git a/samples/boot/src/main/java/sample/config/HttpSessionConfig.java b/samples/boot/src/main/java/sample/config/HttpSessionConfig.java
index 0a424266..5bb05052 100644
--- a/samples/boot/src/main/java/sample/config/HttpSessionConfig.java
+++ b/samples/boot/src/main/java/sample/config/HttpSessionConfig.java
@@ -1,6 +1,23 @@
+/*
+ * Copyright 2002-2015 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
+ *
+ * http://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 sample.config;
import org.springframework.session.data.redis.config.annotation.web.http.*;
+// tag::class[]
@EnableRedisHttpSession // <1>
public class HttpSessionConfig { }
+// end::class[]
\ No newline at end of file
diff --git a/samples/boot/src/main/java/sample/config/SecurityConfig.java b/samples/boot/src/main/java/sample/config/SecurityConfig.java
index 2bc8d1a1..ab040300 100644
--- a/samples/boot/src/main/java/sample/config/SecurityConfig.java
+++ b/samples/boot/src/main/java/sample/config/SecurityConfig.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 the original author or authors.
+ * Copyright 2002-2015 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
@@ -26,10 +26,10 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
- @Autowired
- public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
- auth
- .inMemoryAuthentication()
- .withUser("user").password("password").roles("USER");
- }
+ @Autowired
+ public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
+ auth
+ .inMemoryAuthentication()
+ .withUser("user").password("password").roles("USER");
+ }
}
diff --git a/samples/boot/src/main/java/sample/mvc/IndexController.java b/samples/boot/src/main/java/sample/mvc/IndexController.java
index 16c0343f..8a76934d 100644
--- a/samples/boot/src/main/java/sample/mvc/IndexController.java
+++ b/samples/boot/src/main/java/sample/mvc/IndexController.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2013 the original author or authors.
+ * Copyright 2002-2015 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
@@ -26,8 +26,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
*/
@Controller
public class IndexController {
- @RequestMapping("/")
- public String index() {
- return "index";
- }
+ @RequestMapping("/")
+ public String index() {
+ return "index";
+ }
}
diff --git a/samples/boot/src/main/resources/templates/index.html b/samples/boot/src/main/resources/templates/index.html
index a7f875cb..1a3f6e49 100644
--- a/samples/boot/src/main/resources/templates/index.html
+++ b/samples/boot/src/main/resources/templates/index.html
@@ -1,11 +1,11 @@
-
- Secured Content
-
-
-
-
Secured Page
-
This page is secured using Spring Boot, Spring Session, and Spring Security.
-
-
+
+ Secured Content
+
+
+
+
Secured Page
+
This page is secured using Spring Boot, Spring Session, and Spring Security.