我写了一个CustomValidationInterceptor。我想使用注释在服务级别配置此拦截器。假设,如果我暴露了5个服务,并且我想仅为其中一个服务配置拦截器,那我该怎么做呢
以下是我当前没有触发拦截器的代码
@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...
}
}
My custom Interceptor的代码片段是:
@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
}
}