领先一步
VMware 提供培训和认证,助您加速进步。
了解更多Spring 社区的各位朋友们大家好!
我很高兴地宣布 Apache Geode 的 Spring Session Data Geode 和 Pivotal GemFire 的 Spring Session Data GemFire 的第二个里程碑版本。
第二个里程碑版本带来了许多令人欢迎的改进,包括:
升级到 Spring Framework 5.0.0.RELEASE。
升级到 Spring Data Kay-RELEASE。
升级到 Spring Session 2.0.0.M4。
升级到 Spring Boot 2.0.0.M4。
增加了对 Pivotal GemFire 和 Apache Geode PDX 序列化的支持。
引入了一个新的 序列化框架 和适配器,用于 Pivotal GemFire/Apache Geode 的数据序列化和 PDX 框架。
这两个构件都可以通过 Maven 从Spring的libs-milestone仓库下载…
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-geode</artifactId>
<version>2.0.0.M2</version>
</dependency>
或者,使用 Gradle…
compile 'org.springframework.session:spring-session-data-geode:2.0.0.M2
要将Spring Session与 Pivotal GemFire 一起使用,只需将构件从spring-session-data-geode切换到spring-session-data-gemfire。版本保持不变。
许多用户一直要求Spring Session for Pivotal GemFire and Apache Geode 支持 PDX 序列化。鉴于 PDX 的高度“可移植性”,这很有意义,具体解释请参阅 参考指南。
PDX 的一个关键优势是,在使用客户端/服务器拓扑的Spring Boot、GemFire/Geode 缓存客户端应用程序中使用Spring Session时,您不需要在集群的服务器类路径中包含Spring Session for Pivotal GemFire or Apache Geode。实际上,您甚至不需要将存储在(HTTP)会话中并持久化到集群的 GemFire/Geode 服务器中的应用程序域对象类放到服务器的类路径中。
Spring Session Data GemFire/Geode 现在默认使用 PDX。但是,只需在@EnableGemFireHttpSession注解中切换 bean 引用,就可以非常轻松地在数据序列化和 PDX 之间切换。
开箱即用,Spring Session Data GemFire/Geode 会代表用户注册两个 bean,实现每个 GemFire/Geode 序列化策略。
要显式声明您希望您的Spring Boot、已启用Spring Session的应用程序使用 PDX 序列化,请将@EnableGemFireHttpSession注解中的新sessionSerializerBeanName属性设置为GemFireHttpSessionConfiguration.SESSION_PDX_SERIALIZER_BEAN_NAME…
@SpringBootApplication
@EnableGemFireHttpSession(sessionSerializerBeanName =
GemFireHttpSessionConfiguration.SESSION_PDX_SERIALIZER_BEAN_NAME
class Application {
...
}
要使用数据序列化并利用Delta,请将sessionSerializerBeanName设置为GemFireHttpSessionConfiguration.SESSION_DATA_SERIALIZER_BEAN_NAME…
@SpringBootApplication
@EnableGemFireHttpSession(sessionSerializerBeanName =
GemFireHttpSessionConfiguration.SESSION_DATA_SERIALIZER_BEAN_NAME
class Application {
...
}
有关在Spring Session和 Pivotal GemFire 或 Apache Geode 中使用 PDX 的更多详细信息,请参阅 参考指南。
Spring Session Data GemFire/Geode 引入了一个新的SessionSerializer接口,允许用户自定义如何将Session序列化到 Pivotal GemFire 或 Apache Geode。
interface SessionSerializer<T, IN, OUT> {
void serializer(T session, OUT out);
T deserialize(IN in);
boolean canSerialize(Class<?> type);
}
用户可以提供该接口的自定义实现,将其注册为Spring上下文中的 bean,并将sessionSerializerBeanName属性设置为自定义SessionSerializer bean 定义的名称,然后Spring Session Data GemFire/Geode将适配并将此 bean 注册为 Pivotal GemFire 或 Apache Geode 中的PdxSerializer。
例如…
@SpringBootApplication
@EnableGemFireHttpSession(sessionSerializerBeanName = "customSerializer")
class Application {
@Bean
SessionSerializer<Session, PdxReader, PdxWriter> customSerializer() {
// return an instance of a custom `SessionSerializer` implementation
}
}
这只是冰山一角。有关新 序列化框架 的更多详细信息,请参阅参考指南。
一如既往,我们非常感谢您对此版本的任何反馈。用户可以通过 StackOverflow 联系我们,提交 GitHub Issues,或在下方分享您的评论。您也可以在 Twitter 上联系我,@john_blum。
另外,请务必查看今年的 SpringOne Platform 2017 的阵容。这将是值得纪念的一年,有如此多的精彩内容…Spring Framework 5 对 JDK 9 的早期支持、响应式和函数式编程、与 JUnit 5 和 Kotlin 的集成。有太多酷炫的东西可以学习!