Public Sub SetPersistentJDBCSessions(ServerObject As Server, NodeName As String, DBDriver As String, DBUrl As String, SessionIdTableName As String, SessionDataTableName As String, ScavengeInterval As Long)
' http://www.eclipse.org/jetty/documentation/9.3.x/session-clustering-jdbc.html
Dim joServer As JavaObject = ServerObject
' stop the server as some settings cannot be modified while context is in use
joServer.GetFieldJO("server").RunMethod("stop", Null)
' The session ID manager ensures that session IDs are unique across all webapps hosted on a Jetty instance, and thus there can only be one session ID manager per Jetty instance.
Dim joJDBCSessionIdManager As JavaObject
joJDBCSessionIdManager.InitializeNewInstance("org.eclipse.jetty.server.session.JDBCSessionIdManager", Array(joServer.GetFieldJO("server")))
joJDBCSessionIdManager.RunMethod("setWorkerName", Array(NodeName))
joJDBCSessionIdManager.RunMethod("setDriverInfo", Array(DBDriver, DBUrl))
joJDBCSessionIdManager.RunMethod("setScavengeInterval", Array(ScavengeInterval))
joJDBCSessionIdManager.RunMethodJO("getSessionIdTableSchema", Null).RunMethod("setTableName", Array(SessionIdTableName))
joJDBCSessionIdManager.RunMethodJO("getSessionTableSchema", Null).RunMethod("setTableName", Array(SessionDataTableName))
joServer.GetFieldJO("server").RunMethod("setSessionIdManager", Array(joJDBCSessionIdManager))
' The session manager handles the session lifecycle (create/update/invalidate/expire) on behalf of a web application, so there is one session manager per web application instance.
Dim joJDBCSessionManager As JavaObject
joJDBCSessionManager.InitializeNewInstance("org.eclipse.jetty.server.session.JDBCSessionManager", Null)
joJDBCSessionManager.RunMethod("setSessionIdManager", Array(joJDBCSessionIdManager))
Dim joSessionHandler As JavaObject
joSessionHandler.InitializeNewInstance("org.eclipse.jetty.server.session.SessionHandler", Array(joJDBCSessionManager))
joServer.GetFieldJO("context").RunMethod("setSessionHandler", Array(joSessionHandler))
' start the server with the new settings
joServer.GetFieldJO("server").RunMethod("start", Null)
End Sub