Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introducing Spring Session 2

Introducing Spring Session 2

Vedran Pavić

May 24, 2018
Tweet

More Decks by Vedran Pavić

Other Decks in Technology

Transcript

  1. Agenda • About me • New in Spring Session 2

    • Project Modules • Spring WebFlux Support • Improvements • Migrating to Spring Session 2 • Custom Session Repository
  2. About Me - Vedran Pavić • Spring user for 9

    years • Contributor to Spring projects for 2.5 years • Spring Session committer for 1.5 year
  3. Project Modules • Spring Session 1.x was a single JAR

    • Convenient, but hard to evolve and maintain • Spring Session 2.0 is JAR per session store • Arrangement similar to Spring Data • Community extensions are welcome • Dedicated section in reference manual • Spring Boot and Initializr impact
  4. Project Modules - Spring Session 1.3 • spring-projects/spring-session • spring-session

    (Core, Redis, Gemfire, MongoDB, JDBC, Hazelcast) • spring-session-data-redis (starter module) • spring-session-data-gemfire (starter module) • spring-session-data-mongo (starter module) • spring-session-jdbc (starter module) • spring-session-hazelcast (starter module)
  5. Project Modules - Spring Session 2.0 • spring-projects/spring-session • spring-session-core

    • spring-session-data-redis • spring-session-jdbc • spring-session-hazelcast • spring-projects/spring-session-data-geode • spring-session-data-geode • spring-session-data-gemfire • spring-projects/spring-session-data-mongodb • spring-session-data-mongodb • spring-projects/spring-session-bom • spring-session-bom
  6. Spring WebFlux Support • Follows the familiar Spring Session patterns

    • e.g. @EnableRedisHttpSession vs @EnableRedisWebSession • Much simpler than Servlet support • Key APIs are a part of spring-web • Redis & MongoDB session stores
  7. Improvements - Core • Move to Java 8 & Spring

    5 as baseline • Core API improvements • Refreshed Session & SessionRepository • HttpServletRequest#changeSessionId support • Configuration improvements • SessionCookieConfig support • Alignment of Servlet & WebFlux support • HttpSessionStrategy → HttpSessionIdResolver
  8. Improvements - Repositories • Performance improvements • JdbcOperationsSessionRepository • HazelcastSessionRepository

    • Configuration improvements • Qualifier annotations for data stores • Data access components (e.g. RedisTemplate, JdbcTemplate) no longer registered as beans
  9. Migrating to Spring Session 2 • Check your dependencies •

    spring-session JAR doesn’t exist in 2.0 • spring-session-data-mongo → spring-session-data-mongodb • Adapt to core API changes • Session, SessionRepository • Adapt to session resolution changes • HttpSessionStrategy → HttpSessionIdResolver • removed support for multiple sessions in a single browser
  10. Custom Session Repository • Core Spring Session infra is easy

    to reuse • @EnableSpringHttpSession & @EnableSpringWebSession • Implementing session repository • Beware of race conditions - optimize session writes • Take care to purge the expired sessions • Support session event publishing, if possible • Provide supporting configuration classes
  11. Contribute to Spring Session • Issue tracker • https://github.com/spring-projects/spring-session/issues •

    Gitter chat • https://gitter.im/spring-projects/spring-session • Stack Overflow tag • https://stackoverflow.com/questions/tagged/spring-session • From Zero to Open Source Hero @ Spring I/O 2017 • https://www.youtube.com/watch?v=D7OJFWNx-ks
  12. Related Talks • Under the Hood of Reactive Data Access

    • Thursday @ 17:30 • Spring Boot 2.0 Web Applications • Friday @ 9:00 • Next Generation OAuth Support with Spring Security 5 • Friday @ 17:00