I have a running JSF2 application and now want to add a request logging feature.
Logging will be saved to db and consist of the standard user/page/IP trio with other generated content.
Now calling a dao method in @PostConstruct annotated methods in managed beans but this seems like code duplicate.
@PostConstruct
public void init() {
loggingDao.save(user,page,ip);
}
How can I centralize this logging/auditing process on jsf side using managed beans? Since this is a crosscutting scenario, I do not want to add this code to every managed bean.
EDIT The question got lots of comments which implies that it is not asked in a correct way.
One last chance: I need to log/watch user interaction on my site, either it may be a login action or a button clicked to list items (which maps to a backing bean methods) or a page navigation/redirect.
I also assume that I can use this same architecture to decide if the user has the rights for a specific action on the site, but this is another story since its outcomes would be different.