Skip to content

@Provider annotation on client on server-side #746

@marekkopecky

Description

@marekkopecky

According to the spec, it seems that ClientRequestFilter with @Provider annotation should be used with Client without registration. This behaviour currently doesn't work on Jersey, RESTEasy fix this on server side (see RESTEASY-2084, RESTEASY-2163)

I suggest to make clear in the spec, that this can work on server side, but not on standalone client application (outside of the container).

Example of server-side client usage:

@Provider
public class TestClientRequestFilter implements ClientRequestFilter {
    public void filter(ClientRequestContext clientRequestContext) {
        System.out.println("Hello from ClientRequestFilter");    
    }
}
@Path("/a")
public class Resource {
    @GET
    @Path("/a")
    public String a() {
        return "ok";
    }
    @Path("/b")
    @GET
    public String b() {
        Client client = ClientBuilder.newBuilder().build();
        final WebTarget target = client.target("http://127.0.0.1:8080/jaxrs-wf/a/a");
        final Response response = target.request().get();
        System.out.println(response.getStatus());
        System.out.println(response.readEntity(String.class));
        System.out.println();
        return "ok";
    }
}

The same situation is for ClientResponseFilter, MessageBodyReader, MessageBodyWriter, AsyncClientResponseProvider, ReaderInterceptor, WriterInterceptor, DynamicFeature

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions