views:

728

answers:

2

I would need to implement an audit log for a web application written with JBoss Seam. EntityListeners seem like good candidates, but I don't know how to connect the EntityListeners to the application session context to include the logged in used principal in the audit record.

I wonder if there is a way to do this "connection", or if there is a more confortable/elegant/effective way to implement an audit log for this programming environment.

Thanks in advance.

Rafa.

Edit:
Many thanks to Damo for his answer! I tried the injection of my identity component, but it did not work. However, the suggested call to Component.getInstance() did provide the desired reference to the user's identity in the EntityListener.

+2  A: 

Have you tried injecting your Application/Session scoped Beans into the EntityListener? Or using Component.getInstance("myBean") if injection is unavailable.

Damo
A: 

following link could help u:

http://www.jroller.com/ksevindik/entry/audit_logging_at_service_level