【问题标题】:Apache CXF and Spring AOPApache CXF 和 Spring AOP
【发布时间】:2015-09-24 04:23:42
【问题描述】:

我已经使用 Apache Came 和 Apache CXF 以及“代码优先”方法部署了一个 Web 服务。它工作正常。

<cxf:cxfEndpoint id="operacionesWSEndpoint" address="/operaciones"
    serviceClass="foo.bar.OperacionesService">
</cxf:cxfEndpoint>

但我想衡量我的服务的性能并记录它。为此,我使用 Spring AOP 使用以下切入点

@Pointcut("execution(* foo.bar.OperacionesService.*(..))")
public void operacionsMethods() {

}

@Around("operacionsMethods()")
public Object logTimeMethod(final ProceedingJoinPoint joinPoint) throws Throwable {

    StopWatch stopWatch =
            new StopWatch(joinPoint.getTarget().getClass().getSimpleName() + "."
                + joinPoint.getSignature().getName());
    stopWatch.start();

    Object retVal = joinPoint.proceed();

    stopWatch.stop();

    log.debug("performance: {}", stopWatch.shortSummary());

    return retVal;
}

嗯,不工作。其他方法和服务正在使用相同的方法 (AOP) 进行记录,但不是 Camel 公开的 Web 服务。

我认为我的代码没有任何错误:服务和其他方面一样正常。我觉得我在这里遗漏了一些关于 Apache Camel - CXF 和 Spring AOP 的内容,但我没有发现类似的问题。

有什么想法吗?

【问题讨论】:

  • 多年前问过,但仍然 - 你当时找到解决方案了吗?

标签: java web-services apache-camel cxf spring-aop


【解决方案1】:

我没有尝试过骆驼和 Spring AOP,但您可以使用骆驼interceptor 作为替代方案。这不是你想要的安静。 此外,对于测量,您可以使用来自metrics library 的“仪表”和 Slf4jReporter。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    相关资源
    最近更新 更多