Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-596

subresources with jax-rs annos on superclass's interfaces

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.3-beta-1
    • 2.2.2.GA
    • jaxrs
    • None
    • Hide

      Workaround is to manually push the interface method annotations down to the abstract implementation in the superclass.

      Show
      Workaround is to manually push the interface method annotations down to the abstract implementation in the superclass.

      In situations like this:

      interface SuperInt
      {
          @Path("foo")
          @GET
          @Produces("application/json")
          String getFoo();
      }
      
      abstract class SuperIntAbstract implements SuperInt
      {
          @Override
          public String getFoo()
          {
              return "Foo: " + getName();
          }
          protected abstract String getName();
      }
      
      @Path("/somewhere")
      class SomeOtherResource
      {
          @Path("superint")
          public SuperInt getSuperInt()
          {
              return new SuperIntAbstract()
              {
                  @Override
                  protected String getName()
                  {
                       return "Fred";
                   }
              };
          }
      }
      

      When a client accesses GET /somewhere/superint/foo, resteasy throws indicating that it doesn't think the returned type from getSuperInt() has JAX-RS annotations. In GetRestful.getSubResourceClass(), resteasy looks first up the superclass chain for JAX-RS annotations, then it looks only at the immediate class's interfaces and throws if they don't have JAX-RS annos.

      Is it possible that resteasy should examine superclass interfaces as well? What is the purpose of finding a single class with some jaxrs annotations? What if the class (or a superclass) implemented several interfaces that had different, but compatible annotations?

            patriot1burke@gmail.com Bill Burke (Inactive)
            yarrumretep_jira Peter Murray (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: