cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin" <sbery...@progress.com>
Subject Re: ParameterHandler Question
Date Thu, 15 Oct 2009 10:02:48 GMT
Hi Eric

It's a typo, sorry. Just fixed it. ParameterHandler implementations can be registered as providers;
there're examples showing how to 
register  providers, so I don't show it every time to save some space. For ex, here's how
you can do it from Spring :

<jaxrs:server address="/">
<jaxrs:providers>
   <ref bean="paramHandler"/>
</jaxrs:providers>
</jaxrs:server>

<bean id="paramHandler" "org.apache.cxf.systest.jaxrs.MapParamHandler"/>


thanks, Sergey

----- Original Message ----- 
From: "Eric Johnson" <EMJOHNSO@progress.com>
To: <users@cxf.apache.org>
Sent: Wednesday, October 14, 2009 10:05 PM
Subject: ParameterHandler Question


I was looking through the documentation on JAX-RS and found this:
CXF JAXRS supports ParameterHandler extensions which can be used to deal
with method parameters annotated with one of the JAXRS parameter
annotations :
public class MapHandler implements ParameterHandler<Map> {
    public Map fromString(String s) {...}
}

@Path("/")
public class Service {


    @PUT
    @Path("{id}")
    public Response update(@PathParam("g") Map m, byte[] bytes) {
        ...
    }
}
Note that ParameterHandlers can not be used to deal with parameters
representing a message body, "byte[] byte" in this example.
MessageBodyReaders have to deal with this task. That said, a given
MessageBodyReader implementation can also implement ParameterHandler.
ParameterHandlers can be registered as providers either from Spring or
programmatically.
I'm feeling a little stupid because I cannot figure out from the example
code what is going on. I see that the PathParam is looking for the path
segment "g" which does not appear to exist in the URI template and wants
to map that value into a Map. I also see that there is a
ParameterHandler implemented that maps a PathParam to a Map. So, does
the ParameterHandler get used when the URI template variable does not
exist? Or is it just a typo? Or does it not matter?
Also could an example of how the ParameterHandler is registered be
added?


Mime
View raw message