领先一步
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
。版本保持不变。
许多用户一直要求 Pivotal GemFire 和 Apache Geode 的Spring Session 支持 PDX 序列化。鉴于 PDX 具有高度的“可移植性”,这很有意义,详见参考指南。
PDX 的主要优势之一是,在使用客户端/服务器拓扑的 GemFire/Geode 缓存客户端应用程序中的Spring Boot中使用Spring Session时,您不需要集群中服务器类路径上的 Pivotal GemFire 或 Apache Geode 的 Spring Session。 事实上,您甚至不需要将存储在(HTTP)Session 中并持久化到集群中 GemFire/Geode 服务器上的应用程序域对象类放在服务器的类路径上。
Spring Session Data GemFire/Geode 现在默认使用 PDX。 但是,只需切换 @EnableGemFireHttpSession
注释中的 bean 引用,就可以很容易地在数据序列化和 PDX 之间切换。
OOTB,Spring Session Data GemFire/Geode 代表用户注册 2 个 beans,实现每个 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 {
...
}
要使用数据序列化并利用 Deltas,请将 sessionSerializerBeanName
设置为 GemFireHttpSessionConfiguration.SESSION_DATA_SERIALIZER_BEAN_NAME
…
@SpringBootApplication
@EnableGemFireHttpSession(sessionSerializerBeanName =
GemFireHttpSessionConfiguration.SESSION_DATA_SERIALIZER_BEAN_NAME
class Application {
...
}
有关将 PDX 与 Spring Session 和 Pivotal GemFire 或 Apache Geode 结合使用的更多详细信息,请参见参考指南。
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、Reactive 和Functional 编程,与 JUnit 5 和 Kotlin 集成。 有太多很酷的东西要学习!