jax-rs-spec
  1. jax-rs-spec
  2. JAX_RS_SPEC-450

Specification text and DefaultValue/Encoded docs should clarify where annotations have to be located on bean setters for them to be effective

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.0
    • Fix Version/s: 2.1
    • Component/s: model api, spec
    • Labels:
      None

      Description

      We have a user request implying that the following is correct:
      (1)

      public class Root {
         @QueryParam("{id}")
         @A
         @B
         @Encoded 
         @DefaultValue("1")
         public void setId(String id) {}
      }
      

      as opposed to

      (2)

      public class Root {
         @QueryParam("{id}")
         public void setId(@A @B @Encoded @DefaultValue("1") String id) {}
      }
      

      It is not really obvious which version is right or if both versions are OK. JAX-RS @Encoded and @DefaultValue can target Methods but it is not obvious @A & @B can. For example, they may have been built originally with the idea that they would be applied to resource method parameters, which is often a typical case.

      Specifically, the question came up in scope of discussing passing annotations to ParamConverterProvider on BeanParam setters.
      In fact ParamConverterProvider documentation provides the only hint that it is really the option (2) which is correct, "E.g. if a string value is to be converted into a method parameter, this would be the annotations on that parameter as returned by Method.getParameterAnnotations()."

      IMHO some further clarifications will help.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Santiago Pericas-Geertsen
            Reporter:
            beryozkin_sergey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: