Java 侦听器批注中的CXF不工作+;JAX-RS
我已经写了一个CustomValidationInterceptor。我想使用注释在服务级别配置这个拦截器。假设,如果我已经公开了5个服务,并且我只想为其中的1个服务配置拦截器,那么我该怎么做呢 下面是我当前的代码,它没有触发拦截器Java 侦听器批注中的CXF不工作+;JAX-RS,java,web-services,cxf,jax-rs,interceptor,Java,Web Services,Cxf,Jax Rs,Interceptor,我已经写了一个CustomValidationInterceptor。我想使用注释在服务级别配置这个拦截器。假设,如果我已经公开了5个服务,并且我只想为其中的1个服务配置拦截器,那么我该怎么做呢 下面是我当前的代码,它没有触发拦截器 @Service("someService") @Path("somePath") @InInterceptors(interceptors = { "com.telus.ffo.msl.service.impl.CustomValidationIntercepto
@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
}
}
@组件
公共类CustomValidationInterceptor扩展了AbstractPhaseInterceptor{
公共CustomValidationInterceptor(){
super(Phase.PRE_INVOKE);//将此拦截器置于此阶段
}
公共无效handleMessage(消息消息){
//一些代码
}
}