struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miguel <mig...@almeida.at>
Subject Re: Can we use spring-plugin to inject a HttpServletRequest onto a bean?
Date Fri, 27 May 2011 12:24:57 GMT
Hi Dave,

On Fri, 2011-05-27 at 08:10 -0400, Dave Newton wrote:

> What specifically do you need an actual request for? This strikes me
> as coupling your design to the servlet spec, and there's rarely a
> strong reason to do that past the web layer itself. The idea on
> injecting a request just seems wrong.
> 
> Is that a Struts 2 interceptor you're trying to inject it in to?
> 

It's an hibernate interceptor. It kicks in when you're committing the
transaction to the database. This audit interceptor stores who changed
what information. In very simple terms:

date || user || property || old value || new value || ipaddress||
2011-05-27 13:18 || dnewton || patient[22].age || 27 || 40 ||
83.999.21.21||

This class is the one responsible for:
a) detecting what changes are being made
b) Detecting who made the changes 
c) log that info onto the database.

This interceptor extends an org.hibernate.EmptyInterceptor (that kicks
in with methods like onSave, onDelete, etc). I need the
HttpServletRequest because it's the only way I've found to:
a) retrieve the username (request.getUserPrincpal.getName)
b) retrieve the user's IP address.

Do you see any other better alternative and/or a solution to my previous
mails' question?

Thanks a lot for your quick reply!

Miguel Almeida

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message