Reputation: 9306
I would like to create custom annotation for my domain classes in Grails for auditing. I'm thinking about listening to hibernate events and then save those annotated classes actions.
I still have problem with how could I get the action that called this domain class method and what was its arguments? How could I got them? Any ideas?
Thanks, Feras
Upvotes: 0
Views: 179
Reputation: 122394
You can use the RequestContextHolder to access the current GrailsWebRequest
GrailsWebRequest req = (GrailsWebRequest)RequestContextHolder.getRequestAttributes();
if(req != null) {
log.info("controller = " + req.getControllerName());
} else {
log.info("Not in a web request thread");
}
You also have req.getParams()
if you need the whole parameter map.
Upvotes: 1