diff --git a/docs/modules/ROOT/examples/spring/HazelcastHttpSessionConfig.java b/docs/modules/ROOT/examples/spring/HazelcastHttpSessionConfig.java index 1511f1554..0073708a5 100644 --- a/docs/modules/ROOT/examples/spring/HazelcastHttpSessionConfig.java +++ b/docs/modules/ROOT/examples/spring/HazelcastHttpSessionConfig.java @@ -27,10 +27,10 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.session.MapSession; -import org.springframework.session.hazelcast.HazelcastIndexedSessionRepository; -import org.springframework.session.hazelcast.HazelcastSessionSerializer; -import org.springframework.session.hazelcast.PrincipalNameExtractor; -import org.springframework.session.hazelcast.config.annotation.web.http.EnableHazelcastHttpSession; +import com.hazelcast.spring.session.HazelcastIndexedSessionRepository; +import com.hazelcast.spring.session.HazelcastSessionSerializer; +import com.hazelcast.spring.session.PrincipalNameExtractor; +import com.hazelcast.spring.session.config.annotation.web.http.EnableHazelcastHttpSession; // tag::config[] @EnableHazelcastHttpSession // <1> diff --git a/docs/modules/spring/pages/spring-session-guide.adoc b/docs/modules/spring/pages/spring-session-guide.adoc index 90d04b63e..4db401f83 100644 --- a/docs/modules/spring/pages/spring-session-guide.adoc +++ b/docs/modules/spring/pages/spring-session-guide.adoc @@ -5,9 +5,10 @@ It assumes that you have already applied Spring Security to your application. NOTE: You can find the completed guide in the <>. -== Updating Dependencies +== Update dependencies Before you use Spring Session, you must update your dependencies. + If you use Maven, you must add the following dependencies: .pom.xml @@ -28,15 +29,24 @@ If you use Maven, you must add the following dependencies: 6.2.7 - org.springframework.session - spring-session-hazelcast - 3.2.5 + com.hazelcast + hazelcast-spring-session + 4.0.0 ---- +=== Note on migration from Spring Session Hazelcast 3.x + +From version 4.0, the Hazelcast integration with Spring Session is owned by the Hazelcast team. + +To migrate your application from using Spring Session Hazelcast 3.x to new Hazelcast Spring Session 4.x: + +. Change GroupId to `com.hazelcast` and artifactId to `hazelcast-spring-session`. +. Update your code and change the packages. All Hazelcast-specific classes were moved from `org.springframework.session.hazelcast` to `com.hazelcast.spring.session`. + [[security-spring-configuration]] -== Spring Configuration +== Spring configuration After adding the required dependencies, we can create our Spring configuration. The Spring configuration is responsible for creating a servlet filter that replaces the `HttpSession` implementation with an implementation backed by Spring Session. @@ -56,13 +66,12 @@ is not set, Hazelcast will serialize sessions using native Java serialization. <4> We create a `HazelcastInstance` that connects Spring Session to Hazelcast. By default, the application starts and connects to an embedded instance of Hazelcast. - NOTE: If `HazelcastSessionSerializer` is preferred, it needs to be configured for all Hazelcast cluster members before they start. In a Hazelcast cluster, all members should use the same serialization method for sessions. Also, if Hazelcast Client/Server topology is used, then both members and clients must use the same serialization method. The serializer can be registered via `ClientConfig` with the same `SerializerConfiguration` of members. -== Servlet Container Initialization +== Servlet container initialization The instructions detailed in the link:https://docs.spring.io/spring-session/reference/guides/java-security.html#security-spring-configuration[Spring docs] created a Spring bean named `springSessionRepositoryFilter` that implements `Filter`. The `springSessionRepositoryFilter` bean is responsible for replacing the `HttpSession` with a custom implementation that is backed by Spring Session. @@ -102,11 +111,11 @@ By extending `AbstractHttpSessionApplicationInitializer`, we ensure that the Spr // end::config[] [[hazelcast-spring-security-sample]] -== Hazelcast Spring Security Sample Application +== Hazelcast Spring Security sample application This section describes how to work with the Hazelcast Spring Security sample application. -=== Running the Sample Application +=== Running the sample application You can run the sample by obtaining the link:https://docs.hazelcast.com/hazelcast/latest/spring/spring-session-3.5.2.zip[source code] and invoking the following command: @@ -120,7 +129,7 @@ However, if you want to connect to a standalone instance instead, you can config You should now be able to access the application at http://localhost:8080/ -=== Exploring the Security Sample Application +=== Exploring the Security Sample application You can now try using the application. To do so, enter the following to log in: @@ -132,7 +141,7 @@ Now click the *Login* button. You should now see a message indicating that your are logged in with the user entered previously. The user's information is stored in Hazelcast rather than Tomcat's `HttpSession` implementation. -=== How Does It Work? +=== How does it work? Instead of using Tomcat's `HttpSession`, we persist the values in Hazelcast. Spring Session replaces the `HttpSession` with an implementation that is backed by a `Map` in Hazelcast. @@ -141,12 +150,12 @@ When Spring Security's `SecurityContextPersistenceFilter` saves the `SecurityCon When a new `HttpSession` is created, Spring Session creates a cookie named `SESSION` in your browser. That cookie contains the ID of your session. You can view the cookies (with https://developers.google.com/web/tools/chrome-devtools/manage-data/cookies[Chrome] or https://developer.mozilla.org/en-US/docs/Tools/Storage_Inspector[Firefox]). -=== Interacting with the Data Store +=== Interacting with the data store You can remove the session by using the xref:clients:java.adoc[Java client], xref:clients:hazelcast-clients.adoc[one of the other clients], or xref:{page-latest-supported-mc}@management-center:getting-started:overview.adoc[Management Center]. -==== Using the Console +==== Using the console For example, to remove the session by using the Management Center console after connecting to your Hazelcast node, run the following commands: