Java 是否从Jersey application.wadl中排除资源路径?
Jersey在/application.wadl处提供动态wadl。在我的例子中,我的应用程序中同时公开了内部路径和外部路径。我想从动态wadl生成中排除内部APIJava 是否从Jersey application.wadl中排除资源路径?,java,jersey-2.0,Java,Jersey 2.0,Jersey在/application.wadl处提供动态wadl。在我的例子中,我的应用程序中同时公开了内部路径和外部路径。我想从动态wadl生成中排除内部API 是否有一些配置告诉Jersey忽略某些路径 根据泽西岛文件: 你有三种方法: 在web.xml中设置将禁用整个wadl jersey.config.server.wadl.disableWadl=true @ExtendedResource的使用 注释不会在默认wadl中显示带注释的方法/类, 但只有在扩展的一个 根据17.2,您还
是否有一些配置告诉Jersey忽略某些路径 根据泽西岛文件: 你有三种方法:
最后我自己用这样的东西覆盖了它:
@Context
protected UriInfo uriInfo;
@Context
protected WadlApplicationContext wadlContext;
@GET
@Path("/wadl")
@Produces({"application/vnd.sun.wadl+xml", MediaType.APPLICATION_XML})
public Response wadl() {
// most of this is lifted from org.glassfish.jersey.server.wadl.internal.WadlResource
try {
boolean detailedWadl = WadlUtils.isDetailedWadlRequested(uriInfo);
String lastModified = new SimpleDateFormat(WadlResource.HTTPDATEFORMAT).format(new Date());
ApplicationDescription applicationDescription = wadlContext.getApplication(uriInfo, detailedWadl);
Application application = applicationDescription.getApplication();
application.getResources().stream().findFirst().get().getResource().removeIf(resource -> !resource.getPath().startsWith("/public_api"));
ByteArrayInputStream wadl = marshal(application);
return Response.ok(wadl).header("Last-modified", lastModified).build();
} catch (Exception e) {
throw new ProcessingException("Error generating WADL", e);
}
}