1

我写了一个 CustomValidationInterceptor。我想使用注释在服务级别配置此拦截器。假设,如果我已经公开了 5 个服务,并且我想为这些服务中的 1 个配置拦截器,那么我该怎么做

以下是我当前的代码,它没有触发拦截器

@Service("someService")
@Path("somePath")
@InInterceptors(interceptors = { "com.telus.ffo.msl.service.impl.CustomValidationInterceptor" })
public class SystemCheckRestService {


    @POST
    @Path("/{phoneNumber}")
    @Produces({"application/json;charset=UTF-8"})
    public Response preRepairTest(@PathParam("phoneNumber") String phoneNumber) {
    // Code...
    }
}

我的自定义拦截器的代码片段是:

@Component
public class CustomValidationInterceptor extends AbstractPhaseInterceptor<Message>{

    public CustomValidationInterceptor() {
        super(Phase.PRE_INVOKE); // Put this interceptor in this phase
    }

    public void handleMessage(Message message) {
        // some code
     }

}
4

0 回答 0