【发布时间】:2020-10-21 01:24:41
【问题描述】:
我正在尝试为嵌入式码头服务器实现 jdbc 会话,以便在 openshift 环境中跨节点共享会话(以避免用户在部署发生时丢失会话)。现有的官方文档 (https://www.eclipse.org/jetty/documentation/9.4.32.v20200930/configuring-sessions-jdbc.html) 仅包含 Jetty 分发实现的实现细节。 How to setup embeded Jetty to use JDBC sessions 有一个类似但不完整的解决方案
// Configure a JDBCSessionDataStoreFactory.
JDBCSessionDataStoreFactory sessionDataStoreFactory = new JDBCSessionDataStoreFactory();
sessionDataStoreFactory.setGracePeriodSec(3600);
sessionDataStoreFactory.setSavePeriodSec(0);
sessionDataStoreFactory.setDatabaseAdaptor(...);
JDBCSessionDataStore.SessionTableSchema schema = new JDBCSessionDataStore.SessionTableSchema();
schema.setAccessTimeColumn("accessTime");
schema.setContextPathColumn("contextPath");
// ... more configuration here
sessionDataStoreFactory.setSessionTableSchema(schema);
// Add the SessionDataStoreFactory as a bean on the server.
server.addBean(sessionDataStoreFactory);
这里不清楚如何创建 DatabaseAdaptor 对象。有人可以帮忙吗?
【问题讨论】:
标签: embedded-jetty session-management