[jboss-jira] [JBoss JIRA] (WFLY-10319) NameBinding annotations on resources are ignored in subresources

Marek Kopecký (Jira) issues at jboss.org
Thu Jan 31 05:25:02 EST 2019


    [ https://issues.jboss.org/browse/WFLY-10319?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13689611#comment-13689611 ] 

Marek Kopecký commented on WFLY-10319:
--------------------------------------

{quote}The way I understand this is that sub-resource locators, despite not being annotated with a request method designator, are considered resource methods{quote}

This doesn't corresponds to chapter 3.3 of spec and this doesn't corresponds to the reference jax-rs implementation (Jersey). But I admit that this could be confusing.

[~ron_sigal] or [~asoldano]: We need a dev decision here. It could be also usefull to discuss this with jax-rs expert group or jax-rs mailing list. This could be explained in next jax-rs spec version ([jax-rs roadmap|https://github.com/eclipse-ee4j/jaxrs-api/wiki/Roadmap]).

> NameBinding annotations on resources are ignored in subresources
> ----------------------------------------------------------------
>
>                 Key: WFLY-10319
>                 URL: https://issues.jboss.org/browse/WFLY-10319
>             Project: WildFly
>          Issue Type: Bug
>          Components: REST
>    Affects Versions: 12.0.0.Final
>            Reporter: Javier Estevez Sanchez
>            Assignee: Alessio Soldano
>            Priority: Major
>
> The following JAX-RS resource exposes two resources via a GET operation: /demo and /demo/subresource. The first one via a sub-resource method, the latter via a sub-resource locator. Additionally, a response filter is binded to the JAX-RS resource class to modify the response. From the JAX-RS 2.0 spec, §6.5.2 Name Binding:
> {quote}
> Binding annotations that decorate resource classes apply to all resource methods defined in them.
> {quote}
> However, the binding annotation is not applying to the sub-resource locator method. This happens when the name binding annotation is on the resource class or on the sub-resource locator method. Annotating the sub-resource class or the method within works as expected, though.
> Below is the code needed to reproduce this issue:
> {code:java|title=The resource and subresource}
> @DemoNameBinding
> @Produces(MediaType.APPLICATION_JSON)
> @Path("/demo")
> public class DemoResource {
>     @GET
>     public String getDemoValue() {
>         return "A value";
>     }
>     @Path("/subresource")
>     public DemoSubResource getSubResource() {
>         return new DemoSubResource();
>     }
>     public class DemoSubResource {
>         @GET
>         public String getDemoValue() {
>             return "A value";
>         }
>     }
> }
> {code}
> {code:java|title=The filter}
> @Provider
> @DemoNameBinding
> public class SomeFilter implements ContainerResponseFilter {
>     @Override
>     public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) {
>         responseContext.setEntity("A filtered value");
>     }
> }
> {code}
> {code:java|title=The binding}
> @NameBinding
> @Target({ElementType.TYPE, ElementType.METHOD})
> @Retention(RetentionPolicy.RUNTIME)
> public @interface DemoNameBinding {
> }
> {code}



--
This message was sent by Atlassian Jira
(v7.12.1#712002)



More information about the jboss-jira mailing list