小编Lyo*_*ang的帖子

如何在 jax-rs 的 ContainerRequestFilter 中获取资源方法注解

我编写了一个类扩展 ContainerRequestFilter 以进行权限检查。如何获取匹配方法的注释以进行权限检查。

@javax.ws.rs.ext.Provider
public class AuthorizationRequestFilter implements ContainerRequestFilter {
    public void filter(ContainerRequestContext requestContext) throws IOException {
    // how can I get resources' methods' annotation here? 
    // from the resource below , I want to checkout whether the target matched method contains the @ReadPermission annotation
    }
}

@Path("/region")
public class Region {
   @POST
   @Path("/{region_id}")
   @Produces({MediaType.APPLICATION_JSON , MediaType.APPLICATION_XML})
   @ReadPermission
   public String getRegion() {
      return null;
   }
}
Run Code Online (Sandbox Code Playgroud)

java permissions rest cxf jax-rs

1
推荐指数
1
解决办法
3890
查看次数

标签 统计

cxf ×1

java ×1

jax-rs ×1

permissions ×1

rest ×1