[
https://issues.apache.org/jira/browse/WINK-245?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12805552#action_12805552
]
Bryant Luk commented on WINK-245:
---------------------------------
First off, if users really have enough problems with this, then I'm ok with
adding code to search for @Path on all interfaces/superclasses. Afterall,
we're here to help users.
Just to give some of my thoughts...
I interpreted the first line in the 3.6 Annotation Inheritance section in the
JAX-RS spec to be that annotations may only be inherited on methods and not the
type. It may be that I'm reading too much into the intent but the example
that's given in the spec also does not add a @Path to the interface as well to
showcase only annotations on methods should be inherited. There is also no
@java.lang.annotation.Inherited on @Path so I find it a bit odd.
By allowing the annotation inheritance, this also has some impact I imagine if
you are running in a Servlet 3.0/Java EE 6 environment where annotation
scanning is available. The implementations would have to scan the entire class
hierarchy for each class in the application instead of listening to just @Path,
potentially leading to long deployment times.
One final thing is that I don't think this makes any pragmatic sense from a
JAX-RS application point of view. If you annotate the interface and have
multiple classes implementing it, then which class would be used if you
returned all the classes in your JAX-RS application sub-class or if running in
a Servlet 3.0 container, all your classes were included in your WAR (and if you
relied on the annotation scanning to scan for all the root resource classes)?
There is no JAX-RS specified algorithm to determine which root resource class
to use in this case I believe.
> Annotations on interfaces - should they work?
> ---------------------------------------------
>
> Key: WINK-245
> URL: https://issues.apache.org/jira/browse/WINK-245
> Project: Wink
> Issue Type: Bug
> Reporter: Davanum Srinivas
>
> Here's an example.
> =======================================
> package org.apache.wink;
> import javax.ws.rs.GET;
> import javax.ws.rs.Path;
> import javax.ws.rs.Produces;
> @Path("/helloworld")
> public interface IHello {
> @GET
> @Produces("text/plain")
> public String getString();
> }
> =======================================
> package org.apache.wink;
> public class Hello implements IHello {
> public String getString() {
> return "Hello Stage 1";
> }
> }
> =======================================
> gives me a 404 with the following logs
> 704 [http-8080-1] WARN
> org.apache.wink.common.internal.application.ApplicationFileLoader - class
> org.apache.wink.Hello is neither a resource nor a provider. Ignoring.
> 797 [http-8080-1] INFO org.apache.wink.server.internal.RequestProcessor -
> WebApplicationException (404 - Not Found) occured during the handlers chain
> invocation
> 799 [http-8080-1] INFO
> org.apache.wink.server.internal.handlers.PopulateResponseMediaTypeHandler -
> Content-Type not specified via Response object or via @Produces annotation so
> automatically setting via generic-type compatible MessageBodyWriter providers
> I believe the same code works fine in other implementations. For example see
> CustomerResourceService on Page 35/36 in Restful Java with Jax-RS
> By Bill Burke
> http://books.google.com/books?q=CustomerResourceService
> thanks,
> dims
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.