【发布时间】:2011-12-30 20:24:55
【问题描述】:
我希望我的 AOP 建议能够处理当前正在执行的 Jersey 资源的 HttpContext。 spring-annotations 示例提到用户可以获取请求并进行身份验证等,但是如何获取通知中上下文中的任何值?
目前我的资源定义如下所示:
@Singleton
@Path("/persist")
public class ContentResource {
@PUT
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Auth
public Content save(Content content){
//Do some thing with the data
}
}
方面是这样定义的:
@Aspect
public class AuthorizeProcessor {
@Around(value="@annotation(package.Auth) and @annotation(auth)", argNames = "auth")
public Object authorize(ProceedingJoinPoint pjp, Auth auth) throws Throwable{
//How do I get the HttpContext here?
return pjp.proceed();
}
}
【问题讨论】:
标签: jersey spring-aop