session.closesession.unbindFromCurrentThread
--
Ross A. Baker
ba...@alumni.indiana.edu
Indianapolis, IN, USA
before {
dlSession.value = SessionFactory.newSession
dlSession.value.bindToCurrentThread
}
after {
dlSession.value.unbindFromCurrentThread
dlSession.value.close
dlSession.value = null
}
Alternatively you could implement Handler:
trait DlSessionSupport extends Handler {
val dlSession = new DynamicVariable[Session](null)
abstract override def handle(req: HttpServletRequest, resp:
HttpServletResponse) {
dlSession.withValue(SessionFactory.newSession) {
dlSession.value.bindToCurrentThread
try {
super.handle(request, response)
} finally {
dlSession.value.close
dlSession.value.unbindFromCurrentThread
}
}
}
}
class DailyLifFilter extends ScalatraFilter with ScalateSupport
with DlSessionSupport
--
There's a GitHub wiki that has never gotten off the ground.
Documentation is in the README and being migrated to the in-progress
website project. Pull requests for those are always appreciated.
With the right abstraction, I could also see that Handler evolving
into a scalatra-squeryl helper module.