How to get current session (HttpSession) object in @Scheduled method in Spring 4.0.2?

Sunday, May 4, 2014

I am using Spring 4.0.2 for my Web Application. My Web Application is about file processing. There are some statues about files like "In Progress", "On Hold", "Completed". One user can complete multiple files, but only one at a time. So at a time only one file must be "In Progress" for a single user. Now, I want to check after every 15 mins whether is there any event occurred with particular file or not. If there is no event occurred, I want to change file status from "In Progress" to "On Hold". So that I tried to write Scheduler in Spring as given below.



@Scheduler(fixedDelay = 15*60*1000)
public void checkFrequently()
{
// here I am doing some operation to check for any event occurred in last 15 min or not.
// here, I need HttpSession for two purposes.
// 1. to get current logged in user
// 2. to get current file for current user
}


Is there any possibility to get session in this method? If it is impossible, what are the alternatives?







http://ift.tt/1iXn6SH