Quick post…
I ran across the need to use a session scoped service in my grails app the other day and had quite a hard time finding out how to do some housekeeping/cleanup once a user’s session has expired.
I came across this post on the mailing list which was very helpful but I couldn’t really get this to work, but it helped me figure out what I should be searching for (in the spring docs)
Here is how I got things to work.
import org.springframework.beans.factory.InitializingBean
import org.springframework.beans.factory.DisposableBean
class MySessionScopedService implements InitializingBean,DisposableBean{
static scope = "session"
void afterPropertiesSet(){
// ***********************
// Initialization code goes here
// ***********************
}
void destroy(){
// ******************************
// Housekepping / Cleanup code goes here
// *******************************
}
}
Hope someone will find this useful.

One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion