Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 从LiftSession.onShutdownSession侦听器访问SessionVar_Scala_Lift - Fatal编程技术网

Scala 从LiftSession.onShutdownSession侦听器访问SessionVar

Scala 从LiftSession.onShutdownSession侦听器访问SessionVar,scala,lift,Scala,Lift,我在代码中定义了SessionVar: object User extends SessionVar[Option[User]] 与会话和请求分开的对象 object StatisticMonitor extends LiftActor{ LiftSession.onAboutToShutdownSession::= onSessionShutdown def onSessionShutdown(targetSession: LiftSession) { /

我在代码中定义了SessionVar:

object User extends SessionVar[Option[User]]
与会话和请求分开的对象

object StatisticMonitor extends LiftActor{

    LiftSession.onAboutToShutdownSession::= onSessionShutdown

    def onSessionShutdown(targetSession: LiftSession) {
        //TODO: how to find User for session targetSession 
    }
}
问题:

  • 内部
    onSessionShutdown
    User
    绑定到
    targetSession
    (即,通过调用
    User.Is
    我将获取正在关闭的用户)是真的吗

  • 是否有方法访问任何具有
    LiftSession
    实例的
    SessionVar
    。(例如,我有一个LiftSessions数组,我想迭代所有会话变量)


  • 无论何时任何会话过期,都将调用向onAboutToShutdownSession添加处理程序,而不仅仅是绑定到
    SessionVar
    的当前会话。如果您只关心绑定到
    SessionVar
    的会话,您可能希望替代
    SessionVar
    上的方法


    我不确定您想要用第二点实现什么,但我不相信您可以从
    SessionVar

    SessionVar
    cleanuparam
    定义为
    cleanuparam=LiftSession
    。所以我又一次关闭了(会话:LiftSession)。我必须提取绑定到
    会话的SessionVar值。我需要类似于
    session.get(User)
    的东西来从
    session
    提取
    User
    会话变量。是的,除了
    onShutdown
    方法存在于
    SessionVar
    中之外,您应该能够使用
    这个
    引用过期对象上的任何方法。