TP_JAVA
TP_JAVA

Reputation: 1002

Looking for interceptors for grails service class

Is there any interceptor I can use to validate incoming requests to the Grails service classes/Endpoints? I know interceptors for controllers but I want to do it for Service/endpoint.

Upvotes: 1

Views: 1404

Answers (2)

Gagan Agrawal
Gagan Agrawal

Reputation: 139

In the link mentioned above(Kelly's reply), interceptor logic for Service has been added in BootStrap class. That might suffice in most of the cases but not all. In case you are using Quartz scheduler then job might get triggered even before BootStrap has made required modifications.

The best place to modify a service method would be via custom plugin. You can decorate service method in doWithApplicationContext or doWithDynamicMethod available in Plugin class. These methods are triggered at first and guarantee that changes made will be available to all other classes. Please refer Grails custom plugin documentation for more information.

Upvotes: 1

Kelly
Kelly

Reputation: 3709

This sounds like what you are looking for: Intercepting Service Methods

Upvotes: 3

Related Questions