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

missing support for "fromString" parameter types

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.0.1.GA
    • Fix Version/s: 2.2-beta-1
    • Component/s: None
    • Labels:
      None

      Description

      JSR 311 Javadoc for PathParam annotation (https://jsr311.dev.java.net/nonav/javadoc/index.html) says:

      The type of the annotated parameter, field or property must either:
      ....
      Have a static method named valueOf or fromString that accepts a single String argument (see, for example, Integer.valueOf(String))
      ....

      RESTEasy doesn't support the fromString variant. When I try to deploy resource with this kind of method, it fails with:
      java.lang.RuntimeException: Unable to find a constructor that takes a String param or a valueOf() method for javax.ws.rs.PathParam("var") on public java.lang.String org.jboss.resteasy.exttests.params.ParamTestResource.pathparam(org.jboss.resteasy.exttests.params.Box3) for basetype: org.jboss.resteasy.exttests.params.Box3

      The method in the resource looks like this:
      -----------------------
      @GET
      @Path("/pathparam15/

      {var}

      ")
      public String pathparam(@PathParam("var") Box3 var)

      { return "Received: \"" + var + "\""; }

      the Box3 class looks like this:
      -----------------------
      package org.jboss.resteasy.exttests.params;

      /**

      • A class with fromString(String) method.
        */
        public class Box3 {
        private String content;

      public static Box3 fromString(String aBox3)

      { Box3 r = new Box3(); r.content = aBox3; return r; }

      public String getContent()

      { return content; }

      public void setContent(String content)

      { this.content = content; }

      @Override
      public String toString()

      { return "Box3(" + content + ")"; }

      }

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                bill.burke Bill Burke
                Reporter:
                mlinhard Michal Linhard
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: