Hi I'm going through the Jersey Getting Started Guide.
In Chapter 6 they use the @Ref annotation to inject the URI of a resource. I've followed the example, but my uri is always null.
How can I add the com.sun.jersey.server.linking.LinkFilter
to com.sun.jersey.spi.container.ContainerResponseFilters
programatically? I've already seen a bunch of examples using web.xml.
Thanks!
I ended up retrieving the ResponseFilters
from the ResourceConfig
and then adding an instance of LinkFilter
to it.
private static HttpServer startServer() throws IOException {
LOG.info("Starting server...");
ResourceConfig rc = new PackagesResourceConfig("com.mycomp.resources");
rc.getContainerResponseFilters().add(new com.sun.jersey.server.linking.LinkFilter());
return GrizzlyServerFactory.createHttpServer(BASE_URI, rc);
}