Uploaded image for project: 'Tools (JBoss Tools)'
  1. Tools (JBoss Tools)
  2. JBIDE-16734

JAX-RS Validation: should report an error when resource is annotated with @javax.inject.Singleton and has JAX-RS fields

XMLWordPrintable

    • Icon: Feature Request Feature Request
    • Resolution: Unresolved
    • Icon: Major Major
    • LATER
    • 4.1.1.Final
    • webservices

      JAX-RS Validation: should report an error when resource is annotated with @javax.inject.Singleton and has JAX-RS fields.

      Eg:

      @Path("resource")
      @Singleton
      public static class MySingletonResource {
       
          @QueryParam("query")
          String param; // WRONG: initialization of application will fail as you cannot
                        // inject request specific parameters into a singleton resource.
       
          @GET
          public String get() {
              return "query param: " + param;
          }
      }
      

      The exception exists for specific request objects which can injected even into constructor or class fields. For these objects the runtime will inject proxies which are able to simultaneously server more request. These request objects are HttpHeaders, Request, UriInfo, SecurityContext. These proxies can be injected using the @Context annotation

            Unassigned Unassigned
            xcoulon@redhat.com Xavier Coulon
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: