1
我正在尝试使用Spring AOP来获得Apache CXF JAX-RS服务。我创建了一个简单的日志类:Apache CXF REST服务w/Spring AOP
public class AOPLogger {
public void logBefore(){
System.out.println("Logging Before!");
}
}
我的Spring配置(beans.xml文件):当呼叫的方法getServletRequest做出
<aop:config>
<aop:aspect id="aopLogger" ref="test.aop.AOPLogger">
<aop:before method="logBefore" pointcut="execution(* test.rest.RestService.*(..))"/>
</aop:aspect>
</aop:config>
<bean id="aopLogger" class="test.aop.AOPLogger"/>
我总是在RestService的NPE() ,它有:
return messageContext.getHttpServletRequest();
如果我删除aop配置或从我的beans.xml注释它,一切工作正常。
我所有的实际Rest服务扩展test.rest.RestService(这是一个类)并调用getServletRequest()。我只是试图根据CXF JAX-RS文档中的示例启动并运行AOP。我究竟做错了什么?