Get http session / request in hibernate interceptor
I want to to implement an audit logging module to my existing system and I want to save actual logged user information and it's only the httpSession.
I'm using hibernate/spring/struts 2, and in order to get actual logged user information and call saveLog service I need the ServletContext to find those service bean or get the httpServletRequest...
is there other suggestion? is this a commun pattern or a good practice ?
Spring can bind current request to the thread out of the box. If you use DispatcherServlet, it's done automatically, otherwise you need to declare RequestContextFilter.
Then you can access request properties via RequestContextHolder.