简体   繁体   English

寻找grails服务类的拦截器

[英]Looking for interceptors for grails service class

Is there any interceptor I can use to validate incoming requests to the Grails service classes/Endpoints? 是否有任何拦截器可用于验证对Grails服务类/端点的传入请求? I know interceptors for controllers but I want to do it for Service/endpoint. 我知道控制器的拦截器,但我想为Service /端点做。

这听起来像你在寻找: 拦截服务方法

In the link mentioned above(Kelly's reply), interceptor logic for Service has been added in BootStrap class. 在上面提到的链接(Kelly的回复)中,Service的拦截器逻辑已添加到BootStrap类中。 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. 如果您使用的是Quartz调度程序,那么即使在BootStrap进行了必要的修改之前,也可能会触发作业。

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. 您可以在plugin类中的doWithApplicationContext或doWithDynamicMethod中修饰service方法。 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. 有关更多信息,请参阅Grails自定义插件文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM