如何在Aspect类中注入HttpHeader

时间:2017-04-18 11:19:52

标签: logging cdi aspectj inject

我试图在方面类中注入HttpHeader

这是代码:

public aspect RestRequestsAspect {

    @Context HttpHeaders httpHeaders;

    @Before("endPointsInterfacesCut() || servicesCut() || patternCrudCut()")
    public void beforeCreate(JoinPoint joinPoint) {
        printLogTrace(joinPoint);
    }

    private void printLogTrace(JoinPoint joinPoint) {
        if (this.httpHeaders != null)
            LoggerFactory.getLogger(joinPoint.getTarget().getClass().getName()).info(httpHeaders.toString());
    }
}

它没有记录任何内容,因此HttpHeader必须为null。

CDI需要将HttpHeader注入方面?

0 个答案:

没有答案