Java – envers custom revision listener

I use hibernate envers in Tomcat environment It works normally But I need the user name of the user who can add and change the data to be audited This can be done by implementing your own version of revisionentity Then, you must also implement a custom revisionlistener that will populate the additional information you want to audit I need to audit the user name that has changed the data to audit In the documentation, it is an example of how to do this using seam In revisionlistener, they call:

Identity identity = (Identity) Component.getInstance("org.jboss.seam.security.identity");

Get user name In my project, we split the project into separate modules of database and web I need to implement my Custum revision listener in my database module to get the currently logged in user name I cannot move revisionlistener to web package and introduce dependency on web module from database module How to obtain the current user name by simultaneously processing multiple user logins in my custom revisionlistener?

The best solution is one that works in most containers

Solution

I can understand that you want to limit the coupling between modules I've done this in the past using spring and JSF I have data access code in their own projects, and my web projects rely on data access tanks

I wrote listeners in another project that understands hibernate classes and JSF APIs I can use the JSF API to find login users

In this way, web applications depend on data and listener projects A data access project does not need to know where it is used, even if an audit occurs And the listener is configured in the web project

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>