You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Andriy Redko (Jira)" <ji...@apache.org> on 2022/11/25 01:12:00 UTC

[jira] [Commented] (CXF-8797) NameBinding ignored when implementing interface

    [ https://issues.apache.org/jira/browse/CXF-8797?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17638439#comment-17638439 ] 

Andriy Redko commented on CXF-8797:
-----------------------------------

Thanks [~jensgr@gmx.net] , it seems like there is some misalignment in specification [1] regarding where NameBinding annotation could be placed:

*6.5.2 Name Binding* 
{noformat}
These annotations are declared using the JAX-RS meta-annotation @NameBinding and
are used to decorate both the filter (or interceptor) and the resource method or resource class. 

...

Binding annotations can also be applied to resource classes and Application subclasses. Binding annotations
that decorate resource classes apply to all resource methods defined in them.{noformat}
*Appendix A:*
{noformat}
NameBinding - Meta-annotation to create annotations for binding filters
or interceptors to resource methods and applications.
Name binding is only supported as part of the Server API. {noformat}
 

*Javadoc [2]:*

 
{noformat}
At last, the name-binding annotation is applied to the resource method(s) to which the
 name-bound JAX-RS provider(s) should be bound to:

   @Path("/")
  public class MyResourceClass {
      @GET
      @Produces("text/plain")
      @Path("{name}")
      @Logged
      public String hello(@PathParam("name") String name) {
          return "Hello " + name;
      }
  }
  {noformat}
 

The Apache CXF only supports NameBinding on operations level at the moment.
Thank you.


[1] [https://download.oracle.com/otndocs/jcp/jaxrs-2_1-final-eval-spec/index.html]

[2] https://javadoc.io/doc/javax.ws.rs/javax.ws.rs-api/latest/javax/ws/rs/NameBinding.html

> NameBinding ignored when implementing interface
> -----------------------------------------------
>
>                 Key: CXF-8797
>                 URL: https://issues.apache.org/jira/browse/CXF-8797
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.5.4
>            Reporter: Jens Kleine-Herzbruch
>            Priority: Major
>
> I have the following setup:
> 1. An interface that carries most of the JAX-RS annotations ({{@Path}}, {{@GET}}, etc.). This interface is provided by a third party.
> 2. A service implementing this interface. This is what I'm developing myself. It does not carry any JAX-RS annotations itself.
> 3. A provider ({{ContainerResponseFilter}} in my case) that I now want to attach to some of the operations with {{@NameBinding}}.
> Obviously, I can only add the {{@NameBinding}} annotation to the implementation class. It looks to me like CXF is only checking against the interface carrying the main JAX-RS annotations at runtime, however, so the filter is never called.
> If I remove the NameBinding entirely and run the filter as a global filter, it works as expected, but of course that's not the intent here.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)