cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Moody (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-1572) @Path is not mapping to required methods
Date Tue, 06 May 2008 16:36:56 GMT
@Path is not mapping to required methods
----------------------------------------

                 Key: CXF-1572
                 URL: https://issues.apache.org/jira/browse/CXF-1572
             Project: CXF
          Issue Type: Bug
          Components: REST
    Affects Versions: 2.1
         Environment: Win XP, Sun JDK 1.5_011
            Reporter: Brad Moody
            Priority: Minor
             Fix For: 2.1.1


Hi


    Hi,

    I'm getting an issue where my @Path annotations aren't mapping to the
    required URLs. Here's a rough outline of my test class:

    @Path(value="/{domain}/{network}/{user}/mail")
    public class MailService {

    @GET
    @ConsumeMime({"application/xml", "application/json"})
    @ProduceMime({"application/xml", "application/json"})
    public MailFolderDocument listMail(@PathParam("domain")String domain,
    @PathParam("network")String network, @PathParam("user")String user,
    @HeaderParam("token")String token){
              ....
          }

    @Path(value="/{messageId}", limited=true)
    @GET
    @ConsumeMime({"application/xml", "application/json"})
    @ProduceMime({"application/xml", "application/json"})
    public MessageDocument readMessage(@PathParam("user")String user,
    @PathParam("messageId")String messageId, @HeaderParam("token")String
    token){
              ....
          }
    }

    The problem I'm seeing is that when i invoke the URL
    http://localhost:8081/cxf/rest/test/domain/network/brad/mail, it
    invokes the readMessage method instead of listMail. Am I using the
    correct format for my annotations here?


The annontations seem fine. Can you confirm please, as your're debugging, that listMail()
is also added to the list of candidates ?
I'm actually not sure what exactly JAX_RS says in this regard, the only piece I can see is
this one (section 3.6, 2.f) :

"Sort E using the number of literal characters in each member as the primary key (descending
order), ..., number of capturing groups as the secondary key, and the source of each member
..."

In both cases it's a resource method, so the source is the same. Number of captuting groups
for listMail is 3 as opposed to 2 for readEmail(), and the number of literal characters is
different. It seems like only this bit of the specification which governs the dispatch in
this case, but I''ll need to verify it...

One possible workaround is to

1. Have another root class created, but with slightly different Path.

In the end, I believe it's the CXF bug rather than the ambiguity of the JAX-RS spec...Can
you please open a JIRA ?





    Anyway, just in case I have got it right (*pig flies by*) I stepped
    through JAXRSUtils.findTargetMethod and I was left wondering if this
    line is correct:

    private static final String URITEMPLATE_VARIABLE_REGEX = "(.*?)";

    I'm no regex expert but I did find this in the Java 1.5 API docs:

    X*?  X, zero or more times
    X+? X, one or more times

    Would that value make more sense as "(.+?)" ?


This is required by the spec, every template parameter is substituted by this reg expression.
The rationale I believe is that it
makes it possible for a given method act as a subresource locator...

Cheers, Sergey


    Thanks,
    Brad.


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message